redo with new anti-GLucose
[SugarCubes.git] / DanKaminsky.pde
1 // class GenericController {
2 // GenericController(){}
3 // public void RotateKnob(int type, int num, float val){
4 // LXParameter p = null;
5 // if(type==0) {
6 // p = getPattern().getParameters().get(num);
7 // if(p!=null) { p.setValue(val); }
8 // }
9 // if(type==1) {
10 // p = lx.engine.getDeck(RIGHT_DECK).getFaderTransition().getParameters().get(num);
11 // if(p!=null) { p.setValue(val); }
12 // }
13 // if(type==2) {
14 // p = getSelectedEffect().getParameters().get(num);
15 // if(p!=null) { p.setValue(val); }
16 // }
17 // }
18 // }
19
20 // class MidiController extends GenericController {
21 // MidiController() {
22 // super();
23 // }
24 // }
25 // //PApplet xparent; // be sure to set
26
27
28
29 // OscP5 listener;
30 // // Setup OSC
31 // //listener = new OscP5(this,7022);
32
33 // //boolean[] noteState = new boolean[16];
34 // //
35 // //void controllerChangeReceived(rwmidi.Controller cc) {
36 // // if (debugMode) {
37 // // println("CC: " + cc.toString());
38 // // }
39 // // if(cc.getCC()==1){
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); }
44 // // }
45 // // }
46 // //}
47 // //
48 // //void noteOnReceived(Note note) {
49 // // if (debugMode) {
50 // // println("Note On: " + note.toString());
51 // // }
52 // // int pitch = note.getPitch();
53 // // if(pitch>=36 && pitch <36+16){
54 // // noteState[pitch-36]=true;
55 // // }
56 // //}
57 // //
58 // //void noteOffReceived(Note note) {
59 // // if (debugMode) {
60 // // println("Note Off: " + note.toString());
61 // // }
62 // // int pitch = note.getPitch();
63 // // if(pitch>=36 && pitch <36+16){
64 // // noteState[pitch-36]=false;
65 // // }
66 // //}
67 // //
68 // //void oscEvent(OscMessage theOscMessage) {
69 // // println(theOscMessage);
70 // // LXPattern currentPattern = lx.getPattern();
71 // // if (currentPattern instanceof OSCPattern) {
72 // // ((OSCPattern)currentPattern).oscEvent(theOscMessage);
73 // // }
74 // //}
75 // //
76
77
78 // class ObjectMuckerEffect extends LXEffect {
79 // ObjectMuckerEffect(LX lx) {
80 // super(lx);
81 // }
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));
88 // }
89 // }*/
90 // }
91 // }
92
93 // class BlendFrames extends LXEffect {
94 // int fcount;
95 // int frames[][];
96 // int maxfbuf;
97 // int blendfactor;
98 // BlendFrames(LX lx) {
99 // super(lx);
100 // maxfbuf = 30;
101 // blendfactor=30;
102 // fcount=0;
103 // frames = new int[maxfbuf][];
104 // for(int i=0; i<maxfbuf; i++){
105 // frames[i] = new int[model.points.size()];
106 // }
107 // }
108 // public void apply(int[] colors) {
109 // if(fcount<maxfbuf){
110 // for(int i=0; i<colors.length; i++){
111 // frames[(maxfbuf-1)-fcount][i]=colors[i];
112 // }
113 // fcount++;
114 // return;
115 // } else {
116 // for(int i=maxfbuf-1; i>0; i--){
117 // frames[i] = frames[i-1];
118 // }
119 // frames[0] = new int[model.points.size()];
120
121 // for(int i=0; i<colors.length; i++){
122 // int r,g,b;
123 // r=g=b=0;
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);
129 // }
130 // r/=blendfactor;
131 // g/=blendfactor;
132 // b/=blendfactor;
133 // colorMode(ARGB);
134 // colors[i] = (0xFF << 24) | (r << 16) | (g << 8) | b;
135 // colorMode(HSB);
136 // }
137
138 // }
139 // }
140 // }
141
142
143
144 // abstract class OSCPattern extends SCPattern {
145 // public OSCPattern(LX lx){super(lx);}
146 // public abstract void oscEvent(OscMessage msg);
147 // }
148
149 // class Ball {
150 // public int lastSeen;
151 // public float x,y;
152 // public Ball(){
153 // x=y=lastSeen=0;
154 // }
155 // }
156
157 // class OSC_Balls extends OSCPattern {
158 // Ball[] balls;
159 // public OSC_Balls(LX lx){
160 // super(lx);
161 // balls = new Ball[20];
162 // for(int i=0; i<balls.length; i++) { balls[i] = new Ball(); }
163 // }
164 // void oscEvent(OscMessage msg){
165 // String pattern[] = split(msg.addrPattern(), "/");
166 // int ballnum = int(pattern[3]);
167 // balls[ballnum].lastSeen=millis();
168 // balls[ballnum].x = msg.get(0).floatValue();
169 // balls[ballnum].y = msg.get(1).floatValue();
170 // }
171
172 // void run(double deltaMs){
173 // for(LXPoint p: model.points){ colors[p.index]=0; }
174 // for(int i=1; i<balls.length; i++){
175 // if(millis() - balls[i].lastSeen < 1000) {
176 // for(LXPoint p: model.points){
177 // int x = int(balls[i].x * 255.0);
178 // int y = int(balls[i].y * 127.0);
179 // if(p.x < x+4 && p.x > x-4 && p.y < y+4 && p.y > y-4) { colors[p.index] = #FF0000; }
180 // }
181 // }
182 // }
183 // }
184 // }
185
186 // import processing.serial.*;
187
188
189 // /*class ScreenScrape extends SCPattern {
190 // PImage pret;
191 // ScreenShot ss;
192 // public ScreenScrape(LX lx) {
193 // super(lx);
194 // System.loadLibrary("ScreenShot");
195 // pret = new PImage(8, 128, ARGB);
196 // ss = new ScreenShot();
197 // }
198 // void run(double deltaMs){
199 // int x=(1366/2)+516;
200 // int y=768-516;
201 // int w=8;
202 // int h=128;
203 // pret.pixels = ss.getScreenShotJNI2(x, y, w, h);
204 // //for(int i=0; i<px.length; i++){ pret.pixels[i] = px[i]; }
205 // //println(pret.get(10,10));
206 // for(LXPoint p: model.points){
207 // colors[p.index] = pret.get((int(p.x)/8)*8, 128-int(p.y));
208 // }
209 // }
210 // }*/
211