2

Does anyone know if the audacity is capable of generating 8 bit unsigned PCM code comma separated or just 8 bit unsigned PCM code that are represented as bytes/number values? If not, any clues on which program is capable of this? I have designed a board that is capable of playing sound via PCM and thought it would be an easy job to find a converter program from wav to pcm.

Thanks!

2
ffmpeg -i original-file.wav -f u8 -acodec pcm_u8 8bit-file.pcm

See also here.

It's not comma-separated but binary, but that's definitely the more sensible choice – especially for a board with very limited bandwidth.

1

Do this in two steps. First generate the RAW file (in audacity, there is an option to export to headerless RAW audio file under Export -> Export Audio). Make sure you export to 8-bit signed or unsigned values.

Then, using a linux tool called xxd, you convert the binary file into a c header file(I suppose you could do this with any hex viewer but I haven't tried). The header file has comma separated hexadecimal values of all samples of the audio in an array. You can copy from the array, and using a little scripting, convert those hexadecimal values into any representation.

Here is the format that xxd -i input.raw outputs by default:

unsigned char hel_raw[] = {
  0x7e, 0x7e, ......
};
unsigned int hel_raw_len = 2555;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.