07 December 2009

ChucK: Danger to your ears when working with filters

Currently ChucK seems to have a filter instability problem in certain situations. This post is a duplicate of the warning I posted to the ChucK list (I'll update it once the problem is fixed).

Here's some code from ChucK user Kijjaz that demonstrates the problem:

PulseOsc osc => BPF filter => blackhole;
20000 => filter.freq;
0.5 => filter.Q;
for(int i; i < 100; i++)
{
   <<< "osc: ", osc.last(), " filter: ", filter.last() >>>;
   samp => now;
}

The value output by the filter keeps rising.

I ran into this problem while I had a similar patch connected to dac (digital analogue converter, the ChucK element that translates things into sound, that gets sent to the speakers) instead of to a blackhole (another ChucK element, that doesn't result in sound over the speakers).

Don't run the following code!

// CAUTION! causes filter blow-up on macbook!

PulseOsc osc => ADSR env => BPF filter => dac;
20000=>filter.freq;
0.5=>filter.Q;
while(true){
 1::second=>now;
 env.keyOn();
 20::ms=>now;
 env.keyOff();
}

I was wearing headphones, but I took the usual precaution of turning my macbook volume to the lowest level above 0 before running the patch. To my alarm, the resulting screaming sound came through my headphones at top volume anyway. It turns out that when set to any of the volume gradations above 0, the screaming happens at effectively full volume on my macbook.

So the point of this post is to emphasise that (at least for mac users) there's a 'screaming filter' issue with ChucK that's currently quite dangerous for hearing/speakers, even if you take (imo) normal sensible precautions before running a patch.

This is a bit of a blocker for the joystick sequencer I'm working on at the moment, but apart from this I've been enjoying working with ChucK. Partly inspired by the Ardour book sprint, there's a ChucK documentation sprint planned for later this month, which should mean that it'll be (even) easier for new users to gets started soon.

Related Posts :



3 comments:

rcaceres said...
This comment has been removed by a blog administrator.
rcaceres said...

Interesting. Thanks for the tip.

What are these sprints you mentioned? Are there more of them, and is there a site for them?

(re-posted so that I can receive email followups)

Admin said...

Hi rcaceres. Documentation sprints are very similar to booksprints, you can find more information here for instance: http://www.booksprint.info/