-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualising_again.pde
103 lines (85 loc) · 2.57 KB
/
visualising_again.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
import processing.opengl.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import java.util.LinkedList;
Minim minim;
BeatDetect beat;
FFT fftMain;
AudioSource currentAudioSource = new AudioSource();
int bufferSize = 1024;
float sampleRate = 44100.0f;
final MidiInterface midiInterface = MidiInterface.getInstance();;
ArrayList<Feature> features = new ArrayList<Feature>();
void setup() {
// base setup
//size(displayWidth, displayHeight, P3D);
size(1280, 1024, P3D);
//fullScreen(P3D, 0);
surface.setResizable(false);
frameRate(30);
colorMode(HSB, 360, 100, 100, 100);
// audio input
minim = new Minim(this);
AudioInput input;
input = minim.getLineIn(Minim.STEREO, bufferSize);
currentAudioSource.useAudioInput(input);
// features //
fftMain = new FFT (input.bufferSize (), input.sampleRate ());
fftMain.logAverages(9, 30);
beat = new BeatDetect(bufferSize, sampleRate);
beat.setSensitivity(300);
CameraController camera = new CameraController(this, midiInterface, -1);
camera.enableFeature();
features.add(camera);
VideoPlayer videoPlayer = new VideoPlayer(this, midiInterface, 15);
features.add(videoPlayer);
VideoEffectController vidFX = new VideoEffectController(this, midiInterface, 18) ;
features.add(vidFX);
Waveform wave = new Waveform(this, midiInterface, 3);
wave.enableFeature();
midiInterface.setControlLED(3, true);
features.add(wave);
Spectro spectro = new Spectro(this, midiInterface, 6);
features.add(spectro);
BeatVertex beatVertex = new BeatVertex(this, midiInterface, 9);
features.add(beatVertex);
BeatBoxes beatBoxes = new BeatBoxes(this, midiInterface, 12);
features.add(beatBoxes);
PostFXController postFX = new PostFXController(this, midiInterface, 21) ;
features.add(postFX);
//VideoRecorder videoRecorder = new VideoRecorder(this, midiInterface, 24);
//features.add(videoRecorder);
}
private int currentRun = 0;
void draw() {
currentRun++;
if (currentRun == 800) {
currentRun = 0;
}
if (frameRate < 25) {
midiInterface.setControlLED(22, true);
} else {
midiInterface.setControlLED(22, false);
}
background(0);
lights();
beat.detect(currentAudioSource.getBufferForCenter());
fftMain.forward(currentAudioSource.getBufferForCenter());
// draw features
for (Feature feature : features) {
if (feature.isEnabled()) {
pushStyle();
feature.drawFeature(currentRun);
popStyle();
}
}
}
void keyPressed() {
if (key == CODED) {
for (Feature feature : features) {
if (feature.isEnabled()) {
feature.keyPressed(keyCode);
}
}
}
}