Browse Source

Lovely job. Need to get metronome working

master
Pete Shadbolt 9 years ago
parent
commit
ba193b290a
4 changed files with 70 additions and 23 deletions
  1. +40
    -18
      main.ck
  2. +5
    -0
      main.py
  3. +1
    -0
      run.sh
  4. +24
    -5
      scratch.ck

+ 40
- 18
main.ck View File

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


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


// Global loop time
1::second => dur loopTime;

// Each channel should output to the mixer // Each channel should output to the mixer
for( 0 => int i; i < channels.cap(); i++ ) { channels[i].outputTo(mixer); }
for( 0 => int i; i < channels.cap(); i++ ) { channels[i].outputTo(dac); }


// Listen to OSC messages // Listen to OSC messages
OscIn oin; 9000 => oin.port; OscIn oin; 9000 => oin.port;
oin.listenAll(); oin.listenAll();
OscMsg msg; OscMsg msg;


// Start the metronome
0 => int metronomeLevel;
spork ~plip();

// Event loop // Event loop
while (true) { while (true) {
oin => now; oin => now;
//1::second => now;
while (oin.recv(msg)) { while (oin.recv(msg)) {
if (msg.address=="/input")
{
if (msg.address=="/input") {
msg.getFloat(0) => adc.gain; msg.getFloat(0) => adc.gain;
msg.getFloat(1) => adcThru.gain; msg.getFloat(1) => adcThru.gain;
} }
else if(msg.address=="/delay")
{
msg.getFloat(0)::second => dur loopPoint;
else if(msg.address=="/delay") {
msg.getFloat(0)::second => loopTime;
msg.getFloat(1) => float feedback; msg.getFloat(1) => float feedback;
for( 0 => int i; i < channels.cap(); i++ ) { for( 0 => int i; i < channels.cap(); i++ ) {
channels[i].setLoopPoint(loopPoint);
channels[i].setLoopPoint(loopTime);
channels[i].setFeedback(feedback); channels[i].setFeedback(feedback);
} }
} }
else if(msg.address=="/channel")
{
else if(msg.address=="/channel") {
msg.getInt(0) => int i; msg.getInt(0) => int i;
channels[i].setGain(msg.getFloat(1)); channels[i].setGain(msg.getFloat(1));
channels[i].setPan(msg.getFloat(2)); channels[i].setPan(msg.getFloat(2));
} }
else if(msg.address=="/arm")
{
else if(msg.address=="/arm") {
msg.getInt(0) => int channel; msg.getInt(0) => int channel;
for( 0 => int i; i < channels.cap(); i++ ) { channels[i].arm(i==channel); } for( 0 => int i; i < channels.cap(); i++ ) { channels[i].arm(i==channel); }
} }
else if(msg.address=="/clear")
{
else if(msg.address=="/metronome") {
msg.getInt(0) => metronomeLevel;
}
else if(msg.address=="/clear") {
msg.getInt(0) => int channel; msg.getInt(0) => int channel;
channels[channel].clear(); channels[channel].clear();
} }
@@ -56,7 +60,7 @@ while (true) {
public class SampleChan public class SampleChan
{ {
// Chain // Chain
adc => LiSa sample => LPF filter;
adc => LiSa sample => LPF filter => Pan2 panner;


// Setup // Setup
10::second => sample.duration; //This is the max duration 10::second => sample.duration; //This is the max duration
@@ -71,12 +75,12 @@ public class SampleChan
public void setFeedback( float fb ) { fb => sample.feedback; } public void setFeedback( float fb ) { fb => sample.feedback; }
public void setFilter( float freq ) { freq => filter.freq; } public void setFilter( float freq ) { freq => filter.freq; }
public void setGain( float gain ) { gain => filter.gain; } public void setGain( float gain ) { gain => filter.gain; }
public void setPan( float pan ) { }
public void setPan( float pan ) { pan => panner.pan; }
public void clear() { sample.clear(); } public void clear() { sample.clear(); }


public void outputTo(UGen ugen) { public void outputTo(UGen ugen) {
1 => sample.play; 1 => sample.play;
filter => ugen;
panner => ugen;
} }


public void arm(int value) { public void arm(int value) {
@@ -85,3 +89,21 @@ public class SampleChan
} }
} }



// TODO timing here should be done using events
fun void plip()
{
SinOsc s => dac;
0.01::second => dur plipTime;

while(true){
for( 0 => int i; i < 4; i++ ) {
if (i==0){2000 => s.freq;} else {1000 => s.freq;}
.1*metronomeLevel => s.gain;
plipTime => now;
0 => s.gain;
loopTime/4 - plipTime => now;
}
}

}

+ 5
- 0
main.py View File

@@ -102,6 +102,7 @@ class DelayPanel(wx.Panel):
self.SetSizerAndFit(sizer) self.SetSizerAndFit(sizer)
self.delayTime.Bind(wx.EVT_SCROLL, self.update) self.delayTime.Bind(wx.EVT_SCROLL, self.update)
self.feedback.Bind(wx.EVT_SCROLL, self.update) self.feedback.Bind(wx.EVT_SCROLL, self.update)
self.metronome.Bind(wx.EVT_TOGGLEBUTTON, self.switchMetronome)
self.update(None) self.update(None)


def update(self, evt): def update(self, evt):
@@ -110,6 +111,10 @@ class DelayPanel(wx.Panel):
b=self.feedback.slider.GetValue()/100. b=self.feedback.slider.GetValue()/100.
sendOSCMsg("/delay", [a, b]) sendOSCMsg("/delay", [a, b])


def switchMetronome(self, evt):
""" Send OSC messages """
sendOSCMsg("/metronome", [int(self.metronome.GetValue())])

class Channel(wx.Panel): class Channel(wx.Panel):
""" A single channel """ """ A single channel """
def __init__(self, parent, index): def __init__(self, parent, index):


+ 1
- 0
run.sh View File

@@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
#chuck scratch.ck
chuck --bufsize64 main.ck & chuck --bufsize64 main.ck &
python ./main.py python ./main.py
pkill -SIGINT chuck pkill -SIGINT chuck


+ 24
- 5
scratch.ck View File

@@ -1,7 +1,26 @@
SinOsc s => Pan2 p => dac;
1 => p.pan;
1::second => dur loopTime;


while(1::second => now){
// this will flip the pan from left to right
p.pan() * -1. => p.pan;
fun void plip()
{
SinOsc s => dac;
0.05::second => dur plipTime;
2000 => s.freq;

while(true){
.1 => s.gain;
plipTime => now;
0 => s.gain;
loopTime - plipTime => now;
}

}

spork ~plip();

while(true){
1::second => now;
loopTime - 0.1::second => loopTime;
} }




Loading…
Cancel
Save