Pete Shadbolt 10 лет назад
Родитель
Сommit
1d8053d5f3
2 измененных файлов: 106 добавлений и 26 удалений
  1. +32
    -20
      main.ck
  2. +74
    -6
      main.py

+ 32
- 20
main.ck Просмотреть файл

@@ -8,29 +8,41 @@ g => Gain feedback => DelayL delay => g;
1 => feedback.gain;
1 => delay.gain;

// Create our OSC receiver
spork ~ inputEventHandler(9000);

// Loop forever
while(true) { 1::second => now; }
// OSC listener class
class OSCListener {
fun void run(int port, string address) {
OscRecv recv; port => recv.port; recv.listen();
recv.event(address) @=> OscEvent oe;
while (true) { oe => now; while (oe.nextMsg() != 0) { this.handle(oe); } }
me.yield();
}
fun void handle(OscEvent oe){};
}

// define child class Y
class InputListener extends OSCListener {
fun void handle(OscEvent oe){
oe.getFloat() => g.gain;
oe.getFloat() => float a;
}
}

inputEventHandler => awd.handler;

// Event loop to deal with ADC input
fun void inputEventHandler(int port) {
OscRecv recv;
port => recv.port;
recv.listen();
recv.event( "/input, f f" ) @=> OscEvent oe;
while (true) {
oe => now;
while (oe.nextMsg() != 0) {
oe.getFloat() => g.gain;
oe.getFloat() => float a;
}
// define child class Y
class DelayListener extends OSCListener
{
fun void handle(OscEvent oe){
oe.getFloat()::second => delay.delay;
oe.getFloat() => feedback.gain;
}
me.yield();
}

InputListener il;
DelayListener dl;
spork ~ il.run(9000, "/input, f, f");
spork ~ dl.run(9000, "/delay, f, f");

// Loop forever
while(true) { 1::second => now; }




+ 74
- 6
main.py Просмотреть файл

@@ -57,6 +57,72 @@ class InputPanel(wx.Panel):
except OSCClientError:
pass

class DelayPanel(wx.Panel):
''' Handle the ADC input settings '''
def __init__(self, parent):
''' Constructor '''
wx.Panel.__init__(self, parent)
sizer = wx.BoxSizer(wx.VERTICAL)

label = wx.StaticText(self, label="Delay line:")
font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)

self.delayTime=OSCSlider(self, "Delay time (s)", default_value=5, max_value=10)
sizer.Add(self.delayTime, 0, wx.EXPAND|wx.ALL, 5)

self.feedback=OSCSlider(self, "Feedback", default_value=.95)
sizer.Add(self.feedback, 0, wx.EXPAND|wx.ALL, 5)

self.SetSizerAndFit(sizer)
self.delayTime.slider.Bind(wx.EVT_SCROLL, self.update)
self.feedback.slider.Bind(wx.EVT_SCROLL, self.update)
self.update(None)

def update(self, evt):
""" Send OSC messages """
a=self.delayTime.slider.GetValue()/100.
b=self.feedback.slider.GetValue()/100.
try:
sendOSCMsg("/delay", [a, b])
except OSCClientError:
pass

class Channel(wx.Panel):
""" A single channel """
def __init__(self, parent, index):
self.index=index
wx.Panel.__init__(self, parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetBackgroundColour((255,0,0))

label = wx.StaticText(self, label="CH%d" % self.index)
font = label.GetFont(); font.SetWeight(wx.BOLD); label.SetFont(font)
sizer.Add(label, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 5)
self.SetSizerAndFit(sizer)


class ChannelPanel(wx.Panel):
''' All the channels '''
def __init__(self, parent):
''' Constructor '''
wx.Panel.__init__(self, parent)
sizer = wx.BoxSizer(wx.HORIZONTAL)

self.channels=[]
for i in range(4):
c=Channel(self, index=i)
#self.feedback.slider.Bind(wx.EVT_SCROLL, self.update)
self.channels.append(c)
sizer.Add(c, 1, wx.EXPAND)

self.SetSizerAndFit(sizer)
self.update(None)

def update(self, evt):
""" Send OSC messages """
pass



class MainGUI(wx.Frame):
@@ -79,14 +145,16 @@ class MainGUI(wx.Frame):
self.inputPanel = InputPanel(self)
self.mainsizer.Add(self.inputPanel, 0, wx.EXPAND|wx.ALL, 5)

line=wx.StaticLine(self)
self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 5)
line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 5)

self.delayTime=OSCSlider(self, "Delay time (s)", default_value=5, max_value=10)
self.mainsizer.Add(self.delayTime, 0, wx.EXPAND|wx.ALL, 5)
self.delayPanel = DelayPanel(self)
self.mainsizer.Add(self.delayPanel, 0, wx.EXPAND|wx.ALL, 5)

line=wx.StaticLine(self); self.mainsizer.Add(line, 0, wx.EXPAND|wx.ALL, 5)

self.channelPanel = ChannelPanel(self)
self.mainsizer.Add(self.channelPanel, 1, wx.EXPAND|wx.ALL, 5)

self.feedback=OSCSlider(self, "Feedback", default_value=.95)
self.mainsizer.Add(self.feedback, 0, wx.EXPAND|wx.ALL, 5)

# Put things together
self.SetSizerAndFit(self.mainsizer)


Загрузка…
Отмена
Сохранить