add files
This commit is contained in:
parent
879261cd7e
commit
a7fe0f86d8
41
DMX_TEST/DMX_TEST.pde
Normal file
41
DMX_TEST/DMX_TEST.pde
Normal file
@ -0,0 +1,41 @@
|
||||
import processing.serial.*;
|
||||
|
||||
Serial arduino;
|
||||
|
||||
void setup() {
|
||||
size(700, 600);
|
||||
println(Serial.list()[0]);
|
||||
String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
|
||||
arduino = new Serial(this, portName, 9600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
if (mousePressed == true)
|
||||
{
|
||||
if (mouseX >= 0 && mouseX <= 200){
|
||||
arduino.write("1c255w");
|
||||
} else if (mouseX >= 200 && mouseX <= 400){
|
||||
arduino.write("2c255w");
|
||||
}
|
||||
else if (mouseX >= 400 && mouseX <= 600){
|
||||
arduino.write("3c255w");
|
||||
}
|
||||
else if (mouseX >= 600 && mouseX <= 700){
|
||||
arduino.write("1c255w");
|
||||
arduino.write("2c255w");
|
||||
arduino.write("3c255w");
|
||||
}
|
||||
} else {
|
||||
arduino.write("1c0w");
|
||||
arduino.write("2c0w");
|
||||
arduino.write("3c0w");
|
||||
}
|
||||
fill(255, 0, 0);
|
||||
rect(0, 0, 200, 600);
|
||||
fill(0, 255, 0);
|
||||
rect(200, 0, 200, 600);
|
||||
fill(0, 0, 255);
|
||||
rect(400, 0, 200, 600);
|
||||
fill(255, 255, 255);
|
||||
rect(600, 0, 100, 600);
|
||||
}
|
65
audio_reactive/audio_reactive.pde
Normal file
65
audio_reactive/audio_reactive.pde
Normal file
@ -0,0 +1,65 @@
|
||||
import processing.sound.*;
|
||||
import processing.serial.*;
|
||||
|
||||
int NUM_LIGHTS = 3;
|
||||
|
||||
FFT fft;
|
||||
AudioIn in;
|
||||
int bands = 4;
|
||||
float[] spectrum = new float[bands];
|
||||
|
||||
Serial arduino;
|
||||
|
||||
void setup() {
|
||||
size(600, 300);
|
||||
background(255);
|
||||
|
||||
frameRate(14);
|
||||
// Create an Input stream which is routed into the Amplitude analyzer
|
||||
fft = new FFT(this, bands);
|
||||
in = new AudioIn(this, 0);
|
||||
|
||||
// start the Audio Input
|
||||
in.start();
|
||||
|
||||
// patch the AudioIn
|
||||
fft.input(in);
|
||||
|
||||
String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
|
||||
arduino = new Serial(this, portName, 9600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
fft.analyze(spectrum);
|
||||
|
||||
for (int i = 0; i < bands; i++) {
|
||||
// The result of the FFT is normalized
|
||||
// draw the line for frequency band i scaling it up by 5 to get more amplitude.
|
||||
if (i == 0) {
|
||||
fill(255, 0, 0);
|
||||
int val = (int)map(spectrum[i], 0, 1, 0, 255);
|
||||
for (int k = 0; k < NUM_LIGHTS; k++){
|
||||
int channel = 1 + (k * 3);
|
||||
arduino.write(channel+"c" + val + "w");
|
||||
}
|
||||
|
||||
} else if (i == 1) {
|
||||
int val = (int)map(spectrum[i], 0, 1, 0, 255);
|
||||
val = val*2;
|
||||
fill(0, 255, 0);
|
||||
for (int k = 0; k < NUM_LIGHTS; k++){
|
||||
int channel = 2 + (k * 3);
|
||||
arduino.write(channel+"c" + val + "w");
|
||||
}
|
||||
} else if (i == 2) {
|
||||
int val = (int)map(spectrum[i], 0, 1, 0, 255);
|
||||
fill(0, 0, 255);
|
||||
for (int k = 0; k < NUM_LIGHTS; k++){
|
||||
int channel = 3 + (k * 3);
|
||||
arduino.write(channel+"c" + val + "w");
|
||||
}
|
||||
}
|
||||
rect(i * 200, 0, 200, spectrum[i] * height);
|
||||
}
|
||||
}
|
53
audio_reactive_3light/audio_reactive_3light.pde
Normal file
53
audio_reactive_3light/audio_reactive_3light.pde
Normal file
@ -0,0 +1,53 @@
|
||||
import processing.sound.*;
|
||||
import processing.serial.*;
|
||||
|
||||
|
||||
FFT fft;
|
||||
AudioIn in;
|
||||
int bands = 4;
|
||||
float[] spectrum = new float[bands];
|
||||
|
||||
Serial arduino;
|
||||
|
||||
void setup() {
|
||||
size(600, 300);
|
||||
background(255);
|
||||
|
||||
frameRate(14);
|
||||
// Create an Input stream which is routed into the Amplitude analyzer
|
||||
fft = new FFT(this, bands);
|
||||
in = new AudioIn(this, 0);
|
||||
|
||||
// start the Audio Input
|
||||
in.start();
|
||||
|
||||
// patch the AudioIn
|
||||
fft.input(in);
|
||||
|
||||
String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
|
||||
arduino = new Serial(this, portName, 9600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
fft.analyze(spectrum);
|
||||
|
||||
for (int i = 0; i < bands; i++) {
|
||||
// The result of the FFT is normalized
|
||||
// draw the line for frequency band i scaling it up by 5 to get more amplitude.
|
||||
if (i == 0) {
|
||||
fill(255, 0, 0);
|
||||
int val = (int)map(spectrum[i], 0, 1, 0, 255);
|
||||
arduino.write("1c" + val + "w");
|
||||
} else if (i == 1) {
|
||||
int val = (int)map(spectrum[i], 0, 1, 0, 255);
|
||||
fill(0, 255, 0);
|
||||
arduino.write("5c" + val*2 + "w");
|
||||
} else if (i == 2) {
|
||||
int val = (int)map(spectrum[i], 0, 1, 0, 255);
|
||||
fill(0, 0, 255);
|
||||
arduino.write("9c" + val*3 + "w");
|
||||
}
|
||||
rect(i * 200, 0, 200, spectrum[i] * height);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user