Quellcode durchsuchen

Warming up for real OSC comms

master
Pete Shadbolt vor 10 Jahren
Ursprung
Commit
8a327cb628
4 geänderte Dateien mit 124 neuen und 37 gelöschten Zeilen
  1. +19
    -0
      README
  2. +51
    -25
      chuck.ck
  3. +50
    -11
      osctest.py
  4. +4
    -1
      run.sh

+ 19
- 0
README Datei anzeigen

@@ -0,0 +1,19 @@
TODO:
Two or three channels

Global Sliders:
- BPM
- Input gain
- Amount of input to send to delay line
- Feedback amount

Global Switches:
- OSC Master/Minion

Channel Sliders:
- Gain

Channel buttons:
- Clear
- Mute/unmute
- Pitch down

+ 51
- 25
chuck.ck Datei anzeigen

@@ -1,39 +1,65 @@
// feedforward
// Effects chain
adc => Gain g => dac;
// feedback
g => Gain feedback => DelayL delay => g;

// set delay parameters
5::second => delay.max => delay.delay;
// set feedback
.5 => feedback.gain;
// set effects mix
.75 => delay.gain;
// Delay parameters
10::second => delay.max;
5::second => delay.delay;
1 => feedback.gain;
1 => delay.gain;

// infinite time loop
<<< "hello from chuck (waiting for OSC)" >>>;

// create our OSC receiver
// Create our OSC receiver
OscRecv recv;

// use port 9000
9000 => recv.port;
// start listening (launch thread)
recv.listen();

// create an address in the receiver, store in new variable
recv.event( "/test, f" ) @=> OscEvent oe;

// infinite event loop
while ( true )
{
// wait for event to arrive
// Event loop
while (true) {
// Wait for event to arrive
oe => now;

// grab the next message from the queue.
while ( oe.nextMsg() != 0 )
{
<<< oe.getFloat() >>>;
// Grab the next message from the queue.
while ( oe.nextMsg() != 0 ) {
float val;
<<<val>>>;
oe.getFloat() => val;
val::second => delay.delay;
}
}


/*
// Listen for messages regarding ADC input
fun void oscListener( int port, string osctype ) {
// create our OSC receiver
OscRecv recv;
port => recv.port;
recv.listen();

int val;
string type;

// create an address in the receiver, store in new variable
recv.event( osctype ) @=> OscEvent oe;

while( true ) {
// wait for osc event to arrive
oe => now;

while( oe.nextMsg() ) {
oe.getInt() => val;
osctype => type;

if( type == leftraw ) {
val => raw.freq;
}
else if( type == leftavg ) {
val => avg.freq;
}

me.yield();
}
}
}
*/

+ 50
- 11
osctest.py Datei anzeigen

@@ -3,21 +3,51 @@ import wx

class OSCSlider(wx.Panel):
''' A GUI slider '''
def __init__(self, parent, label, min_value=0, max_value=100, default_value=0):
def __init__(self, parent, label, min_value=0, max_value=1, default_value=0, show_value=True, align=True):
''' Constructor '''
self.show_value=show_value
wx.Panel.__init__(self, parent)
sizer=wx.BoxSizer(wx.HORIZONTAL)
self.indicator=wx.StaticText(self, label=label)
sizer.Add(self.indicator, 0, wx.RIGHT, 10)
self.slider=wx.Slider(self, value=default_value, minValue=min_value, maxValue=max_value)
label=wx.StaticText(self, label=label, size=(100,15) if align else None)
sizer.Add(label, 0, wx.RIGHT, 10)
self.slider=wx.Slider(self, value=default_value*100, minValue=min_value*100, maxValue=max_value*100)
sizer.Add(self.slider, 1, wx.EXPAND)
if show_value:
self.indicator=wx.StaticText(self, label="--", size=(50,15))
sizer.Add(self.indicator, 0, wx.LEFT, 10)
self.SetSizerAndFit(sizer)
self.slider.Bind(wx.EVT_SCROLL, self.update)
self.update(None)

def update(self, evt):
""" Send OSC messages """
value=float(self.slider.GetValue())
sendOSCMsg("/test", [value])
value=self.slider.GetValue()/100.
if self.show_value:
self.indicator.SetLabel("%s" % value)
try:
sendOSCMsg("/test", [value])
except OSCClientError:
pass

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

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

self.gain=OSCSlider(self, "Gain", default_value=.5, show_value=False, align=False)
sizer.Add(self.gain, 1, wx.ALL, 5)
self.thru=OSCSlider(self, "Thru", default_value=.5, show_value=False, align=False)
sizer.Add(self.thru, 1, wx.ALL, 5)

self.button=wx.Button(self, 1, "Kill input")
sizer.Add(self.button, 0)
self.SetSizerAndFit(sizer)


class MainGUI(wx.Frame):
@@ -31,19 +61,28 @@ class MainGUI(wx.Frame):

def build(self):
""" Builds the various pieces of the GUI """
wx.Frame.__init__(self, None, title="Controls", size=(500,100))
wx.Frame.__init__(self, None, title="DELAY LORD")
self.Bind(wx.EVT_CLOSE, self.quit)

# The main sizer
self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
self.mainsizer = wx.BoxSizer(wx.VERTICAL)

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)

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.slider=OSCSlider(self, "Input gain", default_value=50)
self.mainsizer.Add(self.slider, 1, 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)
self.Show()
self.SetSize((700,500))
self.SetSize((400,500))


def populate_left_panel(self):


+ 4
- 1
run.sh Datei anzeigen

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


Laden…
Abbrechen
Speichern