[Japi-cvs] SF.net SVN: japi:[648] progs
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2008-10-06 12:48:32
|
Revision: 648
http://japi.svn.sourceforge.net/japi/?rev=648&view=rev
Author: christianhujer
Date: 2008-10-06 12:45:51 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
Added module for jirus prototype.
Added Paths:
-----------
progs/jirus/
progs/jirus/branches/
progs/jirus/tags/
progs/jirus/trunk/
progs/jirus/trunk/jirus.iml
progs/jirus/trunk/src/
progs/jirus/trunk/src/doc/
progs/jirus/trunk/src/prj/
progs/jirus/trunk/src/prj/net/
progs/jirus/trunk/src/prj/net/sf/
progs/jirus/trunk/src/prj/net/sf/jirus/
progs/jirus/trunk/src/prj/net/sf/jirus/Jirus.java
progs/jirus/trunk/src/prj/net/sf/jirus/MyReceiver.java
progs/jirus/trunk/src/tst/
Added: progs/jirus/trunk/jirus.iml
===================================================================
--- progs/jirus/trunk/jirus.iml (rev 0)
+++ progs/jirus/trunk/jirus.iml 2008-10-06 12:45:51 UTC (rev 648)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/doc" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/prj" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/tst" isTestSource="true" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="libs-argparser" />
+ <orderEntry type="library" name="annotations" level="project" />
+ <orderEntry type="library" name="junit" level="project" />
+ <orderEntry type="library" name="jlfgr-1_0" level="project" />
+ <orderEntry type="module" module-name="midi" />
+ <orderEntryProperties />
+ </component>
+</module>
+
Property changes on: progs/jirus/trunk/jirus.iml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:eol-style
+ LF
Added: progs/jirus/trunk/src/prj/net/sf/jirus/Jirus.java
===================================================================
--- progs/jirus/trunk/src/prj/net/sf/jirus/Jirus.java (rev 0)
+++ progs/jirus/trunk/src/prj/net/sf/jirus/Jirus.java 2008-10-06 12:45:51 UTC (rev 648)
@@ -0,0 +1,64 @@
+package net.sf.jirus;
+
+import java.util.List;
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Sequencer;
+import javax.sound.midi.SysexMessage;
+import javax.sound.midi.Transmitter;
+import net.sf.japi.io.args.ArgParser;
+import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.midi.MidiUtils;
+import org.jetbrains.annotations.NotNull;
+
+/** Jirus Main program.
+ * Jirus is a software for working with midi devices.
+ * It is especially designed for being used live, e.g. on stage.
+ *
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+// Requirements / Wishlist
+// - Allow more complex routing than just a simple keyboard split.
+// - Allow setups and have them changed dynamically during runtime.
+public class Jirus extends BasicCommand {
+
+ public static final int SPLIT_CHANNEL = 0x02;
+ public static final int SPLIT_KEY = 0x30;
+
+ public static final int MIDI_NOTE_RANGE = 128;
+
+ /** Main Program.
+ * @param args Command line arguments (try --help).
+ */
+ public static void main(@NotNull final String... args) {
+ ArgParser.simpleParseAndRun(new Jirus(), args);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"InstanceMethodNamingConvention"})
+ public int run(@NotNull final List<String> args) throws Exception {
+ final MidiDevice device1 = MidiUtils.getTransmittingDevice("Virus TI Synth");
+ final MidiDevice device2 = MidiUtils.getReceivingDevice("Virus TI Synth");
+ final MidiDevice device3 = MidiUtils.getTransmittingDevice("Virus TI MIDI");
+ final MidiDevice device4 = MidiUtils.getReceivingDevice("Virus TI MIDI");
+ final Sequencer sequencer = (Sequencer) MidiUtils.getDeviceByName("Real Time Sequencer");
+ device1.open();
+ device2.open();
+ device3.open();
+ device4.open();
+ final Transmitter transmitter = device1.getTransmitter();
+ final Receiver receiver = device4.getReceiver();
+ transmitter.setReceiver(new MyReceiver(receiver));
+
+ // The following SysEx message is known to do the following:
+ // - It sets the tempo to 0x41 which is 128 BPM (63 is the base, + 65 which is 0x41 so that's 128 BPM)
+ // It sets "Local" to "Off", disabling the Synthesizer's internal feedback loop so all Midi is routed through this program.
+ final SysexMessage sysexMessage = MidiUtils.createSysexMessage("f0002033011071401041f7");
+ receiver.send(new SysexMessage(), 0);
+ // The following sets logo groove to NN (0x00 - 0x7F) : f00020330100730834NNf7
+
+ System.out.println("Go!");
+ return 0;
+ }
+
+}
Property changes on: progs/jirus/trunk/src/prj/net/sf/jirus/Jirus.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: progs/jirus/trunk/src/prj/net/sf/jirus/MyReceiver.java
===================================================================
--- progs/jirus/trunk/src/prj/net/sf/jirus/MyReceiver.java (rev 0)
+++ progs/jirus/trunk/src/prj/net/sf/jirus/MyReceiver.java 2008-10-06 12:45:51 UTC (rev 648)
@@ -0,0 +1,67 @@
+package net.sf.jirus;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.ShortMessage;
+
+/**
+ * Class Description.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class MyReceiver implements Receiver {
+
+ private boolean[] noteState = new boolean[Jirus.MIDI_NOTE_RANGE];
+
+ private int playingNote = 0xFF;
+
+ private final Receiver receiver;
+
+ public MyReceiver(final Receiver receiver) {
+ this.receiver = receiver;
+ }
+
+ public void close() {}
+
+ public void send(final MidiMessage message, final long timeStamp) {
+ try {
+ final byte[] messageData = message.getMessage();
+ boolean echoMessage = true;
+ if (messageData.length != 1 || messageData[0] != (byte) ShortMessage.TIMING_CLOCK) {
+ if (message instanceof ShortMessage) {
+ final ShortMessage smg = (ShortMessage) message;
+ final int cmd = smg.getCommand();
+ if (cmd == ShortMessage.NOTE_ON || cmd == ShortMessage.NOTE_OFF) {
+ final int note = smg.getData1();
+ final int velo = smg.getData2();
+ noteState[note] = cmd == ShortMessage.NOTE_ON;
+ if (note < Jirus.SPLIT_KEY) {
+ receiver.send(message, timeStamp);
+ if (cmd == ShortMessage.NOTE_OFF) {
+ playingNote = 0xFF;
+ } else {
+ assert cmd == ShortMessage.NOTE_ON;
+ if (note < playingNote) {
+ smg.setMessage(ShortMessage.NOTE_OFF, Jirus.SPLIT_CHANNEL, playingNote, velo);
+ receiver.send(message, timeStamp);
+ smg.setMessage(ShortMessage.NOTE_ON, Jirus.SPLIT_CHANNEL, note, velo);
+ playingNote = note;
+ } else {
+ echoMessage = false;
+ }
+ }
+ smg.setMessage(cmd, Jirus.SPLIT_CHANNEL, note, velo);
+ }
+ }
+ }
+ }
+ if (echoMessage) {
+ receiver.send(message, timeStamp);
+ }
+ } catch (InvalidMidiDataException e) {
+ // This should not happen.
+ // It would mean that the program itself did something wrong.
+ e.printStackTrace();
+ }
+ }
+}
Property changes on: progs/jirus/trunk/src/prj/net/sf/jirus/MyReceiver.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|