From 04f17f83b2a2799dfa78763e8c501da0292c6bd4 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 4 Sep 2012 16:15:01 +0200 Subject: 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) --- lib/SampOsc.ck | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') 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; -- cgit v1.2.3