Just for the fun of it ....
Code: Select all
/*
this is a simple fader starter processing sketch by Zoltán Pálffy
for use with Resolume 4 and 5,
if you use this code to earn money, donate at http://programs.palffyzoltan.hu
distribute only with this header please.
you'll need the processing framework - https://processing.org
and Andreas Schlegel's oscP5, and NetP5 library - http://www.sojamo.de/libraries/oscP5/
this sketch will listen for clip launches in resolume, and layer opacity slider movement
if you move the layer opacity from 0 it will relauch the clip that is playing in the layer.
fader start.
*/
import netP5.*;
import oscP5.*;
int [] layerClip = new int [] {0, 0, 0, 0};
int [] layerMute = new int [] {0, 0, 0, 0};
OscP5 oscP5;
NetAddress myRemoteLocation;
void setup() {
size(400, 400);
frame.setTitle("FaderStarter for Resolume");
frameRate(25);
// start oscP5, listening for incoming messages at port 7001 set resolume OSC output to this port
oscP5 = new OscP5(this, 7001);
// set resolume OSC input to this port : 7000
// ip is localhost
myRemoteLocation = new NetAddress("127.0.0.1", 7000);
}
void draw() {
background(0);
try {
fill(200, 200, 250);
text("fader starter for Resolume - http://programs.palffyzoltan.hu", 10, 20);
for (int i=1; i< layerMute.length; i++) {
fill(200, 200, 50);
String addition = "";
if (layerMute[i] == 1) {
addition = " waiting for fader start";
fill(200, 100, 100);
}
if (layerClip[i] == 0)
{
fill(100);
text( "no clip playing in layer "+i, 10, i*20+20);
} else {
text("active clip in layer "+i+" : "+layerClip[i] + addition, 10, i*20+20);
}
}
}
catch(Exception e) {
}
}
int [] growIntArray (int [] in, int to) {
int [] ret = new int[to];
for (int i=0; i < ret.length; i++) {
if (i < in.length) ret[i] = in[i]; //copy existing
else ret[i] = 0; // fill others with 0
}
return ret;
}
void checkAndGrow(int layerNumber) {
if (layerNumber > layerMute.length) { // array too small to store this many layers
println(layerMute.length, "array needs to grow to ", layerNumber );
layerMute = growIntArray(layerMute, layerNumber + 1);
layerClip = growIntArray(layerClip, layerNumber + 1);
}
}
void oscEvent(OscMessage message) {
try {
String msg = message.addrPattern();
//look for layer opacity messages
if (match(msg, "/layer.*/video/opacity/values") != null) {
int layerNumber = Integer.parseInt(msg.replaceAll("/layer(\\d+)/video/opacity/values", "$1"));
checkAndGrow(layerNumber);
if (message.get(0).floatValue() == 0f) {
layerMute[layerNumber] = 1; // if layer opacity is set to 0 store that info
} else
if (layerMute[layerNumber] == 1) {
//relaunch clip
layerMute[layerNumber] = 0;
sendRelaunchToClip(layerNumber);
}
}
//look for clip launch messages
if (match(msg, "/layer.*/clip.*/connect") != null) {
int layerNumber = Integer.parseInt(msg.replaceAll("/layer(\\d+)/clip(\\d+)/connect", "$1"));
int clipNumber = Integer.parseInt(msg.replaceAll("/layer(\\d+)/clip(\\d+)/connect", "$2"));
int action = message.get(0).intValue();
checkAndGrow(layerNumber);
if (action == 1) {
layerClip[layerNumber] = clipNumber;
} else {
if (layerClip[layerNumber] == clipNumber) layerClip[layerNumber] = 0;
}
}
}
catch(Exception e) {
e.printStackTrace();
}
}
void sendRelaunchToClip(int layer) {
if (layerClip[layer] != 0 ) {
OscMessage myMessage = new OscMessage("/layer"+layer+"/clip"+layerClip[layer]+"/connect");
myMessage.add(1);
oscP5.send(myMessage, myRemoteLocation);
}
}
and for the lazy ones: you can get the binaries
on my website