Pārlūkot izejas kodu

Some responsiveness

tags/kitchen
Pete Shadbolt pirms 3 gadiem
vecāks
revīzija
f348c4fe69
2 mainītis faili ar 15 papildinājumiem un 10 dzēšanām
  1. +9
    -8
      audio.scd
  2. +6
    -2
      radio.py

+ 9
- 8
audio.scd Parādīt failu

@@ -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 Parādīt failu

@@ -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))):


Notiek ielāde…
Atcelt
Saglabāt