From df4f1bad31b2c8b539bb170d3db2dbc7839fa7be Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Thu, 1 Jan 2015 17:40:22 +0000 Subject: [PATCH] Main now uses SampleChan class --- main.ck | 61 +++++++++++++++++++++++++++++++++++++++++++++------------ run.sh | 7 +++---- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/main.ck b/main.ck index ca4f989..265230f 100644 --- a/main.ck +++ b/main.ck @@ -1,20 +1,15 @@ -// Effects chain -Gain mixer => dac; // Main mixer -adc => Gain adcThru => mixer; // Monitor the input -adc => LiSa sample => mixer; // Sampler // TODO: turn off adcThru when recording - -//Times -10::second => sample.duration; -0::second => sample.recPos => sample.playPos; -1::second => sample.loopEnd => sample.loopEndRec; +// Effects chain +adc => Gain adcThru => Gain mixer => dac; // Monitor input through a mixer +SampleChan channel1; // Levels //0 => adc.gain; .5 => adcThru.gain; // Start recording and playing in a loop -1 => sample.loop => sample.record => sample.play; +channel1.outputTo(mixer); +channel1.recordFrom(adc); // Listen to OSC messages OscIn oin; 9000 => oin.port; @@ -35,17 +30,57 @@ while (true) { } } + fun void controlInput(OscMsg msg){ msg.getFloat(0) => adc.gain; msg.getFloat(1) => adcThru.gain; } fun void controlDelay(OscMsg msg){ - msg.getFloat(0)::second => sample.loopEnd => sample.loopEndRec; - msg.getFloat(1) => sample.feedback; + channel1.setLoopPoint(msg.getFloat(0)::second); + channel1.setFeedback(msg.getFloat(1)); } fun void controlChannel(OscMsg msg){ msg.getInt(0) => int channel; - msg.getFloat(1) => sample.gain; + channel1.setGain(msg.getFloat(1)); } + + +public class SampleChan +{ + // Chain + LiSa sample => LPF filter; + + // Setup + UGen @ mySource; + 10::second => sample.duration; //This is the max duration + 0::second => sample.recPos => sample.playPos; + 1.0 => sample.feedback; + 1 => sample.loop; + 1 => filter.Q; + setLoopPoint(1::second); + setFilter(1000); + + public void setLoopPoint( dur length ) { length => sample.loopEnd => sample.loopEndRec; } + public void setFeedback( float fb ) { fb => sample.feedback; } + public void setFilter( float freq ) { freq => filter.freq; } + public void setGain( float gain ) { gain => filter.gain; } + + public void outputTo(UGen ugen) { + 1 => sample.play; + filter => ugen; + } + + public void recordFrom(UGen ugen) { + 1 => sample.record; + ugen => sample; + ugen @=> mySource; + } + + public void stopRecording() { + 0 => sample.record; + mySource =< sample; + } +} + diff --git a/run.sh b/run.sh index c62451a..699ed67 100755 --- a/run.sh +++ b/run.sh @@ -1,6 +1,5 @@ #!/bin/bash -chuck --bufsize64 scratch.ck -#chuck --bufsize64 main.ck & -#python ./main.py -#pkill -SIGINT chuck +chuck --bufsize64 main.ck & +python ./main.py +pkill -SIGINT chuck