-
Notifications
You must be signed in to change notification settings - Fork 1
/
motionLight.pde
149 lines (125 loc) · 3.17 KB
/
motionLight.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import processing.video.*;
import processing.sound.*;
//import gab.opencv.*;
//import peasy.PeasyCam;
Capture video;
AudioIn input;
Amplitude rms;
//OpenCV opencv;
//PeasyCam cam;
int frameNom = 10;
int videoScale = 20; // Size of each cell in the grid
int audioScale = 20;
int cols, rows, wwidth = 1280, hheight = 720; // Number of columns and rows in the system
int playMode = 1;
int tempSecond, bmp = 117, bmpMillis, passDownTemp, passDownTemp2;
float minWeight = videoScale * 0.05;
float maxWeight = videoScale * 0.75;
float threshold = videoScale * 0.6;
color strokeC;
PImage prev, output;
float motionX = 0, motionY = 0;
float lerpX = 0, lerpY = 0;
void setup() {
size(1280, 720);
//size(full);
//cam = new PeasyCam(this, 600);
// show which cameras available
//String[] cameras = Capture.list();
//printArray(cameras);
// Initialize columns and rows
cols = int(width / videoScale);
rows = int(height / videoScale);
// Construct the Capture object
video = new Capture(this, wwidth, hheight);
video.start();
prev = createImage(wwidth, hheight, RGB);
output = createImage(wwidth, hheight, RGB);
//Create an Audio input and grab the 1st channel
input = new AudioIn(this, 0);
input.start();
// create a new Amplitude analyzer
rms = new Amplitude(this);
rms.input(input);
tempSecond = millis();
passDownTemp = millis();
}
void mousePressed() {
}
void captureEvent(Capture video) {
prev.copy(video, 0, 0, video.width, video.height, 0, 0, prev.width, prev.height);
prev.updatePixels();
video.read();
motion();
timeTravel(motion);
}
void draw() {
//translate(-width/2.0, -height/2.0, 0);
background(0);
// analyze input audio to change pixel size
audioAnalysis();
//motion();
//if (playMode != 0) {
// if (manyFrames[frameNom-1] != null) {
// lightBulbArray(manyFrames);
// }
//}
pushMatrix();
if (playMode == 1) { // change pixel size based on music beats
mode1();
}
if (playMode == 2) { // single frame single color motion light bulb
mode2();
}
if (playMode == 3) { // single coclr, every other frame, alpha go down
mode3();
}
if (playMode == 4) { // rabow color motion light bulb
mode4();
}
if (playMode == 5) { // rabow color motion light bulb
mode5();
}
if (playMode == 6) { // rabow color motion light bulb
mode6();
}
// debug mode
if (playMode == 0) {
scale(0.5);
pushMatrix();
// no.1 image from motion
image(video, 0, 0);
//no.2 motion
translate(wwidth, 0);
image(motion, 0, 0);
popMatrix();
pushMatrix();
// no.3 light bulb from motion
translate(0, hheight);
strokeC = 255;
lightBulbArray(manyFrames);
// no.4 single frame light bulb
translate(wwidth, 0);
//showRainbowTravel();
//lightBulbEvery(manyFramesPerSecond);
popMatrix();
}
popMatrix();
if (keyPressed) {
if (key == '1') {
playMode = 1;
} else if (key == '2') {
playMode = 2;
} else if (key == '3') {
playMode = 3;
} else if (key == '4') {
playMode = 4;
} else if (key == '5') {
playMode = 5;
} else if (key == '6') {
playMode = 6;
} else {
playMode = 1;
}
}
}