From b2b26d90d227d0a2696d3ee3e27ee2ebef0f794e Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Thu, 1 Jan 2015 22:04:22 +0000 Subject: [PATCH] Wow now you can arm whenever --- main.ck | 15 ++++++++++++--- main.py | 36 +++++++++++++++++------------------- scratch.ck | 51 +++++---------------------------------------------- 3 files changed, 34 insertions(+), 68 deletions(-) diff --git a/main.ck b/main.ck index a96c57c..f1b9cd8 100644 --- a/main.ck +++ b/main.ck @@ -17,8 +17,8 @@ OscMsg msg; // Event loop while (true) { - //oin => now; - 1::second => now; + oin => now; + //1::second => now; while (oin.recv(msg)) { if (msg.address=="/input") { @@ -38,12 +38,18 @@ while (true) { { msg.getInt(0) => int i; channels[i].setGain(msg.getFloat(1)); + channels[i].setPan(msg.getFloat(2)); } else if(msg.address=="/arm") { msg.getInt(0) => int channel; for( 0 => int i; i < channels.cap(); i++ ) { channels[i].arm(i==channel); } } + else if(msg.address=="/clear") + { + msg.getInt(0) => int channel; + channels[channel].clear(); + } } } @@ -53,7 +59,7 @@ public class SampleChan adc => LiSa sample => LPF filter; // Setup - 10::second => sample.duration; //This is the max duration + 10::second => sample.duration; //This is the max duration 0::second => sample.recPos => sample.playPos; 1.0 => sample.feedback; 1 => sample.loop; @@ -65,6 +71,8 @@ public class SampleChan 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 setPan( float pan ) { } + public void clear() { sample.clear(); } public void outputTo(UGen ugen) { 1 => sample.play; @@ -72,6 +80,7 @@ public class SampleChan } public void arm(int value) { + sample.playPos() => sample.recPos; value => sample.record; } } diff --git a/main.py b/main.py index b9e13b8..a5f65da 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,12 @@ from libs.simpleosc import * import wx +def sendOSCSave(channel, data): + try: + sendOSCMsg(channel, data) + except OSCClientError: + print "OSC comms error" + class OSCSlider(wx.Panel): ''' A GUI slider ''' def __init__(self, parent, label, min_value=0, max_value=1, default_value=0, align=True): @@ -71,10 +77,7 @@ class InputPanel(wx.Panel): gain=self.gain.slider.GetValue()/100. thru=self.thru.slider.GetValue()/100. if self.mute.GetValue(): gain, thru = 0.,0. - try: - sendOSCMsg("/input", [gain, thru]) - except OSCClientError: - pass + sendOSCMsg("/input", [gain, thru]) class DelayPanel(wx.Panel): ''' Handle the ADC input settings ''' @@ -105,10 +108,7 @@ class DelayPanel(wx.Panel): """ Send OSC messages """ a=self.delayTime.slider.GetValue()/100. b=self.feedback.slider.GetValue()/100. - try: - sendOSCMsg("/delay", [a, b]) - except OSCClientError: - pass + sendOSCMsg("/delay", [a, b]) class Channel(wx.Panel): """ A single channel """ @@ -123,6 +123,10 @@ class Channel(wx.Panel): self.gain = OSCSlider(self, "Gain", default_value=1, max_value=1.3, align=False) sizer.Add(self.gain, 0, wx.ALL|wx.EXPAND, 3) + + self.pan = OSCSlider(self, "Pan", default_value=0, min_value=-1, max_value=1, align=False) + sizer.Add(self.pan, 0, wx.ALL|wx.EXPAND, 3) + self.record = wx.ToggleButton(self, 1, "Arm") sizer.Add(self.record, 0, wx.ALL|wx.EXPAND if index==0 else wx.ALL|wx.EXPAND, 3) @@ -133,16 +137,15 @@ class Channel(wx.Panel): self.SetSizerAndFit(sizer) self.gain.Bind(wx.EVT_SCROLL, self.update) + self.pan.Bind(wx.EVT_SCROLL, self.update) self.mute.Bind(wx.EVT_TOGGLEBUTTON, self.update) self.update() def update(self, evt=None): gain=self.gain.GetValue()/100. + pan=self.pan.GetValue()/100. if self.mute.GetValue(): gain=0.0; - try: - sendOSCMsg("/channel", [self.index, gain]) - except OSCClientError: - pass + sendOSCMsg("/channel", [self.index, gain, pan]) class Mixer(wx.Panel): @@ -171,17 +174,12 @@ class Mixer(wx.Panel): for i, c in enumerate(self.channels): c.record.SetValue(0) self.channels[index].record.SetValue(value) - if value: - sendOSCMsg("/arm", [index]) - print "Record on channel %d" % index - else: - sendOSCMsg("/arm", [-1]) - print "Stop recording on all channels" + sendOSCMsg("/arm", [index if value else -1]) def clear_channel(self, evt): """ Send OSC message to clear a channel """ index = evt.GetEventObject().index - print "Clear channel %d" % index + sendOSCMsg("/clear", [index]) diff --git a/scratch.ck b/scratch.ck index e362bca..4dab6c4 100644 --- a/scratch.ck +++ b/scratch.ck @@ -1,48 +1,7 @@ -public class SampleChan -{ - // Chain - LiSa sample => LPF filter; +SinOsc s => Pan2 p => dac; +1 => p.pan; - // 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; - setLoopPoint(1::second); - filter.set(10000, 1); - - public void setLoopPoint( dur length ) { - length => sample.loopEnd => sample.loopEndRec; - } - - 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; - } +while(1::second => now){ + // this will flip the pan from left to right + p.pan() * -1. => p.pan; } - -// Effects chain -Gain mixer => dac; // Main mixer -//adc => Gain adcThru => mixer; // Monitor the input -SampleChan sample; // Sampler - -sample.outputTo(mixer); -sample.recordFrom(adc); - -2::second => now; -sample.stopRecording(); -5::second=>now; - -/*while(true) { 1::second => now; }*/