[racket] Sounds in Universe?

From: John Clements (clements at brinckerhoff.org)
Date: Wed Oct 19 12:01:40 EDT 2011

On Oct 19, 2011, at 6:30 AM, Shriram Krishnamurthi wrote:

> John, have you run your audio stuff w/ world?  How hard would that be?

Not hard. In particular, I've isolated the low-level ffi connection in the "portaudio" planet package, which includes a "push" and a "pull" interface. Eli suggested to me at some point that it might make sense to bring this piece of the code into the main tree, so that we could claim audio support. 

Version 1.5, that I'm about to release later today, fixes a crashing bug under Windows.

The "push" interface accepts an s16vector of interleaved 16-bit samples, and plays it.

The "pull" interface accepts a buffer-filling procedure that gets called every time a buffer needs to be filled.

Things work pretty transparently on OS X and Windows; Linux audio is always a bit of a pain, and users are responsible for installing a portaudio package that actually supports whatever interfaces they have on their machine. Also, my library picks the "default" audio interface, which may not always be the best choice on Linux.

There's also a higher-level library, "rsound", that also supports reading and writing sounds from .wav files, and a variety of operations on sounds and on functions that generate sounds (a.k.a. "signals").

So, how would this be integrated with universe? The simplest thing would be simply to allow calls to a "play" routine in the "draw-universe" handler (if I'm spelling that correctly). This wouldn't accommodate building e.g. a synthesizer or other program with long-lasting sound, but it would be easy to implement.

Big picture? It might just be a question of trying it out.

I'll give it a try, and report back tomorrow.

John


> 
> On Wed, Oct 19, 2011 at 3:14 PM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>> 
>> No. -- Matthias
>> 
>> 
>> 
>> On Oct 19, 2011, at 7:59 AM, Yaron Minsky wrote:
>> 
>>> Is there any support for playing sounds within the Universe teachpack?
>>> 
>>> y
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://lists.racket-lang.org/listinfo/users
>> 
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>> 
> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20111019/ad6228db/attachment.p7s>

Posted on the users mailing list.