No simple vibrato example

Hi guys, I'm giving a presentation on ChucK tomorrow and I wanted to show off some of the basic features in a live coding session. I found that creating a vibrato (modulating the frequency) is far too hard. The example I'm looking at is http://chuck.cs.princeton.edu/doc/examples/basic/whirl.ck. In an infinite loop, you have this code: 30 + ( Math.sin(t) + 1.0 ) * 10000.0 => s.sfreq; t + .004 => t; Here, t is a float and s is a SinOsc. Now, what I would have expected is the following, more intuitive setup outside the loop: 30 + SinOsc freq_mod => s.freq; 1 => freq_mod.freq; I know that the first line with the "30 + SinOsc" is probably nonsense in itself, but I could work around that (by using a step UGen for example). My actual problem is that you can't chuck a SinOsc into s.freq. Consider this line: SinOsc freq_mod => s.freq; I get an error like this: arguments type(s) do not match: ... for function 'SinOsc.freq(...)' ... ...(please check the argument types) Is this something that the language is simply not capable of or am I doing something wrong? Best, Manuel

You can always try to modulate the Oscilator:
SinOsc vibrato => SinOsc sine => dac;
// This will tell sine to take the vibrato input as a modulator of
// it's frequency.
2 => sine.sync;
5 => vibrato.freq;
10 => vibrato.gain;
5::second => now;
2013/12/4 Manuel Bärenz
-- -Moisés

Check out the UGen doc:
http://chuck.cs.princeton.edu/doc/program/ugen_full.html#sinosc
The three valid input values for .sync are described there.
On Thu, Dec 5, 2013 at 11:54 AM, Manuel Bärenz
-- Release me, insect, or I will destroy the Cosmos!

You can combine ugen outputs in multiple complex ways. For example here is
how to multiply the output of two SinOsc's. I'm typing away from my chuck
station so please forgive typos.
Gain mult => dac; // The 'mult' ugen will be used as a multiplier.
// The ugen op() method tells the ugen how to combine inputs. 3 means
multiply.
// By default ugens add inputs.
mult.op(3);
// Chuck both SinOscs to mult.
SinOsc osc1 => mult;
SinOsc osc2 => mult;
Now the output of the mult will be the product of the two SinOsc ugens
which should allow a basic vibrato.
-steve aka zencuke
On Thu, Dec 5, 2013 at 5:54 AM, Manuel Bärenz

Hm yeah I think you have to do the gain manually. I like to use another
oscillator for modulation like this (dry-coded and untested):
fun void am(SinOsc @osc, SinOsc@ modulator, float modulation) {
while (true) {
modulator.last*modulation => osc.gain;
1::samp => now;
}
}
SinOsc osc1 => blackhole;
SinOsc osc2 => dac;
spork ~ am(osc1, osc2, 0.1);
On Thu, Dec 5, 2013 at 12:01 PM, Manuel Bärenz
-- Release me, insect, or I will destroy the Cosmos!

sorry for the incomplete repeat post. I find that multiply mode opens lots of interesting possibilities. The nice thing about chuck is there are often many ways to do the same thing . each with different strengths and weaknesses. On Thursday, December 5, 2013, Steve Morris wrote:
participants (5)
-
Manuel Bärenz
-
Moisés Gabriel Cachay Tello
-
Stefan Blixt
-
Steve Morris
-
Steve Morris