From 6aabf209da366b2c62b0b44fc6eed9b1a24cdc63 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 16 Apr 2012 22:18:27 +0200 Subject: added sample-based oscillator class --- lib/SampOsc.ck | 26 ++++++++++++++++++++++++++ lib/pulse.wav | Bin 0 -> 35322 bytes 2 files changed, 26 insertions(+) create mode 100644 lib/SampOsc.ck create mode 100644 lib/pulse.wav (limited to 'lib') diff --git a/lib/SampOsc.ck b/lib/SampOsc.ck new file mode 100644 index 0000000..bc5feda --- /dev/null +++ b/lib/SampOsc.ck @@ -0,0 +1,26 @@ +/* + * Sample based oscillator + * NOTE: may not be frequency-synced! + */ +public class SampOsc extends SndBuf { + 1 => float __freq; /* pseudo-private */ + fun float freq(float f) + { + return f => __freq; + } + fun float freq() + { + return __freq; + } + + /* FIXME: not independant from cwd when instantiated */ + "lib/pulse.wav" => read; + 1 => rate; + + fun void __loop() /* pseudo-private */ + { + while (second/__freq => now) + 0 => pos; + } + spork ~ __loop(); +} diff --git a/lib/pulse.wav b/lib/pulse.wav new file mode 100644 index 0000000..ccf7b26 Binary files /dev/null and b/lib/pulse.wav differ -- cgit v1.2.3