JaQ
JaQ

Reputation:

Encode wav file to pcm

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

Answers (3)

Searock
Searock

Reputation: 6468

Alvas audio library.

Here are the key features.

  • Recorder allows:
    • record uncompressed audio data (PCM)
    • record compressed audio data: IMA ADPCM, Microsoft ADPCM, CCITT A-Law, CCITT u-Law, GSM 6.10, MPEG Layer-3 (mp3) and others;
    • record data to the stream (file stream, memory stream);
    • pause and resume recording;
    • get the current sound position;
    • record data to any recorder installed in the system (multiple sound cards).

  • Player allows:
    • play uncompressed audio data (PCM);
    • play compressed audio data: IMA ADPCM, Microsoft ADPCM, CCITT A-Law, CCITT u-Law, GSM 6.10, MPEG Layer-3 (mp3) and others;
    • play data from the stream (file stream, memory stream);
    • play mixed audio data;
    • pause and resume playing;
    • get the current sound position;
    • play data from any player installed in the system (multiple sound cards).

  • Set up mixer controls:
    • select source line for recording;
    • change source line volume for recording;
    • additional controls adjustment. For example, "Mic Boost";
    • change master volume for playback;
    • playback muting.

  • Editing
    • change the speed of audio data;
    • change the volume of audio data;
    • join several pieces of audio in a single;
    • cut a piece of the audio stream;
    • insert a piece in the audio stream;
    • remove a piece of the audio stream;
    • create audio format from the byte array;
    • insert and mix audio data into main audio data with specified offset multiple times;
    • reverse audio wave stream;
    • split stereo audio stream to two mono streams;
    • merge two mono audio streams into one stereo.
    • Several audio files concatenation.

  • Converting
    • Convert the audio data from one audio format to another.
    • Convert audio wave stream to mp3 stream.
    • Convert Dialogic .vox (adpcm) stream to Mp3 stream.
    • Change Wave stream to MP3 stream. if Wave stream contains MPEG Layer 3 data.
    • Play, record and convert RAW headerless format (SLINEAR etc) (used in Asterisk PBX).
    • Play and extract audio data from Avi streams.
    • Encode and decode Dialogic .vox (adpcm) format data (used in Asterisk PBX).
    • Convert audio wave stream to mp3 stream
    • Convert Dialogic .vox (adpcm) stream to Mp3 stream

  • Misc
    • View the level of the input sound signal.
    • Sign library with strong name. Audio library can be added to GAC

Upvotes: 4

Daniel Brückner
Daniel Brückner

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

wmmeyer
wmmeyer

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

Related Questions