Browse Source

TODO: Sync channels

master
Pete Shadbolt 9 years ago
parent
commit
a4598b22b5
2 changed files with 33 additions and 40 deletions
  1. +31
    -39
      main.ck
  2. +2
    -1
      main.py

+ 31
- 39
main.ck View File

@@ -1,15 +1,14 @@
// TODO: turn off adcThru when recording
// Effects chain
adc => Gain adcThru => Gain mixer => dac; // Monitor input through a mixer
SampleChan channel1;
SampleChan channels[4];

// Levels
//0 => adc.gain;
.5 => adcThru.gain;

// Start recording and playing in a loop
channel1.outputTo(mixer);
channel1.recordFrom(adc);
// Each channel should output to the mixer
for( 0 => int i; i < channels.cap(); i++ ) { channels[i].outputTo(mixer); }

// Listen to OSC messages
OscIn oin; 9000 => oin.port;
@@ -18,49 +17,49 @@ OscMsg msg;

// Event loop
while (true) {
oin => now;
//oin => now;
1::second => now;
while (oin.recv(msg)) {
<<<msg.address>>>;
if (msg.address=="/input")
controlInput(msg);
if (msg.address=="/input")
{
msg.getFloat(0) => adc.gain;
msg.getFloat(1) => adcThru.gain;
}
else if(msg.address=="/delay")
controlDelay(msg);
{
msg.getFloat(0)::second => dur loopPoint;
msg.getFloat(1) => float feedback;
for( 0 => int i; i < channels.cap(); i++ ) {
channels[i].setLoopPoint(loopPoint);
channels[i].setFeedback(feedback);
}
}
else if(msg.address=="/channel")
controlChannel(msg);
{
msg.getInt(0) => int i;
channels[i].setGain(msg.getFloat(1));
}
else if(msg.address=="/arm")
{
msg.getInt(0) => int channel;
for( 0 => int i; i < channels.cap(); i++ ) { channels[i].arm(i==channel); }
}
}
}


fun void controlInput(OscMsg msg){
msg.getFloat(0) => adc.gain;
msg.getFloat(1) => adcThru.gain;
}

fun void controlDelay(OscMsg msg){
channel1.setLoopPoint(msg.getFloat(0)::second);
channel1.setFeedback(msg.getFloat(1));
}

fun void controlChannel(OscMsg msg){
msg.getInt(0) => int channel;
channel1.setGain(msg.getFloat(1));
}


public class SampleChan
{
// Chain
LiSa sample => LPF filter;
adc => 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);
setFilter(10000);

public void setLoopPoint( dur length ) { length => sample.loopEnd => sample.loopEndRec; }
public void setFeedback( float fb ) { fb => sample.feedback; }
@@ -72,15 +71,8 @@ public class SampleChan
filter => ugen;
}

public void recordFrom(UGen ugen) {
1 => sample.record;
ugen => sample;
ugen @=> mySource;
}

public void stopRecording() {
0 => sample.record;
mySource =< sample;
public void arm(int value) {
value => sample.record;
}
}


+ 2
- 1
main.py View File

@@ -137,7 +137,6 @@ class Channel(wx.Panel):
self.update()

def update(self, evt=None):
print "Channel %d: send gain, pan, mute" % self.index
gain=self.gain.GetValue()/100.
if self.mute.GetValue(): gain=0.0;
try:
@@ -173,8 +172,10 @@ class Mixer(wx.Panel):
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"

def clear_channel(self, evt):


Loading…
Cancel
Save