Implement pattern knobs here
[SugarCubes.git] / _Internals.pde
CommitLineData
49815cc0
MS
1/**
2 * If you are an artist, you may ignore this file! It just sets
3 * up the framework to run the patterns. Should not need modification
4 * for general animation work.
5 */
6
7import glucose.*;
8import glucose.control.*;
3f8be614 9import glucose.effect.*;
49815cc0
MS
10import glucose.pattern.*;
11import glucose.transition.*;
12import glucose.model.*;
13import heronarts.lx.*;
3f8be614 14import heronarts.lx.control.*;
49815cc0
MS
15import heronarts.lx.effect.*;
16import heronarts.lx.pattern.*;
17import heronarts.lx.modulator.*;
18import heronarts.lx.transition.*;
19import ddf.minim.*;
20import ddf.minim.analysis.*;
21import processing.opengl.*;
22import java.lang.reflect.*;
23
24final int VIEWPORT_WIDTH = 900;
25final int VIEWPORT_HEIGHT = 700;
26final int TARGET_FRAMERATE = 45;
27
28int startMillis, lastMillis;
29GLucose glucose;
30HeronLX lx;
31LXPattern[] patterns;
32LXTransition[] transitions;
33LXEffect[] effects;
34OverlayUI ui;
49815cc0
MS
35
36void setup() {
37 startMillis = lastMillis = millis();
38
39 // Initialize the Processing graphics environment
40 size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL);
41 frameRate(TARGET_FRAMERATE);
3f8be614 42 noSmooth();
49815cc0
MS
43 // hint(ENABLE_OPENGL_4X_SMOOTH); // no discernable improvement?
44 logTime("Created viewport");
45
46 // Create the GLucose engine to run the cubes
47 glucose = new GLucose(this);
48 lx = glucose.lx;
49 logTime("Built GLucose engine");
50
51 // Set the patterns
52 glucose.lx.setPatterns(patterns = patterns(glucose));
53 logTime("Built patterns");
54 glucose.lx.addEffects(effects = effects(glucose));
55 logTime("Built effects");
56 transitions = transitions(glucose);
57 logTime("Built transitions");
58
59 // Build overlay UI
60 ui = new OverlayUI();
61 logTime("Built overlay UI");
62
63 // MIDI devices
809f3518 64 SCMidiDevices.initializeStandardDevices(glucose, ui.patternKnobs, ui.transitionKnobs, ui.effectKnobs);
3f8be614 65 logTime("Setup MIDI devices");
49815cc0
MS
66
67 println("Total setup: " + (millis() - startMillis) + "ms");
68}
69
70void logTime(String evt) {
71 int now = millis();
72 println(evt + ": " + (now - lastMillis) + "ms");
73 lastMillis = now;
74}
75
76void draw() {
77 // The glucose engine deals with the core simulation here, we don't need
78 // to do anything specific. This method just needs to exist.
79}
80
81void drawUI() {
82 if (uiOn) {
83 ui.draw();
84 } else {
85 ui.drawHelpTip();
86 }
87 ui.drawFPS();
88}
89
90boolean uiOn = true;
3f8be614 91boolean knobsOn = true;
49815cc0 92void keyPressed() {
3f8be614
MS
93 switch (key) {
94 case 'u':
95 uiOn = !uiOn;
96 break;
97 case 'k':
98 knobsOn = !knobsOn;
99 break;
49815cc0
MS
100 }
101}
102
103