lordmulder / DynamicAudioNormalizer

Dynamic Audio Normalizer
Other
251 stars 36 forks source link

How to produce normalized files in C# project? #6

Closed ArthurMarz closed 8 years ago

ArthurMarz commented 8 years ago

When I use your solution with sampling classes from example for *.mp3 normalization in my C# solution it creates a file with equal towards original size, but with errors while playing on. If your library able to normalize mp3? If yes, I am sincerly requesting you to give me a piece of advice how I can fix it.

lordmulder commented 8 years ago

When I use your solution with sampling classes from example for *.mp3 normalization in my C# solution it creates a file with equal towards original size, but with errors while playing on. If your library able to normalize mp3? If yes, I am sincerly requesting you to give me a piece of advice how I can fix it.

If you use the library directly via API, you have to pass "raw" PCM audio samples. The library has a "streaming" design, so it doesn't matter whether those samples came from an MP3 file or from somewhere else. They could even come from "live" capturing device. But: If the source is MP3, then you will have to take care of decompressing the MP3 data to PCM yourself, before passing it to the library. Passing the compressed MP3 to the library - as if it was PCM data - is clearly going to produce garbage results!

If you don't want to take care of MP3 decoding yourself, there are libraries for that! Or you can use the modified SoX version that we provide. Or you can use an up-to-date FFmpeg, which now contains the DynAudNorm as a filter. Or you can use the VST plugin we provide, in the audio editor of your choice.

ArthurMarz commented 8 years ago

Please, can you tell me the libraries to covert PCM - MP3 and back? Also if WAV fit or I need to convert it aswell?

lordmulder commented 8 years ago

Please, can you tell me the libraries to covert PCM - MP3 and back?

I think LAME (libmp3lame) and libmpg123 would be the usual candidates here. But please don't ask me for C# bindings. Maybe they already exist, maybe you have to create them yourself :sweat_smile:

Yet another option: You may use DirectShow (or MediaFoundation) framework. At least for decoding.

See also: http://www.codeproject.com/Articles/5901/C-MP3-Compressor


Also if WAV fit or I need to convert it aswell?

WAV is a container format that may contain various audio formats (PCM, ADPCM, MP3, etc), however storing PCM data is by far the most common use of WAV format. Still, you will need to parse the WAV file, in order to determine the properties (bit depth, sampling rate, number of channels, etc.) and to extract the PCM samples. Writing a WAV reader is not rocket science though. WAV is relatively simple format.

See also: http://www.lightlink.com/tjweber/StripWav/Canon.html