1 class GenericController {
3 public void RotateKnob(int type, int num, float val){
6 p = glucose.getPattern().getParameters().get(num);
7 if(p!=null) { p.setValue(val); }
10 p = glucose.getSelectedTransition().getParameters().get(num);
11 if(p!=null) { p.setValue(val); }
14 p = glucose.getSelectedEffect().getParameters().get(num);
15 if(p!=null) { p.setValue(val); }
20 class MidiController extends GenericController {
25 //PApplet xparent; // be sure to set
31 //listener = new OscP5(this,7022);
33 //boolean[] noteState = new boolean[16];
35 //void controllerChangeReceived(rwmidi.Controller cc) {
37 // println("CC: " + cc.toString());
40 // for(int i=0; i<16; i++){
41 // if(noteState[i] && i<8) { LXParameter p = glucose.getPattern().getParameters().get(i); p.setValue(cc.getValue()/127.0); }
42 // else if(noteState[i] && i<12) { LXParameter p = glucose.getSelectedTransition().getParameters().get(i-8); p.setValue(cc.getValue()/127.0); }
43 // else if(noteState[i] && i<16) { LXParameter p = glucose.getSelectedEffect().getParameters().get(i-12); p.setValue(cc.getValue()/127.0); }
48 //void noteOnReceived(Note note) {
50 // println("Note On: " + note.toString());
52 // int pitch = note.getPitch();
53 // if(pitch>=36 && pitch <36+16){
54 // noteState[pitch-36]=true;
58 //void noteOffReceived(Note note) {
60 // println("Note Off: " + note.toString());
62 // int pitch = note.getPitch();
63 // if(pitch>=36 && pitch <36+16){
64 // noteState[pitch-36]=false;
68 //void oscEvent(OscMessage theOscMessage) {
69 // println(theOscMessage);
70 // LXPattern currentPattern = lx.getPattern();
71 // if (currentPattern instanceof OSCPattern) {
72 // ((OSCPattern)currentPattern).oscEvent(theOscMessage);
78 class ObjectMuckerEffect extends SCEffect {
79 ObjectMuckerEffect(GLucose glucose) {
82 public void apply(int[] colors){
83 /*for(Strip s: model.strips){
84 for(int i=0; i<s.points.size(); i++){
85 int index = s.points.get(i).index;
86 color c = colors[index];
87 colors[index] = lx.hsb((i*22.5), saturation(c), brightness(c));
93 class BlendFrames extends SCEffect {
98 BlendFrames(GLucose glucose) {
103 frames = new int[maxfbuf][];
104 for(int i=0; i<maxfbuf; i++){
105 frames[i] = new int[model.points.size()];
108 public void apply(int[] colors) {
110 for(int i=0; i<colors.length; i++){
111 frames[(maxfbuf-1)-fcount][i]=colors[i];
116 for(int i=maxfbuf-1; i>0; i--){
117 frames[i] = frames[i-1];
119 frames[0] = new int[model.points.size()];
121 for(int i=0; i<colors.length; i++){
124 for(int j=0; j<blendfactor; j++){
125 if(j==0) { frames[0][i] = colors[i]; }
126 r += ((frames[j][i] >> 16) & 0xFF);
127 g += ((frames[j][i] >> 8) & 0xFF);
128 b += ((frames[j][i] >> 0) & 0xFF);
134 colors[i] = (0xFF << 24) | (r << 16) | (g << 8) | b;
148 abstract class OSCPattern extends SCPattern {
149 public OSCPattern(GLucose glucose){super(glucose);}
150 public abstract void oscEvent(OscMessage msg);
161 class OSC_Balls extends OSCPattern {
163 public OSC_Balls(GLucose glucose){
165 balls = new Ball[20];
166 for(int i=0; i<balls.length; i++) { balls[i] = new Ball(); }
168 void oscEvent(OscMessage msg){
169 String pattern[] = split(msg.addrPattern(), "/");
170 int ballnum = int(pattern[3]);
171 balls[ballnum].lastSeen=millis();
172 balls[ballnum].x = msg.get(0).floatValue();
173 balls[ballnum].y = msg.get(1).floatValue();
176 void run(double deltaMs){
177 for(LXPoint p: model.points){ colors[p.index]=0; }
178 for(int i=1; i<balls.length; i++){
179 if(millis() - balls[i].lastSeen < 1000) {
180 for(LXPoint p: model.points){
181 int x = int(balls[i].x * 255.0);
182 int y = int(balls[i].y * 127.0);
183 if(p.x < x+4 && p.x > x-4 && p.y < y+4 && p.y > y-4) { colors[p.index] = #FF0000; }
190 import processing.serial.*;
193 /*class ScreenScrape extends SCPattern {
196 public ScreenScrape(GLucose glucose) {
198 System.loadLibrary("ScreenShot");
199 pret = new PImage(8, 128, ARGB);
200 ss = new ScreenShot();
202 void run(double deltaMs){
207 pret.pixels = ss.getScreenShotJNI2(x, y, w, h);
208 //for(int i=0; i<px.length; i++){ pret.pixels[i] = px[i]; }
209 //println(pret.get(10,10));
210 for(LXPoint p: model.points){
211 colors[p.index] = pret.get((int(p.x)/8)*8, 128-int(p.y));