[chuck-users] pulse width modulation

Michael Heuer heuermh at gmail.com
Tue Jan 26 16:56:54 EST 2010


I'm trying to model the following in ChucK

"OSC1, OSC2, and an LFO (Low Frequency Oscillator) Modulation: OSC1
produces a simple square wave tone, the
pulsewidth of which is modulated with OSC2, and then amplitude
modulated with the LFO oscillator."

I think I understand the LFO amplitude modulation part, but I don't
understand what pulse width modulation with osc2 means.

SqrOsc osc1;
SqrOsc osc2;
SqrOsc lfo;
Gain master;
lfo => blackhole;

osc1 => master;
220.0 => osc1.freq;
0.8 => osc1.gain;
20.0 => lfo.freq;
0.9 => lfo.gain;

fun void updateAtSampleRate()
{
  while (true)
  {
    ((lfo.last() + 1.0) / 2.0) * 0.8 => osc1.gain;
    1::samp => now;
  }
}

master => dac;
spork ~ updateAtSampleRate();
2::second => now;


More information about the chuck-users mailing list