new processing example

master
Rob Canning 2023-01-20 13:22:57 +01:00
parent 8e3e1bfda0
commit 1274cc4e0d
2 changed files with 56 additions and 16 deletions

View File

@ -36,7 +36,8 @@ https://sc-users.bham.ac.narkive.com/75iSw2f6/sending-osc-commands-instead-of-tr
( (
Event.addEventType(\processingOSC, { | server | Event.addEventType(\processingOSC, { | server |
var processingOscServer = NetAddr("127.0.0.1", 47120); var processingOscServer = NetAddr("192.168.178.166", 47120);
//var processingOscServer = NetAddr("127.0.0.1", 47120);
var notes = [~midinote.value, ~ctranspose.value, ~velocity.value, var notes = [~midinote.value, ~ctranspose.value, ~velocity.value,
~sustain.value, ~lag.value, ~timingOffset.value].flop; ~sustain.value, ~lag.value, ~timingOffset.value].flop;
@ -44,12 +45,12 @@ Event.addEventType(\processingOSC, { | server |
var timeNoteOn, timeNoteOff; var timeNoteOn, timeNoteOff;
//processingOscServer.sendMsg("/test",200.rand,200.rand); //processingOscServer.sendMsg("/test",200.rand,200.rand);
processingOscServer.sendMsg("/sc3p5",200.rand, 200.rand); //processingOscServer.sendMsg("/sc3p5",200.rand, 200.rand);
processingOscServer.sendMsg("/col", 255.rand); // n.sendMsg("/sc3p5", i.asFloat); // send OSC message to P5
notes.do {|note| notes.do {|note|
processingOscServer.sendMsg("/sc3p5", rrand(1,256).asFloat); processingOscServer.sendMsg("/mother1", 1920.rand);
processingOscServer.sendMsg("/mother2", 1080.rand);
//processingOscServer.sendMsg("/sc3p5", rrand(1,256).asFloat);
// sustain and timingOffset are in beats, lag is in seconds // sustain and timingOffset are in beats, lag is in seconds
//timeNoteOn = (thisThread.clock.tempo.reciprocal*note[5])+note[4]; //timeNoteOn = (thisThread.clock.tempo.reciprocal*note[5])+note[4];
@ -63,14 +64,19 @@ Event.addEventType(\processingOSC, { | server |
}); });
) )
( ( Pdef(\processingA, Pbind(*[ type: \processingOSC,
Pbind(*[ dur: 1/8, degree: [2,5,12], ]); ))
type: \processingOSC,
legato: Pgauss(0.2,0.05,inf), ( Pdef(\processingB, Pbind(*[ type: \processingOSC,
dur: 1/8, dur: 1/8, degree: [2,5,12], ]); ))
degree: [2,5,12],
ctranspose: Pseq([0,0,0,0,4,4,4,4,5,5,5,5],inf),
velocity: Pgauss(64,10,inf), Pdef(\processingA).play(quant: 4); // TOP MOTHER
]).play(quant: 4); Pdef(\processingA).stop;
) Pdef(\processingB).play(quant: 4); // TOP MOTHER
Pdef(\processingB).stop;

View File

@ -0,0 +1,34 @@
import oscP5.*;
import netP5.*;
OscP5 oscP5;
float x; // global variable
void setup() {
size(400, 300);
frameRate(24);
background(0);
smooth();
OscProperties properties = new OscProperties();
properties.setListeningPort(47120); // osc receive port (from sc)
oscP5 = new OscP5(this, properties);
}
void oscEvent(OscMessage msg) {
if (msg.checkAddrPattern("/sc3p5")) {
x = msg.get(0).floatValue(); // receive floats from sc
}
}
void draw() {
background(x, x, x);
println("POST: ", x);
// draw rect
stroke(256-x/2, 256-x*abs(sin(x)), 256-x/4);
strokeWeight(4);
fill(256-x/2, 256-x, 256-x*abs(sin(x)));
translate(width/2, height/2);
rotate(x%64);
rect(x%64, x%64, x*abs(sin(x))%128, x*abs(sin(x))%128, 6);
}