[chuck-users] Audio Range and Zero-crossings, Hashes and OpenGl

Veli-Pekka Tätilä vtatila at mail.student.oulu.fi
Sun Mar 4 14:44:27 EST 2007

Spencer Salazar wrote:
> On Mar 4, 2007, at 8:30 AM, Veli-Pekka Tätilä wrote:
>> 1. What's the range of the audio float datatype and what would be
>> the best
>> way to detect zero crossings?
>> [...]
>> I'm assuming here that samples are floats or doubles from -1 to 1 as
>> in VST, <snip>
> Yes.  Although, the -1 to 1 part isn't enforced within a UGen graph,
Ah I see, so the rest of the value range is available when needed. But I 
imagine that if larger values end up in the DAC they will be hard clipped or 

>> 3. Is there any way to decrease the latency on WIndows platforms
>> for tru realtime MIDI playback and audio processing similar to Reaktor?
> You could try decreasing the audio buffer size through the --
> bufsize### command line option (see http://chuck.cs.princeton.edu/doc/
> program/vm.html for more information).
Will do that. HOwever I just read that ChucK is based on SDL and DirectSound 
meaning a 20 ms latency is quite an achievement in many cards. It would be 
great if the WIndows port of SDL had native ASIo support some day. That 
would get rid of the latency issues with SDL apps in general.

>> 4. How does one use the ZeroX module for detecting zero crossings?
>> Quote:
>> Emits a single pulse at the the zero crossing in the direction of
>> the zero
>> crossing
> Yes--this just means that for a zero crossing from > 1 to < 1 in its
> input, it outputs a -1 for that particular sample, and for < 1 to >
> 1, it outputs a 1.
But what does it output when no zero-crossing is detected at the now time, 
which is more than likely? I suppose that would be 0 and could test, of 
course, but i'll be lazy and ask here.

>> 6. How do you use the array datatype in ChucK as a hash?
>> you can index the array with strings much like a Perl hash, except that
>> numbres and strings are totally separate. If I get handed a hashtable 
>> whose
>> keys I don't know beforehand, is there a keys or each function for 
>> iterating
>> through the hash's keyset?
> The hash table form of arrays is somewhat limited in available
> operations at this time--its only possible to do assignment and
> lookup, with keys that are known in advance.  Clearly we'd like to
> have some more advanced functionality built into hash tables in the
> near future.
Ah I see, in addition to keys and values the ability to reverse the keys and 
values of a hash is sometimes very useful, though it only properly works if 
the values of the hash also happen to be unique. Still the current 
implementation can be used for light-weight struct:ish datatypes I'd imagine 
similarly to how one would use hashes in Perl in constructing classes.

I also read that the OOP stuff is a bit on the way. The lack of public and 
protected data doesn't bother me much but having constructor support would 
rock. As well as the ability to declare abstract or interface classes 
similar to interfaces in Java or pure virtual classes in C++.

Which reminds me of yet another query, I read somewhere that as ChucK also 
supports multimedia, it would have OpenGl graphics support, too. Can I 
access it in chucK itself and if so, where's the reference? The manual 
doesn't say anything about openGl.

With kind regards Veli-Pekka Tätilä (vtatila at mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:

More information about the chuck-users mailing list