aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2011-10-10 09:54:45 +0100
committerChristopher Baines <cbaines8@gmail.com>2011-10-10 09:54:45 +0100
commitd8caaed9c7d52df463429d73c79bc6e81bcc12ee (patch)
treee0af3edae0b5670740db4f48a246063b84fc40fe
parentc34f84af6108c17cdf451a5162bf9fa9709d19f0 (diff)
downloadpunchingbag-d8caaed9c7d52df463429d73c79bc6e81bcc12ee.tar
punchingbag-d8caaed9c7d52df463429d73c79bc6e81bcc12ee.tar.gz
More midi changes. Need to improve the display of active ticks.
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java33
1 files changed, 19 insertions, 14 deletions
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java b/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java
index 6947778..e7cbfba 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java
@@ -58,9 +58,9 @@ public class MidiSequencer implements ButtonListener, Runnable {
for (int y = 0; y < bag.buttonHeight; y++) {
trackList = new int[bag.buttonWidth];
- int key =0;
+ int key = 0;
if (y < instruments.length) {
- key = instruments[y];
+ key = instruments[y];
} else {
// key = instruments[y - instruments.length];
}
@@ -80,7 +80,7 @@ public class MidiSequencer implements ButtonListener, Runnable {
track.add(makeEvent(192, 9, 1, 0, 15));
try {
sequencer.setSequence(sequence);
- //sequencer.setLoopCount(sequencer.LOOP_CONTINUOUSLY);
+ // sequencer.setLoopCount(sequencer.LOOP_CONTINUOUSLY);
sequencer.setLoopCount(1);
sequencer.start();
sequencer.setTempoInBPM(tempo);
@@ -138,23 +138,28 @@ public class MidiSequencer implements ButtonListener, Runnable {
}
+ private void draw(int tick) {
+ bag.clearLEDs();
+ bag.fillRect(tick, 0, 2, bag.ledHeight, Color.green);
+ for (int x = 0; x < bag.buttonWidth; x++) {
+ for (int y = 0; y < bag.buttonHeight; y++) {
+ if (buttons[x][y]) {
+ // bag.fillRect(x, y, 2, 2, Color.red);
+ bag.setLED(x, y, Color.red);
+ bag.setLED(x + 1, y + 1, Color.red);
+ }
+ }
+ }
+ }
+
@Override
public void run() {
while (true) {
buildTrackAndStart();
try {
for (int x = 0; x < 8; x++) {
- bag.fillRect(x, 0, 2, 8, Color.green);
- for (int y = 0; y < bag.buttonHeight; y++) {
- if (buttons[x][y])
- bag.fillRect(x, y, 2, 2, Color.red);
- }
- Thread.sleep(60000 / 120 / 4);
- bag.fillRect(x, 0, 2, 8, Color.white);
- for (int y = 0; y < bag.buttonHeight; y++) {
- if (buttons[x][y])
- bag.fillRect(x, y, 2, 2, Color.red);
- }
+ draw(x);
+ Thread.sleep(60000 / 120 / 2);
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block