Browse Source

Some responsiveness

tags/kitchen
Pete Shadbolt 3 years ago
parent
commit
f348c4fe69
2 changed files with 15 additions and 10 deletions
  1. +9
    -8
      audio.scd
  2. +6
    -2
      radio.py

+ 9
- 8
audio.scd View File

@@ -1,6 +1,6 @@
s = Server.local;
s.waitForBoot {
var module, sound, msg, modules;
var module, msg, modules;

// Connect to OSC
thisProcess.openUDPPort(5005);
@@ -34,21 +34,22 @@ s.waitForBoot {
// Create multiple sound generators
modules = [];
10.do({
16.do({
arg index;
var synth;
synth = Synth.new("module", [\hue, 0.5, \saturation, 0.1, \value, 0.5, \pan, 0.5, \gain, 0.2]);
synth = Synth.new("module", [\hue, 0.5, \saturation, 0.1, \value, 0.5, \pan, 0.5, \gain, 0.9]);
modules.add(synth);
});

// Hook up OSC
f = { |msg, time, addr|
if(msg[0] == '/radio') {
"Got data: % % % % %".postf(msg[1], msg[2], msg[3], msg[4], msg[5]);
sound.set("hue", msg[1]);
sound.set("saturation", msg[2]);
sound.set("value", msg[3]);
sound.set("pan", msg[4]);
"Got data: index: % hue: % sat: % value: % pan: %\n".postf(msg[1], msg[2], msg[3], msg[4], msg[5]);
modules[msg[1]].set(\hue, msg[2]);
modules[msg[1]].set(\saturation, msg[3]);
modules[msg[1]].set(\value, msg[4]);
modules[msg[1]].set(\pan, msg[5]);
s.sync;
}
};
thisProcess.addOSCRecvFunc(f);


+ 6
- 2
radio.py View File

@@ -26,8 +26,12 @@ def analyze_block(frame, osc, index, sp, ep):
h, s, v = cv2.cvtColor(average_color, cv2.COLOR_BGR2HSV)[0][0]

# Configure the oscillator
# osc.send_message("block/update", [int(x) for x in (index, h, s, v)])
osc.send_message("/goodbye", 1)
osc.send_message(
"/radio",
[int(index),
float(h / 255),
float(s / 255),
float(v / 255), .5])

# Draw the image
for thickness, color in ((3, (0, 0, 0)), (1, (255, 255, 255))):


Loading…
Cancel
Save