sudo apt-get install wireshark
sudo wireshark
# replace with your supercollider ide
scvim
(in IDE)
(
// This just dumps whatever SuperCollider is receiving
OSCFunc.trace(true);
)
Well, not much going on yet. Mash the evo's keyboard all you like, but SuperCollider isn't catching on.
And it wouldn't; the evo sends packets from 169.254.31.0 port 0 by default, so we're going to have to bend them around. Luckily, the evo can do DHCP, so the first part of our solution is getting a DHCP server going.
sudo apt-get install isc-dhcp-server
Then back up these config files and edit them to look like this:
# /etc/default/isc-dhcp-server
INTERFACES="eth0"
# /etc/dhcp/dhcpd.conf
option domain-name "home.lan";
option domain-name-servers ubuntu.home.lan;
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet 192.168.175.0 netmask 255.255.255.0 {
range 192.168.175.100 192.168.175.200;
option routers router.home.lan;
}
ddns-update-style none;
Then give yourself the static IP address 192.168.175.11 in Network Manager. To do so
# Restart the DHCP server
sudo /etc/init.d/isc-dhcp-server restart
Now turn the evo off and back on again, and stop and restart wireshark's listening on eth0. And, lo and behold, the evo is now sending from 192.168.175.100! Evo, you smart, smart machine.
But SuperCollider still isn't catching on. It must be the pesky port 0 the evo sends on. To my knowledge, there is no way to convince it not to do that, probably short of re-flashing the firmware, and messing with the Evo's firmware is not amongst my current desires. I spend too much time fussing with technology and not enough time being musically creative as it is, and I really don't want to spend any time wondering whether I bricked the thing or not.
Speaking of bricking, I did brick my web server once, using a handy linux web server bricking tool called iptables. It allows you to close, reject, re-route and rewrite pretty much any kind of traffic, including your own connection to your sever. Which is a good thing, because the danger also means power. It also runs in the kernel, so I assume it will add little latency (The kernel is part of the upper crust of the hegemony inside your computer, and, like any good autocrat it has all the connections needed to preferentially aquire resources). Could it be that this is the solution to our little port 0 problem? Well, in short, yes. Observe and bow to the mighty kernel (and don't worry, unlike most iptables commands, this one is actually not dangerous!)
# run as root, and also add to the beginning of /etc/rc.local
iptables -t nat -A PREROUTING -p udp --dport 0 -j REDIRECT --to-ports 57120
This takes all the udp traffic coming in on port 0, and rewrites it to port 57120, which is what SuperCollider likes to listen to by default. Yes, SuperCollider does have the this.openPort(1234); and this.openPorts; commands, but sclang does not seem intent to listen on port 0 under any circumstances. Correctly, I might add, in terms of networking standards. Good luck the kernel doesn't give a fuck.
And lo and behold, the messages are coming in!
OSC Message Received:
time: 1360186197.0399
address: a NetAddr(192.168.175.100, 4096)
recvPort: 57120
msg: [ /endeavour/evo110030/slider, 1, 0, 6 ]
OSC Message Received:
time: 1360186197.0531
address: a NetAddr(192.168.175.100, 4096)
recvPort: 57120
msg: [ /endeavour/evo110030/slider, 1, 0, 8 ]
OSC Message Received:
time: 1360186197.0601
address: a NetAddr(192.168.175.100, 4096)
recvPort: 57120
msg: [ /endeavour/evo110030/note, 1, 1, 37 ]
OSC Message Received:
time: 1360186197.0611
address: a NetAddr(192.168.175.100, 4096)
recvPort: 57120
msg: [ /endeavour/evo110030/slider, 1, 1, 3 ]
OSC Message Received:
time: 1360186197.0671
address: a NetAddr(192.168.175.100, 4096)
recvPort: 57120
msg: [ /endeavour/evo110030/slider, 1, 1, 2 ]
OSC Message Received:
time: 1360186197.0741
address: a NetAddr(192.168.175.100, 4096)
recvPort: 57120
msg: [ /endeavour/evo110030/slider, 1, 1, 0 ]
OSC Message Received:
time: 1360186197.3091
address: a NetAddr(192.168.175.100, 4096)
recvPort: 57120
msg: [ /endeavour/evo110030/note, 1, 0, 34 ]
And yeah, I do like writing 'lo and behold'. Lo and behold, I wrote lo and behold! Lo and behold, you can now turn the tracing off again.
(
OSCFunc.trace(false);
)
And this, nicely, also gives away how to work with the messages from SuperCollider. Here's some code that actually creates some decent sound pressing and sliding keys.
# Example SuperCollider synthdef and OSC-handler
# To start playing with the Endeavour Evo
# There's a few glitches with the slider handling
# that needs fixing but it will do as a demo.
# (c) 2013 Carlo Capocasa. MIT license applies.
(
s.waitForBoot({
(
SynthDef.new(\evosizer_sc, {
arg gate, key, velocity = 0, slider = 128;
var pitch,sound;
slider=slider * 0.0009765625;
slider=Lag.kr(slider,0.1);
key = if(key < 24, key, key+12);
pitch = DegreeToKey.kr(Scale.chromatic.as(LocalBuf),key,add:24).midicps;
sound = Saw.ar(pitch, 14*(1/pitch));
sound = RLPF.ar(sound, pitch * (0.9+ (32*slider)),0.25);
sound=sound*Linen.kr(gate, 0.02,1,0.02,2);
Out.ar(0, Pan2.ar(sound,0));
}).send(s);
)
});
{
var synths,note_responder,slide_responder;
synths= Array.newClear(48); // The evo has 48 keys
note_responder = OSCFunc.new({
arg msg;
var synth;
if (1==msg[2] && synths[msg[1]]==nil, {
synths[msg[1]] = Synth.new(\evosizer_sc, [gate: 1, key: msg[1], velocity: msg[3]], s);
},{
synths[msg[1]].set(\gate, 0);
synths[msg[1]] = nil;
});
}, "/endeavour/evo110030/note");
slide_responder=OSCFunc.new({
arg msg;
var synth = synths[msg[1]];
if (nil != synth) {
synth.set(\slider, msg[3]);
};
}, "/endeavour/evo110030/slider");
}.value;
)
Step-By-Step:
# run this
sudo apt-get install isc-dhcp-server
# Put this in/etc/default/isc-dhcp-server
INTERFACES="eth0"
# Put this in /etc/dhcp/dhcpd.conf
option domain-name "home.lan";
option domain-name-servers ubuntu.home.lan;
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet 192.168.175.0 netmask 255.255.255.0 {
range 192.168.175.100 192.168.175.200;
option routers router.home.lan;
}
ddns-update-style none;
# Then restart your dhcp server
sudo /etc/init.d/isc-dhcp-server restart
# run as root, and also add to the beginning of /etc/rc.local
iptables -t nat -A PREROUTING -p udp --dport 0 -j REDIRECT --to-ports 57120
# Run this in your SuperCollider IDE to make sure you are receiving the messages
OSCFunc.trace(true);
# Turn it back off
OSCFunc.trace(false);
See above for an example.