[plt-scheme] support for sound or interfaces to sound software

From: Lee Spector (lspector at hampshire.edu)
Date: Thu Apr 20 11:23:37 EDT 2006

Thanks John, but unless I'm missing something the built-in play-sound  
just plays sound files as-is, without any control over pitch or  
duration. While this can be handy (and maybe my original post wasn't  
clear about my needs) it doesn't get one very far towards music  
generation. For tonal music one would have to pre-generate sound  
files for all needed pitches and durations, which would be awkward. A  
play-sound command with pitch and duration parameters (like in the  
old Apple HyperCard application) would provide what I need, as would  
a MIDI-generation library (which would allow one to use a software  
MIDI synthesizer for the actual sound generation). Less attractive,  
but still useful, would be a sine-wave tone generator with frequency  
and duration parameters.

To give a little context: for a variety of reasons I teach intro  
compsci using arts-oriented programming exercises and projects, in  
which students write programs that produce things like poems,  
melodies, and images. One of the reasons I'm considering DrScheme is  
its apparently clean support for image-related programming (though I  
haven't yet experimented with this). But melody programming is  
usually central to my presentation, in part because there are simple  
algorithms for generating interesting melodies (e.g. combining  
templates or grammars with random choices). The long history of  
algorithmic music composition is full of ideas that even beginning  
programmers can implement (given the right tools) and I have my  
students read work by David Cope and others who do this kind of thing  
in a more sophisticated way.

When I've taught with Common Lisp I've used libraries that connected  
Macintosh Common Lisp to MIDI and Quicktime Musical Instruments. This  
gives one a lot of flexibility and control, piggybacking on other  
well-developed software. When I taught with C it was back in the  
HyperCard days, and I had students generate melody text strings that  
they could play by pasting them into HyperCard. This was also nice  
although it didn't support polyphony. At various times I've also done  
more complicated things using textual intermediaries and the Max  
program for MIDI/sound synthesis -- but that's usually more  
complicated than I want to make things for my beginning students.

Anyway, sorry to be so longwinded, but if anyone has ideas for  
generating sound with pitch and duration specifications from DrScheme  
I'd love to hear them.

Thanks,

  -Lee


PS I had a hard time finding out about the details of play-sound  
because that documentation isn't in the default installation, and  
when I try to install it from the DrScheme "Documentation missing"  
help desk screen it downloads something but then gives me a  
permissions error:

open-output-file: cannot open output file: "/Applications/PLT Scheme  
v301/collects/doc/mred/mred-Z-H-304.html" (Permission denied; errno=13)

Anyone know how to get around this?




On Apr 19, 2006, at 2:33 PM, John Clements wrote:
> To add just a bit to this: DrScheme does support a play-sound (sp?)  
> call, which essentially calls the appropriate player for the  
> platform.  Under OS X (the platform the original poster described),  
> play-sound works just fine on a variety of different sound files.
>
> Also, in order to read and write sound files, DrScheme's foreign  
> function library can interact with sound-reading & -writing  
> libraries (e.g. the libsndfile library).  In fact, I believe this  
> is one of the 'examples' that comes with the ffi package.
>
> In other words, the support for this (reading/writing sound files,  
> playing sound files) is all already built in to drscheme.
>
> John Clements
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

--
Lee Spector, Professor of Computer Science
School of Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspector at hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438



Posted on the users mailing list.