diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-04-18 00:03:46 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-04-18 00:03:46 +0200 |
commit | d572febd57e507b7d04dfa2111f048f11dfca4d1 (patch) | |
tree | f247822132494cb535decd3a5a59d62f60488fc9 /lib | |
parent | c5ab57c1494f96a063ae6ea7744221db4d659ab4 (diff) | |
download | digitale-debutanten-d572febd57e507b7d04dfa2111f048f11dfca4d1.tar.gz |
fixed SampOsc and integrated it as oscillator into lfo
Diffstat (limited to 'lib')
-rw-r--r-- | lib/SampOsc.ck | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/SampOsc.ck b/lib/SampOsc.ck index bc5feda..6bbb3a9 100644 --- a/lib/SampOsc.ck +++ b/lib/SampOsc.ck @@ -4,6 +4,7 @@ */ public class SampOsc extends SndBuf { 1 => float __freq; /* pseudo-private */ + fun float freq(float f) { return f => __freq; @@ -13,14 +14,30 @@ public class SampOsc extends SndBuf { return __freq; } - /* FIXME: not independant from cwd when instantiated */ - "lib/pulse.wav" => read; - 1 => rate; - + /* + * Wait till next loop point but no longer than 100::ms, + * so frequency changes get applied with a maximum of 100::ms latency. + * NOTE: Due to a ChucK bug, simply killing and restarting the shred + * does not work very well. + */ fun void __loop() /* pseudo-private */ { - while (second/__freq => now) - 0 => pos; + now => time last_trigger; + + while (second/__freq => dur interval) { + if (last_trigger+interval - now > 100::ms) { + 100::ms => now; + } else { + interval +=> last_trigger; + if (last_trigger >= now) + last_trigger => now; + 0 => pos; + } + } } spork ~ __loop(); + + /* FIXME: not independant from cwd when instantiated */ + "lib/pulse.wav" => read; + 1 => rate; } |