lab 3 - wavefs


lab 3 - create a filesystem, wavefs, that serves a looped waveform. This is our staring point for playing with DSP.


Inferno 4th edition release 20040830. Using styxservers(2), audio(3), audio(6). and Synthesis Toolkit in C++ stk. Emu is running hosted on Windows XP. (I haven't gotten the sound figured out yet using esd.)


I've been looking for tools to experiment with DSP. The synthesis toolkit has a good all round collection of DSP routines and the code is easy enough to read. I wanted this "sound workbench" well integrated with inferno. Where possible make the resources files or file2chans.

The first step was to make a sound source; an oscillator. For this I created a file server that serves two files


I started with the sample code from styxservers-nametree(2). The server is given a raw audio file to loop. I took the example raw files included in the STK distribution. These are 16bit mono, big-endian two's complement.

The data file served is an unlimited stream of data in 16bit mono, little-endian, two's complement suitable for streaming to /dev/audio

% mkdir /mnt/dsp
% mount {wavefs sinewave.raw} /mnt/dsp
% echo rate 22050 > /dev/audioctl
% echo chans 1 > /dev/audioctl
% read 40000 < /mnt/dsp/wave > /dev/audio

Reading the ctl file describes attributes of the sound file, similar to /dev/audioctl Change attributes, such as pitch, by writing to ctl. For example to create a sinewave rising in pitch

{for (i in `{seq 300 10 700}) {
 echo pitch $i > /n/dsp/wavectl; 
 read 4000 < /n/dsp/wave }
}> /dev/audio

seq is a port of the plan9 command.

I made some helper programs to look at the wave form.

% read < 100 /mnt/dsp/wave |pcm |gr

The ffts doesn't seem to work, or I misunderstand how to use it.


These are the final versions: pcm.b gr.b wavefs.b ffts.b seq.b And here is the sinewave from the STK package. sinwave.raw Given the above I have a model to build a family of fileservers. Each serves a ctl and data file. Reading from data always reads the sound samples in a format suitable for /dev/audio and writing to ctl controls the effect, filter, or oscillator.

The filesystems can be layered. So a filter is started by giving it as parameter the wave file

% mount {wavefs sinewave.raw} /mnt/dsp
% mount {lowpfs /mnt/dsp/wave} /mnt/dsp

And so on. It'll be interesting to see how layering filesystems on a larger scale works out. A patch bay of filesystems may be required.

This is also an excuse to learn about DSP.


Popular posts from this blog

lab 110 - inferno archive edition

lab 107 - midiplay

The Cartesian Theater of AI