Ok, sorry I wasn’t very clear.
I’m using Sc to send to Processing data from the patterns.
I’m doing so because, in Sc 3.9.3 I can’t use the DMX quark GitHub - supercollider-quarks/DMX: A set of classes to interface with DMX devices to send and receive the DMX lightning protocol. Note: not all of this code is tested to work. Sc can’t see my ENTTEC dmxusb pro.
Anyway, I decided to use Processing via OSC and it works.
I’m using a 6 channels dimmer with 6 lightbulbs (PROEL PLDM6KN)
In processing I have :
import oscP5.*;
import netP5.*;
import dmxP512.*;
import processing.serial.*;
//OSC
OscP5 oscP5;
NetAddress myRemoteLocation;
//DMX
DmxP512 dmxOutput;
int universeSize=128;
boolean LANBOX=false;
String LANBOX_IP="192.168.1.77";
boolean DMXPRO=true;
String DMXPRO_PORT="COM4";//case matters ! on windows port must be upper cased.
int DMXPRO_BAUDRATE=115000;
// GRIGLIA..
int w = 100, h = w, offset = 5, green=0;
//float[] oscColors;
float oscColors0, oscColors1, oscColors2, oscColors3, oscColors4, oscColors5= 100;
void setup() {
size(600, 50);
// listen
oscP5 = new OscP5(this, 12000);
myRemoteLocation = new NetAddress("127.0.0.1", 12000);
dmxOutput=new DmxP512(this, universeSize, false);
if (LANBOX) {
dmxOutput.setupLanbox(LANBOX_IP);
}
if (DMXPRO) {
dmxOutput.setupDmxPro(DMXPRO_PORT, DMXPRO_BAUDRATE);
}
}
void draw() {
background(126, 126, 126);
//frameRate(60);
noStroke();
// CANALE 1
fill(0, oscColors0, 0);
rect( 0, 0, w, h);
dmxOutput.set(1, int(oscColors0));
// CANALE 2
fill(0, oscColors1, 0);
rect( 100, 0, w, h);
dmxOutput.set(2, int(oscColors1));
// CANALE 3
fill(0, oscColors2, 0);
rect( 200, 0, w, h);
dmxOutput.set(3, int(oscColors2));
// CANALE 4
fill(0, oscColors3, 0);
rect( 300, 0, w, h);
dmxOutput.set(4, int(oscColors3));
// CANALE 5
fill(0, oscColors4, 0);
rect( 400, 0, w, h);
dmxOutput.set(5, int(oscColors4));
// CANALE 6
fill(0, oscColors5, 0);
rect( 500, 0, w, h);
dmxOutput.set(6, int(oscColors5));
}
// RECEIVE AN ARRAY and split it with get..
void oscEvent(OscMessage theOscMessage) {
oscColors0 = theOscMessage.get(0).intValue();
oscColors1 = theOscMessage.get(1).intValue();
oscColors2 = theOscMessage.get(2).intValue();
oscColors3 = theOscMessage.get(3).intValue();
oscColors4 = theOscMessage.get(4).intValue();
oscColors5 = theOscMessage.get(5).intValue();
println(oscColors0, " Sono OSC color 0");
}
I’m moving the first steps in this kind of communication using the patterns to control something that is not a SynthDef.
I was trying
// OscSender~
~n1 = NetAddr("127.0.0.1", 12000);
(
~n1.sendMsg('/test',100,100,100,100,100,100);
)
//OFF turn off the lights
(
~n1.sendMsg('/test',0,0,0,0,0,0);
)
// trivial Example
(
Pbindef(\singMultiSEQ,
\stretch,1,
\seq1, Pseq([100,0],inf),
\seq2, Pseq([100,0],inf),
\seq3, Pseq([100,0],inf),
\seq4, Pseq([100,0],inf),
\seq5, Pseq([100,0],inf),
\seq6, Pseq([100,0],inf),
\bla, Pfunc {|e| ~n1.sendMsg('/test',
e[\seq1],
e[\seq2],
e[\seq3],
e[\seq4],
e[\seq5],
e[\seq6],
) },
\dur,Pseq([~metroBase.tempo],inf)// ~metroBase is just a general metro im referring to
).play(~metroBase,quant:[~metroBase.timeToNextBeat,0]);
)
(
Pbindef(\singMultiSEQ).stop;
~n1.sendMsg('/test',0,0,0,0,0,0);
)
it’s super simple and it works, in this way I can write all the sequences indipendently,
and every \seq is related to a channel in Processing and in the dimmer.
Pseq([100,0],inf)
Now I was trying to find a way to route a single sequence, for instance a Pseq([100, 0],inf),
to every element of the array one after the other:
e[\seq1],
e[\seq2],
e[\seq3],
e[\seq4],
e[\seq5],
e[\seq6]
it would be nice to have the Pseq([100,0],inf) turn On the first light, then turn it off and switch to the second light and repeat the same action untill the end of the array and start again.
Like a first step it could be nice just to find a way to make it works.
Hope now it’s clearer.
If anyone have an hint, it would be really appreciated.
Thanks
ps:
I just found a way to do it with a routine
(
r = Routine({
6.do({
|i|
~c = [100,0,0,0,0,0].permute(i);
~n1.sendMsg('/test',~c[0],~c[1],~c[2],~c3],~c[4],~c[5]);
~metroBase.tempo.yield;
~n1.sendMsg('/test',0,0,0,0,0,0); // turn all OFF
})
}).reset.play(~metroBase,quant:[~metroBase.timeToNextBeat,0]);
)