examples/csv2wav/README.md
This project is a utility for converting audio data recorded via Serial Studio's Audio I/O driver into playable WAV files. It's for developers testing Serial Studio's data pipeline integrity using audio signals like voice, tones, or music. If the reconstructed .wav file sounds like the original, the I/O pipeline works.
No extra hardware needed. Just Serial Studio, a microphone or audio source, and this Python script.
Serial Studio's audio features may need a paid license. See serial-studio.com for details.
Serial Studio logs audio samples to CSV like this:
Elapsed (s),Audio Input/Channel 1,Audio Input/Channel 2,...
0.000000,0.000000,0.002541,...
Elapsed (s) relative timestamp, used to auto-detect the sample rate.Channel <n> counts..wav file.Elapsed (s) column (fallback 44,100 Hz).--rate).--in_format: float32, int16, int24, int32, uint8).--dither)..csv file.python3 csv2wav.py path/to/audio.csv
You can optionally specify an output path, sample rate, and format:
python3 csv2wav.py path/to/audio.csv output.wav --rate 48000 --in_format int16
| Format | Bit depth | Range |
|---|---|---|
| float32 | 32-bit | -1.0 to 1.0 |
| int16 | 16-bit | -32768 to 32767 |
| int24 | 24-bit | -8388608 to 8388607 |
| int32 | 32-bit | -2147483648 to 2147483647 |
| uint8 | 8-bit | 0 to 255 (biased unsigned) |
Default is float32. The format describes the values stored in the CSV; the output WAV is always 16-bit PCM.
As a developer or tester:
csv2wav.py to convert it back into a WAV.If it sounds correct, the pipeline works. If it's clipped, noisy, or silent, check device config, sample rate, or formatting.
csv2wav.py: the core CSV to WAV conversion script.README.md: project documentation and usage guide.numpy (install via pip).pip install numpy
python3 csv2wav.py input.csv [output.wav] [--rate <hz>] [--in_format <type>] [--dither]
input.csv: CSV file exported from Serial Studio.output.wav: optional name for the output WAV file.--rate: optional sample rate in Hz; when omitted it is derived from the Elapsed (s) column, falling back to 44100.--in_format: input format (float32, int16, int24, int32, uint8).--dither: apply TPDF dither before int16 quantization.[!TIP] For advanced resampling, route audio through a virtual loopback device and set the target frequency with Serial Studio. Then run
csv2wav.pyto export at the new frequency. This produces clean downsampling results suitable for slowed and reverb style mixes.