[plt-scheme] audio processing and music generation

From: Stephen Tetley (rt014i7347 at blueyonder.co.uk)
Date: Thu Nov 27 15:33:08 EST 2003

Hello

I've a MIDI file IO library at:
http://slackwise.org/spt/scheme.html

Its fairly well tested and I used an earlier version for my 
undergraduate thesis so its seen some use. Unfortunately I don't think 
its a very good design - it reads the whole MIDI file into memory and 
represents it as a tree of objects. This is the design that MIDI libs 
for 'scripting' languages seem to use, but it feels a bit deficient.

As MIDI files are generally small it preforms well enough but it would 
be a bad strategy to use for other binary file types where the files are 
larger. It also fixes MIDI files in one representation (an OO syntax 
tree), that's unwieldy if you don't want to program in the OO style. You 
also loose random access to the binary file. If anyone knows any good 
examples of binary parsing a more functional style I'd be interested to 
hear about them with a look towards rewriting the library (I know Erlang 
has the 'bit syntax').




An interesting strategy for making audio with Scheme or a similar 
language where you might not want to go down to the level of digital 
signal processing is to generate code for one of the unit generator 
music programming languages such as Csound or RT-Cmix.

Unit generators are DSP 'components' - you make audio by writing an 
instrument file specifying how the unit generators are linked together 
and a score file which list the notes to be played on the instrument.

I built a number of prototypes that generated RT-cmix for my degree 
project and found it a very pleasant way of working. As a 'music 
programming language' RT-cmix is quite complicated (instruments are 
written in C++ and scores are written in MINC a subset of C), and for 
the last prototype I generated the instrument from a single macro 
'specification'. I worked out the details of generating them in a more 
modular way using the Kamin[] style of combinator library but didn't get 
round to implementing this.

Csound represents scores and instruments in a much simpler form so it 
would be quite easy to make a combinator library embedding Csound in Scheme.


['Kamin-style' combinators generate code in a different language to the 
one they are written in, for example in: 
http://www-sal.cs.uiuc.edu/~kamin/pubs/ml-meta-extabs.ps
the parser combinators written in SML generate C++ parsers].





Regards

Stephen



Posted on the users mailing list.