Переглянути джерело

Wow now you can arm whenever

master
Pete Shadbolt 10 роки тому
джерело
коміт
b2b26d90d2
3 змінених файлів з 34 додано та 68 видалено
  1. +12
    -3
      main.ck
  2. +17
    -19
      main.py
  3. +5
    -46
      scratch.ck

+ 12
- 3
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;
}
}


+ 17
- 19
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])





+ 5
- 46
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; }*/

Завантаження…
Відмінити
Зберегти