Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: .pcm file to .wav format (Read 12476 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

.pcm file to .wav format

I'm working on converting a .pcm file to a .wav file with GoldWave.  I'm not sure if any other programs out there support headerless raw file types, but anyway I'm not able to hear a clean version of the file.  I tried opening the file as raw, 16-bit sound with a 44.1 kHz sampling rate.  All I hear is a high-pitched squeal, similar to the way rewinding an old video tape sounds, so I'm assuming the sampling rate is too high.

Any tips for playing PCM files?

Here's a screenshot:

.pcm file to .wav format

Reply #1
You probably have either the bit depth, sampling rate, stereo or endianness wrong.  Try a few other combinations until you get one that sounds like audio.

FWIW I've done this lots of times using SoX to put raw PCM back into a .WAV file.

.pcm file to .wav format

Reply #2
Create a frequency spectrogram of your PCM files. If the max. shown frequency is e.g. 11025Hz, load your PCM file with a samplerate of 22050Hz, etc.

.halverhahn

.pcm file to .wav format

Reply #3
Create a frequency spectrogram of your PCM files. If the max. shown frequency is e.g. 11025Hz, load your PCM file with a samplerate of 22050Hz, etc.

In order to create a frequency spectrogram of a headerless file, wouldn't you need to know e.g. the sample rate in order to tell that to the software making the spectrogram? Otherwise it will simply have content up to 1/2 the sample rate that you tell it.

.pcm file to .wav format

Reply #4
I assumed that 44.1kHz is allready a to high samplerate because it play to fast (mickeymouse style). If you load it at 44.1kHz and you look at the spectrogram you will see no frequencies above a certain point - that's the max. bandwith of the original samplingrate.

If you see no signal above 8kHz, the original samplingrate should be 16kHz. Exept the original has been brickwall filtered, but i don't assume this has been done.
To be sure load the rawPCM with the guessed samplerate and listen to it. If the sound is OK -> be happy.

And to be honest: There are just a few standard samplingrates - one will fit: 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 Hz

.halverhahn

.pcm file to .wav format

Reply #5
@halverhahn:  Sorry, but your logic is erroneous.

Like pdq said, loading in a different sampling rate won't magically maintain the frequency band, but change it aswell.  A 440Hz tone sampled at 22Khz is a 880Hz tone if loaded at 44Khz.


@Cincodekyle: Looks like you have the correct endianess, but like Mike said, you should try loading it in mono instead of stereo and/or loading it in 8bits instead of 16bits. If bitdepth is really 16bits, it will sound very distorted in 8bits, so if it sounds okish with 8bits it surely is 8bits.

About stereo or mono, there's no easy way to tell without knowing it, but if it is stereo, it may sound more distorted in mono. (that depends if it is a two channel mono, or stereo with different enough content)

At last, as you should know, reducing the samplerate will help you reduce the speed, but first check if you have the proper bitdepth and channel numbers

.pcm file to .wav format

Reply #6
Thanks for the helpful insight Mike, .halverhahn, pdq and JAZ.  I'm experimenting with some of those ideas right now to see if I can get a clearer view of the audio.  An 8-bit, unsigned, mono signals sounds the cleared right now I just need to find the right frequency to playback with.

.pcm file to .wav format

Reply #7
To put some finality on this thread, I got the file to play perfectly.  As it turns out the parameters for the file in Goldwave were:

File type: Raw (snd, raw)
Signed 16-bit depth
Little endian codec
Stereo reverb

Sampling rate: 4000 Hz

Thank you again for all the helpful tips.

.pcm file to .wav format

Reply #8
4000Hz sounds too low for all known uses. That's a bandwidth of 2Khz. Even voice may sound worse than with a phone.

8000Hz seems more valid.

Try either of these and see which sounds better to you:

mono, 8bit, 16Khz
mono, 16bit, 8Khz
stereo, 8bit, 8Khz
plus your current one.

.pcm file to .wav format

Reply #9
[JAZ], you yourself pointed out that would only double the audio's speed. The OP says it now sounds perfect, so why would they wish to do that? Unless using mono or 8-bit (but not both) will maintain the speed, but I'd think (admittedly I'm not great at conceptualising) that'd result in noise.

.pcm file to .wav format

Reply #10
I thought the best way to explain it would be with an example:

I've posted in this thread four samples which demonstrate what i mean.
http://www.hydrogenaudio.org/forums/index....showtopic=79384

I started with an original which is 8bit, mono, 16Khz. (What i believe the OP's file is).

I've imported the file with the three alternative settings that we've talked in this thread (the one the OP has found to fit his options, and two more of mine).

All four files seem to play well (at least at the appropiate speed). But it is obvious that the lower the sampling rate, the worse it sounds.


Edit: Now that i have corrected the 8bit file, there is one suggestion about the file being 16bits and not 8 bits. In DOS/Windows at least, 8bit samples were unsigned (i.e. from 0 to 255), while 16bit samples are signed (from -32768 to 32767).

Since the op says that the file he has is signed (as i have assumed in my example), chances are the file is 16bits. So, in conclusion, my second option.

.pcm file to .wav format

Reply #11

I started with an original which is 8bit, mono, 16Khz. (What i believe the OP's file is).

I've imported the file with the three alternative settings that we've talked in this thread (the one the OP has found to fit his options, and two more of mine).

All four files seem to play well (at least at the appropiate speed). But it is obvious that the lower the sampling rate, the worse it sounds.


If you changed the sampling rate and the speed of the file didn't change you probably did something wrong.  Perhaps you accidentally resampled?

.pcm file to .wav format

Reply #12
I added the .wav files in the upload forums to clear any confusion. No, i did not resample. The size of each file should be enough to understand that the only difference is the header ( except for the 8bit unsigned file, in which case the bytes are changed from signed to unsigned).