diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-04 16:15:01 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-04 16:15:01 +0200 |
commit | 04f17f83b2a2799dfa78763e8c501da0292c6bd4 (patch) | |
tree | 3ff36103cae842864bdcd9c80c5e343cae927aad | |
parent | 58834d3578dbffb8835409eedcc54d1af6cfb8bf (diff) | |
download | digitale-debutanten-04f17f83b2a2799dfa78763e8c501da0292c6bd4.tar.gz |
if possible save SampOsc source directory for later use
makes SampOsc independant of ChucK VM cwd or directory of shred instantiating SampOsc
(only if VM wasn't started with --loop)
-rw-r--r-- | lib/SampOsc.ck | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/SampOsc.ck b/lib/SampOsc.ck index 2046728..d6adb4b 100644 --- a/lib/SampOsc.ck +++ b/lib/SampOsc.ck @@ -2,6 +2,8 @@ * Sample based oscillator */ public class SampOsc extends ChubgraphStd { + static string @__sourceDir; /* pseudo-private */ + inlet => blackhole; inlet.last() => float __last_in; /* pseudo-private */ 1 => float __freq; /* pseudo-private */ @@ -57,7 +59,7 @@ public class SampOsc extends ChubgraphStd { max_latency => now; } else { interval +=> last_trigger; - if (last_trigger >= now) + if (last_trigger > now) last_trigger => now; 0 => __buf.pos; } @@ -67,7 +69,11 @@ public class SampOsc extends ChubgraphStd { } spork ~ __loop(); - /* FIXME: not independant from cwd when instantiated */ - "lib/pulse.wav" => read; + __sourceDir+"/pulse.wav" => read; 1 => rate; } +/* static initialization */ +me.sourceDir() => SampOsc.__sourceDir; +/* BUG WORKAROUND: me.sourceDir() == "" if VM is started with --loop */ +if (SampOsc.__sourceDir == "") + "lib" => SampOsc.__sourceDir; |