Issue in Playback of recording .

Hello,

I am using SPH0645LM4H microphone.I have interfaced this with MKRZERO arduino board.I am getting waveform on serial plotter. I have stored these samples in one file using UART. after that I imported sample file in Audacity as raw data but not getting proper recording.

I have make sample file in ASCII in which I am storing samples of audio.
I am attaching here sample file , .ino file and Mic datasheet.

It'd be grateful if you suggest any workaround for the same.

Thanks in Advance.

Regards,
Bhavna

InputSerialPlotter.ino (2.64 KB)

SPH0645LM4H-BRevB (1).PDF (1.06 MB)

teraterm6.txt (140 KB)

Your txt file is not a text file. It appears to be 16 bit samples (perhaps biased to 0x4000 rather than zero? Looks pretty strange actually)

There is no standard for text/ASCII audio files, but text file should be mostly [u]ASCII[/u] numbers, plus carriage returns, line-feeds, and spaces, and maybe commas and maybe a text header... It should be readable text. When I open your "text" file in Notepad it just looks like garbage. (Most computer files look like garbage because most computer files are not text.)

If you are making a text file you should add spaces or CR/LF or something to separate the samples, otherwise you're going to get a long string of numbers and you won't know where one sample ends and the next one begins..

There is also no standard for "raw hex" or "raw binary" files.* If you want to read the file, you have to know the bit-depth (to the number of bytes per sample), you have to know the number of channels, little or big endin, signed/unsigned, and assuming you want to play the file you also need to know the sample rate.

Your file doesn't look like a raw file either because I see a lot of repeated values. A raw audio file usually "looks random" unless you graph it out to see the waveform.

Here is bit of a text file created in Audacity (Analyze -> Sample data export). It looks like this when opened in Notepad. Audacity saves the floating-point sample values, where zero is silence (-infinity dB) and a value of 1.0 represents 0dB.

sample-data14.txt 2 channels (stereo)
Left channel then Right channel on same line.
Sample Rate: 44100 Hz. Sample values on linear scale.
Length processed: 100 samples 0.00227 seconds.

-0.06955 -0.06955
-0.08518 -0.08518
-0.10508 -0.10508
-0.11246 -0.11246
-0.17057 -0.17057
-0.15949 -0.15949
0.00491 0.00491
0.13977 0.13977
0.05881 0.05881
-0.17911 -0.17911
-0.23682 -0.23682
-0.06989 -0.06989
-0.07303 -0.07303
-0.26087 -0.26087

Here is a text file created in GoldWave. This time it's the 24-bit integer values (saved-as ASCII).

[ASCII 44100Hz, Channels: 2, Samples: 131433, Flags: 3]
-1781558
-643347
-1872953
-516367
-1913146
-450829
-1901370
-580881
-1856824
-790552
-1755445
-898587
-1721652
-894747
-1681459
-951069
-1658674
-1010462
-1747765
-861466
-1774646
-621587
-1793846

  • The terms "hex" or "binary" can be confusing because all computer files are binary numbers stored as bytes. It's only the context that tells you if the numbers represent binary number values, or ASCII characters, or part of a pixel, computer-code instructions, etc.