WAV Analog Stimulus/Logger

The following pair of components provide analog stimulus and logging using WAV audio files. Because these rely on the libsndfile library, the stimulus component can read any WAV file supported by that library. The logging component writes uncompressed PCM WAV files with either 8, 16, 24, or 32 bit width. The "README.txt" file in "wavlogstim.zip" explains where to install the libsndfile DLL file.

Note that libsndfile is licensed under the GNU LGPL, while my components are released into the public domain.

Downloads

  • wavlog-1.0.zip - Contains the pre-compiled "wavlog.dll" and "wavstim.dll" components, as well as the "libsndfile-1.dll" library.
  • wavlog-1.0-src.zip - Contains source code to the stimulus/logger components, compiling instructions, and the header and import library for libsndfile.

Usage

; To use either component, use one of the following definitions:
;
; X<Name> _wavlog(<SampleRate> <BitWidth>) <Data>
; X<Name> _wavstim <Data>
;
; The <Name> is used to form part of the input or output filename in the format
; "<Name>.wav". For the wavlog component, the <SampleRate> is specified in Hz
; (e.g. "48K") and has no upper limit, although not all audio programs may open
; WAV files with non standard rates. The <BitWidth> must be 8, 16, 24, or 32.
; Files created by the wavlog component will always be single channel. For the
; wavstim component, the sample rate of the input file determines the rate at
; which the analog output pin <Data> gets updated. If the wavstim input file
; contains multiple channels, only the first (left) channel will be used.
; Voltage levels of VSS, VDD, and (VDD-VSS)/2 on the <Data> pin correspond to
; the maximum negative, maximum positive, and zero sample values within the WAV
; file.

Example

Xinput _wavstim pc0
Xoutput _wavlog(96K 16) signal

Screenshot

The VMLAB Scope window in the screenshot below shows the analog output of the wavstim component when producing a 10Khz sine wave sampled at 96Khz: