瀏覽代碼

Metronome now syncs!

master
Pete Shadbolt 10 年之前
父節點
當前提交
9cf0a3c1e7
共有 3 個文件被更改,包括 66 次插入26 次删除
  1. +27
    -5
      main.ck
  2. +2
    -2
      main.py
  3. +37
    -19
      scratch.ck

+ 27
- 5
main.ck 查看文件

@@ -1,7 +1,6 @@
// TODO: turn off adcThru when recording
// TODO: Effects break panning for some unknown reason
// TODO: currently I don't turn ADC thru back on after recording

// Effects chain with limiters, reverb, filters
NRev reverb => LPF lpf => HPF hpf => Dyno outputLimiter => dac;
outputLimiter.limit();
@@ -19,7 +18,7 @@ inputLimiter @=> UGen @ mainInput;
.5 => adcThru.gain;
10000 => lpf.freq;
10 => hpf.freq;
1::second => dur loopTime;
//1::second => dur loopTime;

// Plug in the pedals
LoopPedal pedals[4];
@@ -28,6 +27,10 @@ for( 0 => int i; i < pedals.cap(); i++ ) {
pedals[i].outputTo(outputWet, outputDry);
}

// Create the metronome
Metronome metronome;
spork ~metronome.run();

// Start listening to OSC messages
OscIn oin; 9000 => oin.port;
oin.listenAll();
@@ -42,10 +45,9 @@ while (true) {
msg.getFloat(1) => adcThru.gain;
}
else if(msg.address=="/delay") {
msg.getFloat(0)::second => loopTime;
msg.getFloat(0)::second => dur loopTime;
msg.getFloat(1) => float feedback;
for( 0 => int i; i < pedals.cap(); i++ ) {
//pedals[i].setLoopPoint(loopTime + (i*.1)::second);
pedals[i].setLoopPoint(loopTime);
pedals[i].setFeedback(feedback);
}
@@ -78,7 +80,7 @@ while (true) {
}
}

public class LoopPedal
class LoopPedal
{
// We are wrapping a live sampler, LiSa
LiSa sample;
@@ -100,6 +102,7 @@ public class LoopPedal
public void setWet( float ratio ) { ratio => wet.gain; 1-ratio => dry.gain;}
public void clear() { sample.clear(); }
public void recordFrom(UGen ugen) { ugen => sample; }
public dur remaining() { return sample.loopEnd() - sample.playPos(); }

public void outputTo(UGen wetSink, UGen drySink) {
1 => sample.play;
@@ -115,6 +118,25 @@ public class LoopPedal
}


class Metronome
{
// A simple metronome
SinOsc s => ADSR a => dac;
0.5 => s.gain;
a.set(0.01, .1, .5, .2);
0.01::second => dur plipTime;

fun void run()
{
while(true){
pedals[0].remaining() => now;
a.keyOn();
plipTime => now;
a.keyOff();
}
}
}






+ 2
- 2
main.py 查看文件

@@ -3,7 +3,7 @@ import wx

def sendOSCSafe(channel, data):
try:
print channel, data
#print channel, data
sendOSCMsg(channel, data)
except OSCClientError:
print "OSC comms error"
@@ -115,7 +115,7 @@ class DelayPanel(wx.Panel):
label.SetFont(font)
sizer.Add(label, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)

self.delayTime = OSCSlider(self, "Time", default_value=1, max_value=10, align=False)
self.delayTime = OSCSlider(self, "Time", default_value=1, max_value=10, min_value=0.5, align=False)
sizer.Add(self.delayTime, 1, wx.ALL, 5)

self.feedback = OSCSlider(self, "Hold", default_value=.99, align=False)


+ 37
- 19
scratch.ck 查看文件

@@ -1,26 +1,44 @@
1::second => dur loopTime;

fun void plip()
{
SinOsc s => dac;
0.05::second => dur plipTime;
2000 => s.freq;
// the event
KBHit kb;

class MetronomeEvent extends Event{ int value; }

class Metronome {
MetronomeEvent metronomeEvent;
spork ~pulse();

fun void listen(){
while (true){
metronomeEvent => now;
<<<"Metronome got event " + metronomeEvent.value>>>;
if (metronomeEvent.value==0){
spork ~pulse();
}
}
}

while(true){
.1 => s.gain;
plipTime => now;
0 => s.gain;
loopTime - plipTime => now;
fun void pulse(){
1::second => now;
0=>metronomeEvent.value;
metronomeEvent.signal();
}

fun void signal(){
1=>metronomeEvent.value;
metronomeEvent.signal();
}
}

spork ~plip();
Metronome m;
spork ~m.listen();

while(true){
1::second => now;
loopTime - 0.1::second => loopTime;
// time-loop
while( true )
{
kb => now;
while( kb.more() )
{
<<< "ascii: ", kb.getchar() >>>;
m.signal();
}
}




Loading…
取消
儲存