[chuck] New guy, and questions

Ge Wang gewang at CS.Princeton.EDU
Tue Mar 22 14:28:24 EST 2005


Hi Paul!

Welcome!

>   Firstly I have to say wow, this looks great, loads of really neat 
> features,
> well done!

Thanks!   ChucK is very young  and needs a lot of work.   Some of that 
is
coming in the new release next week.

>   I've had a quick play and its pretty easy to pick up, but I have a 
> question.
> One thign I want to do is to play with 'VOSIM', basically you have a 
> train of
> pulses (bell curves) that make up a cycle of audio. You vary the 
> number of,
> amplitude and width of each curve to change the 'tone'.
>
>   Now I can see I can use a sine oscillator, square it and this will 
> give me the
> bell curve, only problem here is that I get two 'bell curves' for the 
> price of
> one cycle, which brings me neatly onto my next problem..
> What I need to do is to change the amplitude and/or pitch of each 
> 'pulse' at the
> zero crossing, great I can use Zerox, but, how do I then change the 
> value?

zerox might not help you in this case, since the signal doesn't actually
cross zero.

there are several ways around this:

1) go at close to sample rate (3::samp => now), and keep track of the 
last few
samples (use .last to get the last sample computed), and test for the 
inflection
when the signal "dips".

I put a quick and dirty version on the wiki:

     http://wiki.cs.princeton.edu/index.php/ChucK_Program_Bad_VOSIM

2) or: given the pulse width, keep this value and advance time by the 
same
number of samp.  (pw::samp => now), and that should put you at the right
place both in time and the signal.  You can move in this way to the end 
of
each pulse, and modify the gain or width at this point, or set things 
to be
silent and wait until the next series of pulse.  This is probably the 
most
robust way.

3) or: do everything by hand, and calculate the signal without sinosc.

// patch
impulse i => dac;

// time loop
while( true )
{
      // compute val and set the next sample (code omitted)
      val => i.next;
      // move to next sample in time
      1::samp => now;
}

4) surely, other ways exist.

---
how to vary the amplitude - depends on how you set up the patch.

example:

// first osc to gain
sinosc s1 => gain g => dac;
// second osc
sinosc s2 => g;
// set multiply at g
3 => g.op;

at any point, you can set g.gain to change the amplitude.  you can
also change s1.sfreq or s2.sfreq to change the frequency, and s1.phase
and s2.phase to set the phase.

> Is there a sequencer module planned?

Not natively.  The idea is that it should be straightforward to 
implement
sequencers in ChucK, tailored to the needs of the programmer.  With the
new release, this should be doable.

Hope this helps.

Also, related to VOSIM: FOF's - we hope to put up some examples soon.

Best,
Ge!



More information about the chuck mailing list