Reputation:
I need to encode a wav file to another file format (pcm). This format has to following properties: 8kHz, 16-bit.
Has anybody an idea how to do this in c# or vb?
Upvotes: 2
Views: 7560
Reputation: 6468
Here are the key features.
Upvotes: 4
Reputation: 59645
An uncompressed Wave file contains plain PCM data plus some meta data - you can find a description here at Wotsit.org.
If the sampling rates, resolutions, and number of channels match, you can just strip off the meta data.
If they do not match, you will have to resample the Wave file, but this is not a trivial task, if you want it done right (Downsampling requires low-pass filtering the data in order to avoid aliasing because of the Nyquist–Shannon sampling theorem and both - upsampling and downsampling - require good interpolation - ideally sinc interpolation.
Upvotes: 2
Reputation: 466
I am not sure exactly what you want to do. WAV files are (usually) just wrappers around uncompressed pcm data.
But, whether you want to access the data, or write out RAW header-less PCM files, you can use libsndfile. I found some c# sample code on the ArsTechnica forums.
RE: Daniel Brückner's Answer
The author of libsndfile also wrote libsamplerate, which can simplify resampling.
Upvotes: -1