[racket] Trouble with RSound

From: John Clements (clements at brinckerhoff.org)
Date: Mon May 13 18:42:33 EDT 2013

On May 13, 2013, at 2:53 PM, Gabriel Peredo wrote:

> On Mon, 2013-05-13 at 14:06 -0700, John Clements wrote:
>> On May 12, 2013, at 12:26 PM, Gabriel Peredo wrote:
>>> Hello,
>>> I'm trying to use RSound, but I ran into a problem. Thing is, if I try
>>> to play more than one sound, in any manner, during a single racket
>>> session, I get a "pa-open-stream: Device unavailable" error. This here
>>> is enough to trigger the problem on my machine:
>>> #lang racket
>>> (require (planet clements/rsound))
>>> (play ding)
>>> (play ding)
>>> For what it's worth, here is some info about my system:
>>> Fedora 17, x86_64
>>> Racket 5.3
>>> portaudio v19 (from Fedora's repo)
>>> RSound v4.4
>> Thanks for the report.
>> I know it sounds like you've given me all of the configuration information you possibly could, but… what does your audio subsystem look like? Are you using ALSA?
>> John
> Yeah, forgot about that. I'm currently using PulseAudio 1.1 on its stock
> configuration, over ALSA. After trying a bit by loading the jackd module directly... and installing jack (, I reverted to the defaults.
> If it's of help, I have put the what's printed to the CLI racket REPL here: http://pastebin.com/Y6N3xgM6, the sound played once on that run as well.

Yes, that's definitely helpful. 

One problem with a cross-platform library like PortAudio is that its interface makes promises that are essentially the intersection of the promises made by the interfaces on all of the supported platforms. In particular, OS X supports a huge number of simultaneous streams, whereas Windows seems to support somewhere between one and 100 simultaneous streams. Linux… well, it's hard to predict.

Here are a number of things to try:

1) You say that you reverted to the defaults--did this involve removing jack completely? I see a reference to jack in your paste.  To be clear: I have nothing against jack, but it's one extra thing to go wrong. Also, it seems that on Linux, it's not uncommon to get, e.g., portaudio running on top of jack running on top of portaudio running on top of ALSA… things can get nasty. Removing it is one thing to try.

2) Take a quick look at the the play/s function.  It works by piping all sounds to a single mix channel. It should be possible to use this to circumvent your problem. One issue here is that since the mixing is done in the i32 world, it's pretty easy to overflow and clip.

3) the portaudio package contains a direct test of multiple open streams. I'm assuming this will fail on your platform, but it's worth testing, just to see if I've missed something. It should be possible to run the test by evaluating this program:

#lang racket

(require (planet clements/portaudio/test/test-portaudio.rkt))

It looks to me like you'll get all kinds of failure in these tests, but it would be useful to know what happens. Also, since a number of these tests involve actually listening to the speakers, it might be worthwhile to read the test-portaudio.rkt file before running it, to see what it is you're supposed to be hearing…


John Clements

Posted on the users mailing list.