aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java2
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java35
2 files changed, 25 insertions, 12 deletions
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
index f6cebe2..713b5a4 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
@@ -107,7 +107,7 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
// Mixer mix = AudioSystem.getMixer(AudioSystem.getMixerInfo()[0]);
try {
- bag.connectToArduinos();
+ //bag.connectToArduinos();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java b/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java
index e7cbfba..6912f9c 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/examples/MidiSequencer.java
@@ -2,6 +2,7 @@ package uk.ac.open.punchingbag.examples;
import java.awt.Color;
+import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequence;
@@ -25,10 +26,13 @@ public class MidiSequencer implements ButtonListener, Runnable {
boolean[][] buttons = new boolean[8][20];
- String[] instrumentNames = { "Bass Drum", "Closed Hi-Hat", "Open Hi-Hat", "Acoustic Snare", "Crash Cymbal", "Hand Clap", "High Tom", "Hi Bongo", "Maracas",
- "Whistle", "Low Conga", "Cowbell", "Vibraslap", "Low-mid Tom", "High Agogo", "Open Hi Conga" };
+ String[] instrumentNames = { "Bass Drum", "Closed Hi-Hat", "Open Hi-Hat",
+ "Acoustic Snare", "Crash Cymbal", "Hand Clap", "High Tom",
+ "Hi Bongo", "Maracas", "Whistle", "Low Conga", "Cowbell",
+ "Vibraslap", "Low-mid Tom", "High Agogo", "Open Hi Conga" };
- int[] instruments = { 35, 42, 46, 38, 49, 39, 50, 60, 70, 72, 64, 56, 58, 47, 67, 63 };
+ int[] instruments = { 35, 42, 46, 38, 49, 39, 50, 60, 70, 72, 64, 56, 58,
+ 47, 67, 63 };
public MidiSequencer() {
bag.addButtonListener(this);
@@ -37,15 +41,24 @@ public class MidiSequencer implements ButtonListener, Runnable {
}
public void setUpMidi() {
- try {
- sequencer = MidiSystem.getSequencer();
- sequencer.open();
- sequence = new Sequence(Sequence.PPQ, 4);
- track = sequence.createTrack();
- sequencer.setTempoInBPM(120);
+ MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
+ if (devices.length == 0) {
+ System.out.println("No MIDI devices found");
+ } else {
+ for (MidiDevice.Info dev : devices) {
+ System.out.println(dev);
+ }
- } catch (Exception e) {
- e.printStackTrace();
+ try {
+ sequencer = MidiSystem.getSequencer();
+ sequencer.open();
+ sequence = new Sequence(Sequence.PPQ, 4);
+ track = sequence.createTrack();
+ sequencer.setTempoInBPM(120);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
} // close method