Data Acquisition (DAQ) and Control from Microstar Laboratories

Knowledge Base: Processing

  • See the list of other topics for category Processing

Q10071 Playing back WAV audio data files

Tags: Help, DAP, DAPL, processing, output, waveforms, WAV file, audio

Applies to: All DAPL versions and DAP models

I have waveform generator software that writes multi-channel audio data in a "Microsoft WAV" format. I want to have the DAP play the data back as test signals. Can the DAPL system read "WAV" files?

The DAPL system does not understand the WAV file format, so it can't use the files directly. There are many WAV file variations, some that allow very elaborate encoding options. As a practical matter, however, most data sets use a simple 16-bit PCM (Pulse Coded Modulation) format (basically, that means there is no compression), 16-bit signed fixed point sample values, channel data in multiplexed sequence, and the entire dataset is contained within one sub-chunk. That means the data blocks are typically a perfect match for DAPL playback.

The drawback, however, is that the DAPL system expects only the signal binary data, and does not understand or expect the block of header information at the start of the WAV file.

There are two approaches to avoiding this header data. In a canonical PCM WAV file, there are 44 bytes of header information. Since you probably know everything about the data file anyway, you can strip out this information. Your software may include more information in the header, and if so, just discard more bytes.

  • You can use the Matlab or Octave software systems to read in a WAV file using the wavread function, then write out a new binary-only file using the fwrite function. The only thing to be careful about, the Octave / Matlab environments interpret the data values bounded by the range -1.0 and 1.0, representing this as a floating point matrix. When you write the file out, the data should be in the fixed point range bounded by -32768 to +32768. So multiply your data matrix by 32768.0, then write out the data matrix as int16 data.

  • You can pass the entire WAV file to the DAPL system, and use DAPL processing to strip out the header each time. Determine how many bytes of header information are present, and then convert this to the number of 16-bit words. (For the canonical header length 44 bytes, this would be 22 words.) Then use a SKIP processing command to discard the header data and retain everything else.

        SKIP($BinIn,  22,1024,0,  pBinData)
    

    You can route the multiplexed binary data stream to the appropriate subsequent processing. For example, to deliver two channels of audio directly for clocked output, you could substitute the following.

        SKIP($BinIn,   22,1024,0,   Opipe(0,1))
    
  • Skilled DAPL users can easily write custom processing in C++, to build a WAV file aware processing command able to identify WAV file variants, validate channel count, etc.

L13656

A detailed description of the WAV file format:

http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html