Skip to content

Commit

Permalink
removed dependence on hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelforrest committed Jan 24, 2009
1 parent 57b9152 commit 9966087
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/Applications/Processing.app/Contents/Resources/Java/core.jar"/>
<classpathentry kind="lib" path="/Grimonium/src/rwmidi"/>
<classpathentry kind="lib" path="/Applications/Processing.app/Contents/Resources/Java/libraries/rwmidi/library/rwmidi.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
6 changes: 5 additions & 1 deletion src/microkontrol/MicroKontrol.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class MicroKontrol {
PApplet applet;
public final String VERSION = "0.1.0";

private MicroKontrolHardware hardware;
private MicroKontrolDevice hardware;

public Pad[] pads = new Pad[16];
public Hashtable<String, Button> buttons = new Hashtable<String, Button>();
Expand Down Expand Up @@ -91,13 +91,17 @@ public MicroKontrol(PApplet applet) {
"MicroKontrolHardware.input_device_b = \"" + MicroKontrolHardware.input_device_b + "\";\n" +
"MicroKontrolHardware.output_device = \"" + MicroKontrolHardware.output_device + "\";");
PApplet.println("\nNote that you can still use the MicroKontrol class as normal even if the hardware unit is not connected.");
hardware = new MicroKontrolHardwareStub(applet);
}

go();
}
public void plugKeyboard(Object object){
hardware.plugKeyboard(object);
}
public void plugPitchBend(Object object){
hardware.plugPitchBend(object);
}
void go() {
main.setText("");
main.setColor("red");
Expand Down
9 changes: 9 additions & 0 deletions src/microkontrol/MicroKontrolDevice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package microkontrol;

public interface MicroKontrolDevice {

void plugKeyboard(Object object);

void plugPitchBend(Object object);

}
13 changes: 9 additions & 4 deletions src/microkontrol/MicroKontrolHardware.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import rwmidi.RWMidi;
import rwmidi.SysexMessage;

public class MicroKontrolHardware {
public class MicroKontrolHardware implements MicroKontrolDevice {
public static String input_device_a = "PORT A(.*)KORG INC.";
public static String input_device_b = "PORT B(.*)KORG INC.";
public static String output_device = "CTRL(.*)KORG INC.";
Expand Down Expand Up @@ -352,9 +352,6 @@ void setupIO() {
send(PACKET4);
}

void plugKeyboard(Object to) {
inputB.plug(to);
}

/**
* MIDI IN
Expand Down Expand Up @@ -392,4 +389,12 @@ private static String findInArray(String regex, String[] array) {
private static String findInput(String regex) {
return findInArray(regex, RWMidi.getInputDeviceNames());
}
public void plugPitchBend(Object object) {
inputB.plug(object,"pitchBendReceived");

}
public void plugKeyboard(Object to) {
inputB.plug(to);
}

}
18 changes: 18 additions & 0 deletions src/microkontrol/MicroKontrolHardwareStub.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package microkontrol;

import processing.core.PApplet;

public class MicroKontrolHardwareStub implements MicroKontrolDevice {

public MicroKontrolHardwareStub(PApplet applet) {
}

public void plugKeyboard(Object object) {

}

public void plugPitchBend(Object object) {

}

}
1 change: 1 addition & 0 deletions src/microkontrol/controls/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private void dispatchTo(ArrayList<CallBack> handlers) {
}
public void release(){
dispatchToListeners(RELEASED);
dispatchTo(releaseHandlers);
}


Expand Down
3 changes: 3 additions & 0 deletions src/microkontrol/controls/Joystick.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

public class Joystick extends Observable {

private static final String MOVED = "moved";
private float x;
private float y;

public void set(float x, float y) {
this.x = x;
this.y = y;
setChanged();
notifyObservers(MOVED);
}

public float getX() {
Expand Down

0 comments on commit 9966087

Please sign in to comment.