[chuck-users] Audio Range and Zero-crossings, Performance, Hashes and Future DIrections

Spencer Salazar ssalazar at CS.Princeton.EDU
Sun Mar 4 14:16:45 EST 2007

Hi Veli-Pekka,
Welcome to ChucK!

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, as I didn't find the range in the manual. Is this correct?

Yes.  Although, the -1 to 1 part isn't enforced within a UGen graph,  
so a system that is dealing with completely arbitrary input probably  
shouldn't have that expectation.

> 3. Is there any way to decrease the latency on WIndows platforms  
> for true
> realtime MIDI playback and audio processing similar to Reaktor?  
> DirectSound
> latency is pretty bad as my audio machine, which isn't this laptop,  
> would
> have both WDM kernel streaming and ASIO support in it.

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).  However, please note that  
smaller buffer sizes may cause audio to break up, depending on your  
soundcard, audio driver, and OS.

> 4. How does one use the ZeroX module for detecting zero crossings?  
> What's
> the value range and what is the output method of that module called  
> i.e.
> which thing should I poll to detect the crossings?
> The manual says:
> 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.

> 6. How do you use the array datatype in ChucK as a hash? I read  
> that 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? Is the hash portion of the array unordered as one might
> expect in an implementation e.g. an array of pointers to linked-lists?

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.


More information about the chuck-users mailing list