I am attempting the exact same exercise. I record sound with a board that I built that uses a micro controller, an audio ADC, and flash memory. This data is a stream of PCM 16bit signed, 44.1kHz samples, but could be any variation of standard resolution or sample rate values. (LPCM or Linear PCM only means not compressed in the context that I am familiar with.) Uploading the flash data to the PC could assume formatting the data as 16bit ASCII (text), or hex in two 8bit bytes. I would like to play this “raw” data directly with Audacity. Creating a .wav file is a royal pain and I hope unnecessary. The metadata header format is ugly. See https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
I thought in order to see what an Audacity “raw” input file should look like I would record a snippet of music with Audacity and export it as raw. The closest format I could see in the export pulldown is “AIFF (Apple) signed 16 bit PCM”. The output file is test_audio.aiff which is attached. This file can only be view by a hex editor. I use the tool HexEdit for Mac. This aiff file has lots of header metadata, similar to a .wav file. Not what I want to have to generate, and not what is required for Audacity’s Import RAW data. Raw data should just unformmated PCM.
My next experiment was to export the audio snippit as a .wav file and converter it to “C code” or in the form my circuit would create. This was done with cjseymour’s wav2c.exe on a Windows PC. The result is the attached test_audio.txt which is viewable with a text editor. This ASCII file can can be read by Audacity but provides no sound.
I need explicit byte by byte description of data format for the simplest Audacity importable RAW file.
Probably the simplest format is “8 bit signed integer PCM raw”, which is simple a series of 8bit values representing the audio samples. For example, here is an 8 bit signed PCM raw file of a sine wave. If you look at the file in a hex editor you will see a series of 1 byte (8 bit) numbers starting from 00 Hex and rising to 7F Hex (127 decimal), then falling to 80 Hex (-128 decimal) and so on.
The file can also be imported into Audacity using “File > Import > Raw Data” and selecting “Signed 8 bit PCM” as the encoding.
Hi Gale, I think my challenge was the same as the original author, ‘birds count’; I want to create audio stream files with an Analog to Digital Converter and then listen to the binary audio with Audacity.
Steve, you provided the answer. The sinewave file you gave me appeared to have no header information. It would not be usable as WAV file (lacks the WAV metadata header), but is fine for import as RAW. If fact I cut out the top 20 lines or so in a hex editor and it still plays after imported as raw. The file has a .wav extension, but for RAW, the extension can be anything. I changed filename to sinewave.xyz and it still imports and plays the tone. I also exported my short Audacity created audio recording as a WAV file and stripped off the top of the file and it imports and plays as a RAW file.
So now, it seems that I only need to convert my ADC binary data to hex format before uploading to Audacity.
Because I named it incorrectly. The first version that I made was indeed “unsigned integer” but then I changed it to “signed integer” but forgot to change the name. (Romeo and Juliet. Act II. Scene II)
The .WAV extension is just for convenience - the forum does not allow .raw files to be uploaded, but as bamboola correctly deduced, the file extension is irrelevant for RAW data because there is no header, hence no real “file format”, it is just binary data. 8 bit formats are more “simple” than higher bit formats because they avoid issues with endianness.