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