-
Notifications
You must be signed in to change notification settings - Fork 0
/
twinklr_pde.pde
90 lines (69 loc) · 1.73 KB
/
twinklr_pde.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
import de.looksgood.ani.*;
// import processing.io.*;
Stave stave;
PlayheadManager playheadManager;
Playhead playhead;
Soundbox soundbox;
Midibox midibox;
PImage loadingImg;
boolean loaded = false;
PFont deja;
void setup() {
size(800, 480);
//fullScreen();
//noCursor();
smooth();
loadingImg = loadImage("twinklr-loading.jpg");
deja = createFont("deja.ttf",14);
background(loadingImg);
// begin RPi mode
// GPIO.noInterrupts();
// delay(10);
// GPIO.pinMode(pinA, GPIO.INPUT);
// delay(10);
// GPIO.pinMode(pinB, GPIO.INPUT);
// delay(10);
// GPIO.releaseInterrupt(pinA);
// delay(10);
// GPIO.attachInterrupt(pinA, this, "updatePinA", GPIO.CHANGE);
// delay(10);
// GPIO.releaseInterrupt(pinB);
// delay(10);
// GPIO.attachInterrupt(pinB, this, "updatePinB", GPIO.CHANGE);
// delay(10);
// GPIO.interrupts();
// delay(10);
}
void draw() {
if(!loaded) {
Ani.init(this);
Ani.noAutostart();
int noteCount = 15;
midibox = new Midibox(this);
soundbox = new Soundbox(noteCount, midibox, this);
stave = new Stave(noteCount, soundbox, this);
playheadManager = new PlayheadManager(stave, this);
setupGui();
prepareExitHandler();
loaded = true;
}
background(255);
stave.render();
playheadManager.render();
stave.drawNotes();
playheadManager.playNotes();
for (int i = 0; i < bottomButtons.length; i++ ) {
bottomButtons[i].render();
}
}
private void prepareExitHandler () {
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run () {
System.out.println("SHUTDOWN HOOK");
// application exit code here
if(midibox.currentBusName != null) {
midibox.midiBus.clearAll();
}
}
}));
}