MY WEBCAM TEST GUIDE

How to Convert PCM Audio Files

Convert raw or WAV PCM audio to WAV, FLAC or MP3, or create PCM from other formats. Covers the settings to enter, local versus online tools, and fixes for noise and wrong speed.

PCM (pulse-code modulation) is uncompressed digital audio: a plain sequence of samples with no compression. It often sits inside a WAV or AIFF file, but some recorders, voice tools and embedded devices save it as a bare .pcm or .raw file with no header. A file without a header does not say how it was recorded, so most players cannot open it. This guide shows how to convert PCM into a playable format, how to produce PCM from other audio, and how to check that the result sounds right.

Before you start

First find out which kind of file you have. A .wav file usually already contains PCM with a header, and most players and editors open it directly. You may only need to change its sample rate, bit depth or container. A headerless .pcm or .raw file needs extra information before any converter can read it.

For a headerless file, collect these parameters from the documentation or settings of the device or app that made the recording:

  • Sample rate, for example 8000, 16000, 44100 or 48000 Hz
  • Sample format and bit depth, for example signed 16-bit, signed 24-bit, 32-bit float or unsigned 8-bit
  • Byte order (endianness), usually little-endian on common desktop and mobile hardware
  • Number of channels: mono or stereo
  • Whether the file starts with a header or other extra bytes that should be skipped

Decide where the conversion will run. Desktop tools such as Audacity and the FFmpeg command-line tool process files on your own computer. Online converters upload your audio to a remote service. If the recording contains calls, meetings or other private speech, check the service's own statements on storage, retention and deletion before you upload, and treat them as claims to verify, not guarantees. Many online converters also need the parameters listed above and may not accept headerless files at all.

Work on a copy and keep the original file unchanged. If you guess a setting wrong, you can then try again without losing data.

Step-by-step instructions

Option 1: Audacity (graphical editor)

  • Open Audacity and choose File, then Import, then Raw Data. Menu wording can differ slightly between versions.
  • Select your .pcm or .raw file.
  • In the import dialog, set Encoding (for example Signed 16-bit PCM), Byte order, Channels and Sample rate to match the source. Leave Start offset at 0 unless you know the file begins with extra bytes.
  • Confirm the import and play the first few seconds. If you hear static or the speed is wrong, undo the import and try again with different settings (see the troubleshooting section below).
  • When playback sounds correct, use the export command in the File menu. Choose WAV for lossless output that most programs accept, FLAC for smaller lossless files, or MP3 if you need compatibility and accept lossy compression.
  • In the export options, choose the output sample rate and bit depth. Keep them the same as the source unless a target device or service requires something else.

Option 2: FFmpeg (command line)

FFmpeg needs the same parameters, passed before the input file. The -f option sets the raw sample format, -ar sets the sample rate and -ac sets the channel count. For signed 16-bit little-endian stereo at 44100 Hz, wrapping the data in a WAV file looks like this: ffmpeg -f s16le -ar 44100 -ac 2 -i input.pcm output.wav

  • Other common raw formats: s16be (16-bit big-endian), s24le (24-bit little-endian), s32le (32-bit integer), f32le (32-bit float) and u8 (unsigned 8-bit).
  • To produce FLAC, change the output name to output.flac.
  • To produce MP3, add an encoder option, for example -c:a libmp3lame -b:a 192k before the output name. This works only if your FFmpeg build includes that encoder.
  • To change the sample rate during conversion, add -ar with the new value after the input file, for example -ar 48000 before the output name.

Converting into PCM

Sometimes the task runs the other way: a device, speech engine or embedded player expects raw PCM. In FFmpeg you specify the output format instead of the input format. For example, ffmpeg -i input.mp3 -f s16le -ar 16000 -ac 1 output.pcm creates headerless mono 16-bit audio at 16000 Hz. To keep a header, write a WAV file with a PCM codec instead: ffmpeg -i input.mp3 -c:a pcm_s16le output.wav. In Audacity, open the file normally and export with the uncompressed or raw option offered by your version. Match the sample rate, bit depth and channel count to what the target system documents.

Check the output

Listen to the start, middle and end of the converted file. Normal speech or music at the expected speed and pitch means the input settings were correct. Next, confirm the technical properties: open the file's information panel in your player or editor, or run ffprobe output.wav to see the codec, sample rate, channel count and duration.

For a headerless source, you can check the duration with simple arithmetic. Divide the file size in bytes by the sample rate multiplied by the number of channels multiplied by the bytes per sample (2 for 16-bit, 3 for 24-bit, 4 for 32-bit). The result is the length in seconds. If it differs clearly from the known length of the recording, one of the parameters is wrong.

Keep the format limits in mind. WAV and FLAC preserve the PCM samples exactly. MP3 and other lossy formats discard some audio information. Raising the sample rate or bit depth does not restore detail that was never recorded. Reducing bit depth, for example from 24-bit to 16-bit, lowers resolution, so keep the original if you may need it later. Conversion also leaves existing background noise or a low recorded input level unchanged. Those need separate editing.

Common problems and next steps

  • Loud static or harsh noise instead of sound: the sample format, signedness or byte order is wrong. Try the other endianness first, then other bit depths such as 24-bit or 32-bit float.
  • Plays too slowly and sounds deep: the sample rate is set too low, or stereo audio was imported as mono.
  • Plays too fast and sounds high-pitched: the sample rate is set too high, or mono audio was imported as stereo.
  • A click or burst of noise at the very start: the file may begin with a header or metadata. Set a start offset in Audacity, or check whether the file is actually a renamed WAV that opens normally.
  • An online PCM audio converter rejects the file: many web tools accept only files with a header. Use a local tool where you can enter the raw parameters.
  • The output device or app plays the file at the wrong speed: its expected sample rate may differ from your file's. Convert to the rate stated in that device's documentation.

If you are looking for a PCM audio encoder, note that PCM itself is uncompressed. Encoding to PCM means decoding compressed audio such as MP3 or AAC into plain samples, as in the converting-into-PCM steps above. A PCM audio format converter that changes sample rate, bit depth or channel count works the same way: set the new values on the output side and keep the input settings that matched the source.