|Source code (in)||wav.c|
|Source code (out)||wav.c|
wav is a binary file format generally used for storing audio data.
- The maximum file size is limited to 4GB (uint32_t used for the file size header field). However, many applications routinely ignore this field, and just load however many samples are in the file.
- While sigrok stores the analog values in a WAV file as they are, many audio applications that process WAV files cannot deal with sample values outside the range -1 to +1. Thus when generating a WAV file with sigrok with a view to using an audio application on that file, it is recommended to scale down the values to within the audio range.
Both input and output of WAV files is supported in sigrok. The input module can take sample values in PCM (8, 16 and 32 bits) and 32-bit IEEE754 BINARY32 floating point. Output to WAV files is always in 32-bit IEEE754 BINARY32 floating point.
WAV files are always assumed to be little-endian, and conversion to/from the files is done on that assumption.
The output module has an option
scale. When specified, this divides the sample values by the given factor. This can be used when the resulting WAV file is intended for processing by an audio tool, which generally expects samples to be in the range -1 to +1.
The WAV format has the length of the file and of the 'data' chunk embedded in it, before the actual data. This clashes with sigrok's streaming nature; an output module cannot necessarily know how many samples are to follow. Therefore the module stores the maximum value in each of those fields. Audio tools reading those files seem to have no problem with that so far.