1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-10 00:23:32 +02:00

Update portmidi to SVN r227.

This commit is contained in:
lllucius
2013-10-31 07:33:41 +00:00
parent a30f9e913b
commit bb63fa0d07
118 changed files with 15017 additions and 12291 deletions

View File

@@ -0,0 +1,47 @@
# pm_java
if(UNIX)
if(APPLE)
# java not dealt with in CMake -- see pm_mac/pm_mac.xcodeproj
else(APPLE)
# linux
set(JPORTMIDICLASS JPortMidi.class JPortMidiException.class
JPortMidiApi.class)
set(PMDEFAULTSCLASS PmDefaultsFrame.class PmDefaults.class)
prepend_path(JPORTMIDICLASS2 jportmidi/ ${JPORTMIDICLASS})
prepend_path(PMDEFAULTSCLASS2 pmdefaults/ ${PMDEFAULTSCLASS})
set(PMDEFAULTS_ALL_CLASSES ${JPORTMIDICLASS2} ${PMDEFAULTSCLASS2})
# message(STATUS "PMDEFAULTS_ALL_CLASSES is " ${PMDEFAULTS_ALL_CLASSES})
add_custom_command(OUTPUT pmdefaults/PmDefaultsFrame.class
COMMAND javac -classpath . pmdefaults/PmDefaultsFrame.java
MAIN_DEPENDENCY pmdefaults/PmDefaultsFrame.java
DEPENDS pmdefaults/PmDefaults.java
WORKING_DIRECTORY pm_java)
add_custom_command(OUTPUT pmdefaults/PmDefaults.class
COMMAND javac -classpath . pmdefaults/PmDefaults.java
MAIN_DEPENDENCY pmdefaults/PmDefaults.java
DEPENDS pmdefaults/PmDefaultsFrame.java
WORKING_DIRECTORY pm_java)
add_custom_command(OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
COMMAND cp pmdefaults/portmusic_logo.png .
COMMAND jar cmf pmdefaults/manifest.txt pmdefaults.jar
pmdefaults/*.class portmusic_logo.png jportmidi/*.class
COMMAND chmod +x pmdefaults/pmdefaults
COMMAND cp pmdefaults/pmdefaults ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
COMMAND mv pmdefaults.jar ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
COMMAND rm portmusic_logo.png
MAIN_DEPENDENCY pmdefaults/PmDefaults.class
DEPENDS ${PMDEFAULTS_ALL_CLASSES}
WORKING_DIRECTORY pm_java)
add_custom_target(pmdefaults_target ALL
DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar)
# message(STATUS "add_custom_target: pmdefaults.jar")
# install the libraries (Linux only)
INSTALL(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
DESTINATION /usr/share/java)
INSTALL(PROGRAMS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults
DESTINATION /usr/local/bin)
endif(APPLE)
endif(UNIX)
# In windows, use pm_java/make.bat

Binary file not shown.

View File

@@ -0,0 +1,48 @@
README.txt
Roger B. Dannenberg
16 Jun 2009
This directory was created to implement PmDefaults, a program to
set default input and output devices for PortMidi applications.
There are three main sub-projects here:
1) pmjni -- a JNI (Java Native Interface) to access PortMidi
2) jportmidi -- a Java class to access PortMidi (uses pmjni)
3) pmdefaults -- the PmDefaults application (uses jportmidi)
For Mac OS X, you should build the PmDefaults application in Xcode.
For Win32, an installer for PmDefaults is included in setup/.
To build from sources, you should first build everything including
the portmidi dll (that will be used by the Java application) using
Visual C++ and a provided .sln file in the portmidi home directory.
Then, run make.bat in this directory. The subdirectory win32 will be
created with the application pmdefaults.exe. You can run this application
in the normal way. To move the application, you need to copy *everything*
in win32. To build setup/pmdefaults-setup.exe, I have used both
Setup Generator from Gentee software and Inno Setup from jrsoftware.org.
A script for Inno Setup is included in this directory, but since paths
seem to be absolute, you will have to adjust the paths in the script
before you use it.
---- implementation notes ----
For windows, we use the free software JavaExe.exe. The copy here was
downloaded from
http://software.techrepublic.com.com/abstract.aspx?kw=javaexe&docid=767485
I found this page by visiting http://software.techrepublic.com.com and
searching in the "Software" category for "JavaExe"
JavaExe works by placing the JavaExe.exe file in the directory with the
Java application jar file and then *renaming* JavaExe.exe to the name
of the jar file, but keeping the .exe extension. (See make.bat for this
step.) Documentation for JavaExe can be obtained by downloading the
whole program from the URL(s) above.

Binary file not shown.

View File

@@ -0,0 +1,539 @@
package jportmidi;
/* PortMidi is a general class intended for any Java program using
the PortMidi library. It encapsulates JPortMidiApi with a more
object-oriented interface. A single PortMidi object can manage
up to one input stream and one output stream.
This class is not safely callable from multiple threads. It
is the client's responsibility to periodically call the Poll
method which checks for midi input and handles it.
*/
import jportmidi.*;
import jportmidi.JPortMidiApi.*;
public class JPortMidi {
// timecode to send message immediately
public final int NOW = 0;
// midi codes
public final int MIDI_NOTE_OFF = 0x80;
public final int MIDI_NOTE_ON = 0x90;
public final int CTRL_ALL_OFF = 123;
public final int MIDI_PITCH_BEND = 0xE0;
public final int MIDI_CLOCK = 0xF8;
public final int MIDI_CONTROL = 0xB0;
public final int MIDI_PROGRAM = 0xC0;
public final int MIDI_START = 0xFA;
public final int MIDI_STOP = 0xFC;
public final int MIDI_POLY_TOUCH = 0xA0;
public final int MIDI_TOUCH = 0xD0;
// error code -- cannot refresh device list while stream is open:
public final int pmStreamOpen = -5000;
public final int pmOutputNotOpen = -4999;
// access to JPortMidiApi is through a single, global instance
private static JPortMidiApi pm;
// a reference count tracks how many objects have it open
private static int pmRefCount = 0;
private static int openCount = 0;
public int error; // user can check here for error codes
private PortMidiStream input;
private PortMidiStream output;
private PmEvent buffer;
protected int timestamp; // remember timestamp from incoming messages
protected boolean trace = false; // used to print midi msgs for debugging
public JPortMidi() throws JPortMidiException {
if (pmRefCount == 0) {
pm = new JPortMidiApi();
pmRefCount++;
System.out.println("Calling Pm_Initialize");
checkError(pm.Pm_Initialize());
System.out.println("Called Pm_Initialize");
}
buffer = new PmEvent();
}
public boolean getTrace() { return trace; }
// set the trace flag and return previous value
public boolean setTrace(boolean flag) {
boolean previous = trace;
trace = flag;
return previous;
}
// WARNING: you must not call this if any devices are open
public void refreshDeviceLists()
throws JPortMidiException
{
if (openCount > 0) {
throw new JPortMidiException(pmStreamOpen,
"RefreshDeviceLists called while stream is open");
}
checkError(pm.Pm_Terminate());
checkError(pm.Pm_Initialize());
}
// there is no control over when/whether this is called, but it seems
// to be a good idea to close things when this object is collected
public void finalize() {
if (input != null) {
error = pm.Pm_Close(input);
}
if (input != null) {
int rslt = pm.Pm_Close(output);
// we may lose an error code from closing output, but don't
// lose any real error from closing input...
if (error == pm.pmNoError) error = rslt;
}
pmRefCount--;
if (pmRefCount == 0) {
error = pm.Pm_Terminate();
}
}
int checkError(int err) throws JPortMidiException
{
// note that Pm_Read and Pm_Write return positive result values
// which are not errors, so compare with >=
if (err >= pm.pmNoError) return err;
if (err == pm.pmHostError) {
throw new JPortMidiException(err, pm.Pm_GetHostErrorText());
} else {
throw new JPortMidiException(err, pm.Pm_GetErrorText(err));
}
}
// ******** ACCESS TO TIME ***********
public void timeStart(int resolution) throws JPortMidiException {
checkError(pm.Pt_TimeStart(resolution));
}
public void timeStop() throws JPortMidiException {
checkError(pm.Pt_TimeStop());
}
public int timeGet() {
return pm.Pt_Time();
}
public boolean timeStarted() {
return pm.Pt_TimeStarted();
}
// ******* QUERY DEVICE INFORMATION *********
public int countDevices() throws JPortMidiException {
return checkError(pm.Pm_CountDevices());
}
public int getDefaultInputDeviceID() throws JPortMidiException {
return checkError(pm.Pm_GetDefaultInputDeviceID());
}
public int getDefaultOutputDeviceID() throws JPortMidiException {
return checkError(pm.Pm_GetDefaultOutputDeviceID());
}
public String getDeviceInterf(int i) {
return pm.Pm_GetDeviceInterf(i);
}
public String getDeviceName(int i) {
return pm.Pm_GetDeviceName(i);
}
public boolean getDeviceInput(int i) {
return pm.Pm_GetDeviceInput(i);
}
public boolean getDeviceOutput(int i) {
return pm.Pm_GetDeviceOutput(i);
}
// ********** MIDI INTERFACE ************
public boolean isOpenInput() {
return input != null;
}
public void openInput(int inputDevice, int bufferSize)
throws JPortMidiException
{
openInput(inputDevice, "", bufferSize);
}
public void openInput(int inputDevice, String inputDriverInfo, int bufferSize)
throws JPortMidiException
{
if (isOpenInput()) pm.Pm_Close(input);
else input = new PortMidiStream();
if (trace) {
System.out.println("openInput " + getDeviceName(inputDevice));
}
checkError(pm.Pm_OpenInput(input, inputDevice,
inputDriverInfo, bufferSize));
// if no exception, then increase count of open streams
openCount++;
}
public boolean isOpenOutput() {
return output != null;
}
public void openOutput(int outputDevice, int bufferSize, int latency)
throws JPortMidiException
{
openOutput(outputDevice, "", bufferSize, latency);
}
public void openOutput(int outputDevice, String outputDriverInfo,
int bufferSize, int latency) throws JPortMidiException {
if (isOpenOutput()) pm.Pm_Close(output);
else output = new PortMidiStream();
if (trace) {
System.out.println("openOutput " + getDeviceName(outputDevice));
}
checkError(pm.Pm_OpenOutput(output, outputDevice, outputDriverInfo,
bufferSize, latency));
// if no exception, then increase count of open streams
openCount++;
}
public void setFilter(int filters) throws JPortMidiException {
if (input == null) return; // no effect if input not open
checkError(pm.Pm_SetFilter(input, filters));
}
public void setChannelMask(int mask) throws JPortMidiException {
if (input == null) return; // no effect if input not open
checkError(pm.Pm_SetChannelMask(input, mask));
}
public void abort() throws JPortMidiException {
if (output == null) return; // no effect if output not open
checkError(pm.Pm_Abort(output));
}
// In keeping with the idea that this class represents an input and output,
// there are separate Close methods for input and output streams, avoiding
// the need for clients to ever deal directly with a stream object
public void closeInput() throws JPortMidiException {
if (input == null) return; // no effect if input not open
checkError(pm.Pm_Close(input));
input = null;
openCount--;
}
public void closeOutput() throws JPortMidiException {
if (output == null) return; // no effect if output not open
checkError(pm.Pm_Close(output));
output = null;
openCount--;
}
// Poll should be called by client to process input messages (if any)
public void poll() throws JPortMidiException {
if (input == null) return; // does nothing until input is opened
while (true) {
int rslt = pm.Pm_Read(input, buffer);
checkError(rslt);
if (rslt == 0) return; // no more messages
handleMidiIn(buffer);
}
}
public void writeShort(int when, int msg) throws JPortMidiException {
if (output == null)
throw new JPortMidiException(pmOutputNotOpen,
"Output stream not open");
if (trace) {
System.out.println("writeShort: " + Integer.toHexString(msg));
}
checkError(pm.Pm_WriteShort(output, when, msg));
}
public void writeSysEx(int when, byte msg[]) throws JPortMidiException {
if (output == null)
throw new JPortMidiException(pmOutputNotOpen,
"Output stream not open");
if (trace) {
System.out.print("writeSysEx: ");
for (int i = 0; i < msg.length; i++) {
System.out.print(Integer.toHexString(msg[i]));
}
System.out.print("\n");
}
checkError(pm.Pm_WriteSysEx(output, when, msg));
}
public int midiChanMessage(int chan, int status, int data1, int data2) {
return (((data2 << 16) & 0xFF0000) |
((data1 << 8) & 0xFF00) |
(status & 0xF0) |
(chan & 0xF));
}
public int midiMessage(int status, int data1, int data2) {
return ((((data2) << 16) & 0xFF0000) |
(((data1) << 8) & 0xFF00) |
((status) & 0xFF));
}
public void midiAllOff(int channel) throws JPortMidiException {
midiAllOff(channel, NOW);
}
public void midiAllOff(int chan, int when) throws JPortMidiException {
writeShort(when, midiChanMessage(chan, MIDI_CONTROL, CTRL_ALL_OFF, 0));
}
public void midiPitchBend(int chan, int value) throws JPortMidiException {
midiPitchBend(chan, value, NOW);
}
public void midiPitchBend(int chan, int value, int when)
throws JPortMidiException {
writeShort(when,
midiChanMessage(chan, MIDI_PITCH_BEND, value, value >> 7));
}
public void midiClock() throws JPortMidiException {
midiClock(NOW);
}
public void midiClock(int when) throws JPortMidiException {
writeShort(when, midiMessage(MIDI_CLOCK, 0, 0));
}
public void midiControl(int chan, int control, int value)
throws JPortMidiException {
midiControl(chan, control, value, NOW);
}
public void midiControl(int chan, int control, int value, int when)
throws JPortMidiException {
writeShort(when, midiChanMessage(chan, MIDI_CONTROL, control, value));
}
public void midiNote(int chan, int pitch, int vel)
throws JPortMidiException {
midiNote(chan, pitch, vel, NOW);
}
public void midiNote(int chan, int pitch, int vel, int when)
throws JPortMidiException {
writeShort(when, midiChanMessage(chan, MIDI_NOTE_ON, pitch, vel));
}
public void midiProgram(int chan, int program)
throws JPortMidiException {
midiProgram(chan, program, NOW);
}
public void midiProgram(int chan, int program, int when)
throws JPortMidiException {
writeShort(when, midiChanMessage(chan, MIDI_PROGRAM, program, 0));
}
public void midiStart()
throws JPortMidiException {
midiStart(NOW);
}
public void midiStart(int when)
throws JPortMidiException {
writeShort(when, midiMessage(MIDI_START, 0, 0));
}
public void midiStop()
throws JPortMidiException {
midiStop(NOW);
}
public void midiStop(int when)
throws JPortMidiException {
writeShort(when, midiMessage(MIDI_STOP, 0, 0));
}
public void midiPolyTouch(int chan, int key, int value)
throws JPortMidiException {
midiPolyTouch(chan, key, value, NOW);
}
public void midiPolyTouch(int chan, int key, int value, int when)
throws JPortMidiException {
writeShort(when, midiChanMessage(chan, MIDI_POLY_TOUCH, key, value));
}
public void midiTouch(int chan, int value)
throws JPortMidiException {
midiTouch(chan, value, NOW);
}
public void midiTouch(int chan, int value, int when)
throws JPortMidiException {
writeShort(when, midiChanMessage(chan, MIDI_TOUCH, value, 0));
}
// ****** now we implement the message handlers ******
// an array for incoming sysex messages that can grow.
// The downside is that after getting a message, we
private byte sysexBuffer[] = null;
private int sysexBufferIndex = 0;
void sysexBufferReset() {
sysexBufferIndex = 0;
if (sysexBuffer == null) sysexBuffer = new byte[256];
}
void sysexBufferCheck() {
if (sysexBuffer.length < sysexBufferIndex + 4) {
byte bigger[] = new byte[sysexBuffer.length * 2];
for (int i = 0; i < sysexBufferIndex; i++) {
bigger[i] = sysexBuffer[i];
}
sysexBuffer = bigger;
}
// now we have space to write some bytes
}
// call this to insert Sysex and EOX status bytes
// call sysexBufferAppendBytes to insert anything else
void sysexBufferAppendStatus(byte status) {
sysexBuffer[sysexBufferIndex++] = status;
}
void sysexBufferAppendBytes(int msg, int len) {
for (int i = 0; i < len; i++) {
byte b = (byte) msg;
if ((msg & 0x80) != 0) {
if (b == 0xF7) { // end of sysex
sysexBufferAppendStatus(b);
sysex(sysexBuffer, sysexBufferIndex);
return;
}
// recursively handle embedded real-time messages
PmEvent buffer = new PmEvent();
buffer.timestamp = timestamp;
buffer.message = b;
handleMidiIn(buffer);
} else {
sysexBuffer[sysexBufferIndex++] = b;
}
msg = msg >> 8;
}
}
void sysexBegin(int msg) {
sysexBufferReset(); // start from 0, we have at least 256 bytes now
sysexBufferAppendStatus((byte) (msg & 0xFF)); // first byte is special
sysexBufferAppendBytes(msg >> 8, 3); // process remaining bytes
}
public void handleMidiIn(PmEvent buffer)
{
if (trace) {
System.out.println("handleMidiIn: " +
Integer.toHexString(buffer.message));
}
// rather than pass timestamps to every handler, where typically
// timestamps are ignored, just save the timestamp as a member
// variable where methods can access it if they want it
timestamp = buffer.timestamp;
int status = buffer.message & 0xFF;
if (status < 0x80) {
sysexBufferCheck(); // make enough space
sysexBufferAppendBytes(buffer.message, 4); // process 4 bytes
return;
}
int command = status & 0xF0;
int channel = status & 0x0F;
int data1 = (buffer.message >> 8) & 0xFF;
int data2 = (buffer.message >> 16) & 0xFF;
switch (command) {
case MIDI_NOTE_OFF:
noteOff(channel, data1, data2); break;
case MIDI_NOTE_ON:
if (data2 > 0) {
noteOn(channel, data1, data2); break;
} else {
noteOff(channel, data1);
}
break;
case MIDI_CONTROL:
control(channel, data1, data2); break;
case MIDI_POLY_TOUCH:
polyTouch(channel, data1, data2); break;
case MIDI_TOUCH:
touch(channel, data1); break;
case MIDI_PITCH_BEND:
pitchBend(channel, (data1 + (data2 << 7)) - 8192); break;
case MIDI_PROGRAM:
program(channel, data1); break;
case 0xF0:
switch (channel) {
case 0: sysexBegin(buffer.message); break;
case 1: mtcQuarterFrame(data1);
case 2: songPosition(data1 + (data2 << 7)); break;
case 3: songSelect(data1); break;
case 4: /* unused */ break;
case 5: /* unused */ break;
case 6: tuneRequest(); break;
case 7: sysexBufferAppendBytes(buffer.message, buffer.message); break;
case 8: clock(); break;
case 9: tick(); break;
case 0xA: clockStart(); break;
case 0xB: clockContinue(); break;
case 0xC: clockStop(); break;
case 0xD: /* unused */ break;
case 0xE: activeSense(); break;
case 0xF: reset(); break;
}
}
}
// the value ranges from +8181 to -8192. The interpretation is
// synthesizer dependent. Often the range is +/- one whole step
// (two semitones), but the range is usually adjustable within
// the synthesizer.
void pitchBend(int channel, int value) { return; }
void control(int channel, int control, int value) { return; }
void noteOn(int channel, int pitch, int velocity) { return; }
// you can handle velocity in note-off if you want, but the default
// is to drop the velocity and call the simpler NoteOff handler
void noteOff(int channel, int pitch, int velocity) {
noteOff(channel, pitch);
}
// if the subclass wants to implement NoteOff with velocity, it
// should override the following to make sure all NoteOffs are handled
void noteOff(int channel, int pitch) { return; }
void program(int channel, int program) { return; }
// the byte array may be bigger than the message, length tells how
// many bytes in the array are part of the message
void sysex(byte[] msg, int length) { return; }
void polyTouch(int channel, int key, int value) { return; }
void touch(int channel, int value) { return; }
void mtcQuarterFrame(int value) { return; }
// the value is a 14-bit integer representing 16th notes
void songPosition(int value) { return; }
void songSelect(int value) { return; }
void tuneRequest() { return; }
void clock() { return; } // represents 1/24th of a quarter note
void tick() { return; } // represents 10ms
void clockStart() { return; }
void clockStop() { return; }
void clockContinue() { return; }
void activeSense() { return; }
void reset() { return; }
}

View File

@@ -0,0 +1,117 @@
package jportmidi;
public class JPortMidiApi {
public static class PortMidiStream {
private long address;
}
public static class PmEvent {
public int message;
public int timestamp;
}
// PmError bindings
public final int pmNoError = 0;
public final int pmNoData = 0;
public final int pmGotData = -1;
public final int pmHostError = -10000;
public final int pmInvalidDeviceId = -9999;
public final int pmInsufficientMemory = -9998;
public final int pmBufferTooSmall = -9997;
public final int pmBufferOverflow = -9996;
public final int pmBadPtr = -9995;
public final int pmBadData = -9994;
public final int pmInternalError = -9993;
public final int pmBufferMaxSize = -9992;
static public native int Pm_Initialize();
static public native int Pm_Terminate();
static public native int Pm_HasHostError(PortMidiStream stream);
static public native String Pm_GetErrorText(int errnum);
static public native String Pm_GetHostErrorText();
final int pmNoDevice = -1;
static public native int Pm_CountDevices();
static public native int Pm_GetDefaultInputDeviceID();
static public native int Pm_GetDefaultOutputDeviceID();
static public native String Pm_GetDeviceInterf(int i);
static public native String Pm_GetDeviceName(int i);
static public native boolean Pm_GetDeviceInput(int i);
static public native boolean Pm_GetDeviceOutput(int i);
static public native int Pm_OpenInput(PortMidiStream stream,
int inputDevice,
String inputDriverInfo,
int bufferSize);
static public native int Pm_OpenOutput(PortMidiStream stream,
int outputDevice,
String outnputDriverInfo,
int bufferSize,
int latency);
final static public int PM_FILT_ACTIVE = (1 << 0x0E);
final static public int PM_FILT_SYSEX = (1 << 0x00);
final static public int PM_FILT_CLOCK = (1 << 0x08);
final static public int PM_FILT_PLAY =
(1 << 0x0A) | (1 << 0x0C) | (1 << 0x0B);
final static public int PM_FILT_TICK = (1 << 0x09);
final static public int PM_FILT_FD = (1 << 0x0D);
final static public int PM_FILT_UNDEFINED = PM_FILT_FD;
final static public int PM_FILT_RESET = (1 << 0x0F);
final static public int PM_FILT_REALTIME =
PM_FILT_ACTIVE | PM_FILT_SYSEX | PM_FILT_CLOCK;
final static public int PM_FILT_NOTE = (1 << 0x19) | (1 << 0x18);
final static public int PM_FILT_CHANNEL_AFTERTOUCH = (1 << 0x1D);
final static public int PM_FILT_POLY_AFTERTOUCH = (1 << 0x1A);
final static public int PM_FILT_AFTERTOUCH =
(PM_FILT_CHANNEL_AFTERTOUCH | PM_FILT_POLY_AFTERTOUCH);
final static public int PM_FILT_PROGRAM = (1 << 0x1C);
final static public int PM_FILT_CONTROL = (1 << 0x1B);
final static public int PM_FILT_PITCHBEND = (1 << 0x1E);
final static public int PM_FILT_MTC = (1 << 0x01);
final static public int PM_FILT_SONG_POSITION = (1 << 0x02);
final static public int PM_FILT_SONG_SELECT = (1 << 0x03);
final static public int PM_FILT_TUNE = (1 << 0x06);
final static public int PM_FILT_SYSTEMCOMMON =
(PM_FILT_MTC | PM_FILT_SONG_POSITION |
PM_FILT_SONG_SELECT | PM_FILT_TUNE);
static public native int Pm_SetFilter(PortMidiStream stream, int filters);
static public int Pm_Channel(int channel) { return 1 << channel; }
final static public native int Pm_SetChannelMask(PortMidiStream stream,
int mask);
final static public native int Pm_Abort(PortMidiStream stream);
final static public native int Pm_Close(PortMidiStream stream);
static public int Pm_Message(int status, int data1, int data2) {
return (((data2 << 16) & 0xFF0000) |
((data1 << 8) & 0xFF00) |
(status & 0xFF));
}
static public int Pm_MessageStatus(int msg) {
return msg & 0xFF;
}
static public int Pm_MessageData1(int msg) {
return (msg >> 8) & 0xFF;
}
static public int Pm_MessageData2(int msg) {
return (msg >> 16) & 0xFF;
}
// only supports reading one buffer at a time
static public native int Pm_Read(PortMidiStream stream, PmEvent buffer);
static public native int Pm_Poll(PortMidiStream stream);
// only supports writing one buffer at a time
static public native int Pm_Write(PortMidiStream stream, PmEvent buffer);
static public native int Pm_WriteShort(PortMidiStream stream,
int when, int msg);
static public native int Pm_WriteSysEx(PortMidiStream stream,
int when, byte msg[]);
public final int ptNoError = 0;
public final int ptAlreadyStarted = -10000;
public final int ptAlreadyStopped = -9999;
public final int PtInsufficientMemory = -9998;
static public native int Pt_TimeStart(int resolution);
static public native int Pt_TimeStop();
static public native int Pt_Time();
static public native boolean Pt_TimeStarted();
static {
System.out.println("Loading pmjni");
System.loadLibrary("pmjni");
System.out.println("done loading pmjni");
}
}

View File

@@ -0,0 +1,12 @@
// JPortMidiException -- thrown by JPortMidi methods
package jportmidi;
public class JPortMidiException extends Exception {
public int error = 0;
public JPortMidiException(int err, String msg) {
super(msg);
error = err;
}
}

View File

@@ -0,0 +1,26 @@
# script to build a jar file to run PmDefaults from the command line on OS X
# (This is for debugging. Normally, you would use XCode to build PmDefaults.app.)
# Compile the java Portidi interface classes.
javac jportmidi/*.java
# Compile the pmdefaults application.
javac -classpath . pmdefaults/*.java
# Temporarily copy the portmusic_logo.png file here to add to the jar file.
cp pmdefaults/portmusic_logo.png .
# Create a directory to hold the distribution.
mkdir mac-osx
# Copy the interface DLL to the distribution directory.
cp ../Release/libpmjni.dylib mac-osx
# Create a java archive (jar) file of the distribution.
jar cmf pmdefaults/manifest.txt mac-osx/pmdefaults.jar pmdefaults/*.class portmusic_logo.png jportmidi/*.class
# Clean up the temporary image file now that it is in the jar file.
rm portmusic_logo.png
echo "You now have a jar file in mac-osx"

View File

@@ -0,0 +1,47 @@
@echo off
rem Compile the java PortMidi interface classes.
javac jportmidi/*.java
rem Compile the pmdefaults application.
javac -classpath . pmdefaults/*.java
rem Temporarily copy the portmusic_logo.png file here to add to the jar file.
copy pmdefaults\portmusic_logo.png . > nul
rem Create a directory to hold the distribution.
mkdir win32
rem Attempt to copy the interface DLL to the distribution directory.
if exist "..\release\pmjni.dll" goto have-dll
echo "ERROR: pmjni.dll not found!"
exit /b 1
:have-dll
copy "..\release\pmjni.dll" win32\pmjni.dll > nul
rem Create a java archive (jar) file of the distribution.
jar cmf pmdefaults\manifest.txt win32\pmdefaults.jar pmdefaults\*.class portmusic_logo.png jportmidi\*.class
rem Clean up the temporary image file now that it is in the jar file.
del portmusic_logo.png
rem Copy the java execution code obtained from
rem http://devwizard.free.fr/html/en/JavaExe.html to the distribution
rem directory. The copy also renames the file to our desired executable
rem name.
copy JavaExe.exe win32\pmdefaults.exe > nul
rem Integrate the icon into the executable using UpdateRsrcJavaExe from
rem http://devwizard.free.fr
UpdateRsrcJavaExe -run -exe=win32\pmdefaults.exe -ico=pmdefaults\pmdefaults.ico
rem Copy the 32-bit windows read me file to the distribution directory.
copy pmdefaults\readme-win32.txt win32\README.txt > nul
rem Copy the license file to the distribution directory.
copy pmdefaults\pmdefaults-license.txt win32\license.txt > nul
echo "You can run pmdefaults.exe in win32"

View File

@@ -0,0 +1,44 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{5094958B-3CD7-4780-A883-69C9E5B95AEF}
AppName=PmDefaults
AppVerName=PmDefaults
AppPublisher=Roger Dannenberg - Carnegie Mellon University
AppPublisherURL=http://portmedia.sourceforge.net/
AppSupportURL=http://portmedia.sourceforge.net/
AppUpdatesURL=http://portmedia.sourceforge.net/
DefaultDirName={pf}\PmDefaults
DefaultGroupName=PmDefaults
LicenseFile=C:\Users\rbd\portmedia\portmidi\pm_java\win32\license.txt
OutputBaseFilename=setup
SetupIconFile=C:\Users\rbd\portmedia\portmidi\pm_java\pmdefaults\pmdefaults.ico
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\rbd\portmedia\portmidi\pm_java\win32\pmdefaults.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\rbd\portmedia\portmidi\pm_java\win32\pmdefaults.jar"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\rbd\portmedia\portmidi\pm_java\win32\pmjni.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\rbd\portmedia\portmidi\pm_java\win32\license.txt"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\PmDefaults"; Filename: "{app}\pmdefaults.exe"
Name: "{commondesktop}\PmDefaults"; Filename: "{app}\pmdefaults.exe"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\PmDefaults"; Filename: "{app}\pmdefaults.exe"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\pmdefaults.exe"; Description: "{cm:LaunchProgram,PmDefaults}"; Flags: nowait postinstall skipifsilent

View File

@@ -0,0 +1,11 @@
// PmDefaults -- a small application to set PortMIDI default input/output
package pmdefaults;
public class PmDefaults {
public static void main(String[] args) {
System.out.println("starting main");
new PmDefaultsFrame("PortMIDI Setup");
}
}

View File

@@ -0,0 +1,428 @@
// PmDefaults -- a small application to set PortMIDI default input/output
/* Implementation notes:
This program uses PortMidi to enumerate input and output devices and also
to send output messages to test output devices and
to receive input messages to test input devices.
*/
package pmdefaults;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Math.*;
import jportmidi.*;
import jportmidi.JPortMidiApi.*;
import java.util.ArrayList;
import java.util.prefs.*;
import java.net.*;
public class PmDefaultsFrame extends JFrame
implements ActionListener, ComponentListener {
// This class extends JPortMidi in order to override midi input handling
// In this case, midi input simply blinks the activity light
public class JPM extends JPortMidi {
ActivityLight light;
PmDefaultsFrame frame;
int lightTime;
boolean lightState;
int now; // current time in ms
final int HALF_BLINK_PERIOD = 250; // ms
public JPM(ActivityLight al, PmDefaultsFrame df)
throws JPortMidiException {
light = al;
frame = df;
lightTime = 0;
lightState = false; // meaning "off"
now = 0;
}
public void poll(int ms) throws JPortMidiException {
// blink the light. lightState is initially false (off).
// to blink the light, set lightState to true and lightTime
// to now + 0.25s; turn on light
// now > ligntTime && lightState => set lightTime = now + 0.25s;
// set lightState = false
// turn off light
// light can be blinked again when now > lightTime && !lightState
now = ms;
if (now > lightTime && lightState) {
lightTime = now + HALF_BLINK_PERIOD;
lightState = false;
light.setState(false);
}
super.poll();
}
public void handleMidiIn(PmEvent buffer) {
System.out.println("midi in: now " + now +
" lightTime " + lightTime +
" lightState " + lightState);
if (now > lightTime && !lightState) {
lightState = true;
lightTime = now + HALF_BLINK_PERIOD;
light.setState(true);
}
}
}
public class ActivityLight extends JPanel {
Color color;
final Color OFF_COLOR = Color.BLACK;
final Color ON_COLOR = Color.GREEN;
ActivityLight() {
super();
Dimension size = new Dimension(50, 25);
setMaximumSize(size);
setPreferredSize(size);
setMinimumSize(size);
color = OFF_COLOR;
System.out.println("ActivityLight " + getSize());
}
public void setState(boolean on) {
color = (on ? ON_COLOR : OFF_COLOR);
repaint();
}
public void paintComponent(Graphics g) {
super.paintComponent(g); // paint background
g.setColor(color);
int x = (getWidth() / 2) - 5;
int y = (getHeight() / 2) - 5;
g.fillOval(x, y, 10, 10);
g.setColor(OFF_COLOR);
g.drawOval(x, y, 10, 10);
}
}
private JLabel inputLabel;
private JComboBox inputSelection;
// inputIds maps from the index of an item in inputSelection to the
// device ID. Used to open the selected device.
private ArrayList<Integer> inputIds;
private ActivityLight inputActivity;
private JLabel outputLabel;
private JComboBox outputSelection;
// analogous to inputIds, outputIds maps selection index to device ID
private ArrayList<Integer> outputIds;
private JButton testButton;
private JButton refreshButton;
private JButton updateButton;
private JButton closeButton;
private JLabel logo;
private JPM jpm;
private Timer timer;
public void componentResized(ComponentEvent e) {
System.out.println(e);
if (e.getComponent() == this) {
Insets insets = getInsets();
Dimension dim = getSize();
layoutComponents(dim.width - insets.left - insets.right,
dim.height - insets.top - insets.bottom);
}
}
public void componentMoved(ComponentEvent e) {
System.out.println(e);
}
public void componentHidden(ComponentEvent e) {
System.out.println(e);
}
public void componentShown(ComponentEvent e) {
System.out.println(e);
}
PmDefaultsFrame(String title) {
super(title);
initComponents();
System.out.println("initComponents returned\n");
pack(); // necessary before calling getInsets();
// initially, only width matters to layout:
layoutComponents(550, 300);
System.out.println("after layout, pref " + getPreferredSize());
// now, based on layout-computed preferredSize, set the Frame size
Insets insets = getInsets();
Dimension dim = getPreferredSize();
dim.width += (insets.left + insets.right);
dim.height += (insets.top + insets.bottom);
setSize(dim);
System.out.println("size" + getPreferredSize());
addComponentListener(this);
timer = new Timer(50 /* ms */, this);
timer.addActionListener(this);
try {
jpm = new JPM(inputActivity, this);
jpm.setTrace(true);
loadDeviceChoices();
timer.start(); // don't start timer if there's an error
} catch(JPortMidiException e) {
System.out.println(e);
}
}
void openInputSelection() {
int id = inputSelection.getSelectedIndex();
if (id < 0) return; // nothing selected
id = (Integer) (inputIds.get(id)); // map to device ID
// openInput will close any previously open input stream
try {
jpm.openInput(id, 100); // buffer size hopes to avoid overflow
} catch(JPortMidiException e) {
System.out.println(e);
}
}
// make a string to put into preferences describing this device
String makePrefName(int id) {
String name = jpm.getDeviceName(id);
String interf = jpm.getDeviceInterf(id);
// the syntax requires comma-space separator (see portmidi.h)
return interf + ", " + name;
}
public void savePreferences() {
Preferences prefs = Preferences.userRoot().node("/PortMidi");
int id = outputSelection.getSelectedIndex();
if (id >= 0) {
String prefName = makePrefName(outputIds.get(id));
System.out.println("output pref: " + prefName);
prefs.put("PM_RECOMMENDED_OUTPUT_DEVICE", prefName);
}
id = inputSelection.getSelectedIndex();
if (id >= 0) {
String prefName = makePrefName(inputIds.get(id));
System.out.println("input pref: " + prefName);
prefs.put("PM_RECOMMENDED_INPUT_DEVICE", prefName);
}
try {
prefs.flush();
} catch(BackingStoreException e) {
System.out.println(e);
}
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
try {
if (source == timer) {
jpm.poll(jpm.timeGet());
} else if (source == refreshButton) {
if (jpm.isOpenInput()) jpm.closeInput();
if (jpm.isOpenOutput()) jpm.closeOutput();
jpm.refreshDeviceLists();
loadDeviceChoices();
} else if (source == updateButton) {
savePreferences();
} else if (source == closeButton) {
if (jpm.isOpenInput()) jpm.closeInput();
if (jpm.isOpenOutput()) jpm.closeOutput();
} else if (source == testButton) {
sendTestMessages();
} else if (source == inputSelection) {
// close previous selection and open new one
openInputSelection();
} else if (source == outputSelection) {
jpm.closeOutput(); // remains closed until Test button reopens
}
} catch(JPortMidiException ex) {
System.out.println(ex);
}
};
private void layoutComponents(int width, int height) {
// I tried to do this with various layout managers, but failed
// It seems pretty straightforward to just compute locations and
// sizes.
int gap = 2; // pixel separation between components
int indent = 20;
int y = gap;
// inputLabel goes in upper left
inputLabel.setLocation(0, y);
inputLabel.setSize(inputLabel.getPreferredSize());
// inputSelection goes below and indented, width based on panel
y += inputLabel.getHeight() + gap;
inputSelection.setLocation(indent, y);
// size of inputSelection must leave room at right for inputButton
// (in fact, inputActivity goes there, but we'll make inputSelection
// and outputSelection the same size, based on leaving room for
// testButton, which is larger than inputActivity.)
Dimension dim = inputSelection.getPreferredSize();
Dimension dimButton = testButton.getPreferredSize();
// make button and selection the same height so they align
dim.height = dimButton.height = Math.max(dim.height, dimButton.height);
// make selection width as wide as possible
dim.width = width - indent - dimButton.width - gap;
inputSelection.setSize(dim);
// inputActivity goes to the right of inputSelection
inputActivity.setLocation(indent + dim.width + gap, y);
// square size to match the height of inputSelection
inputActivity.setSize(dim.height, dim.height);
// outputLabel goes below
y += dim.height + gap;
outputLabel.setLocation(0, y);
outputLabel.setSize(outputLabel.getPreferredSize());
// outputSelection is like inputSelection
y += outputLabel.getHeight() + gap;
outputSelection.setLocation(indent, y);
outputSelection.setSize(dim);
// testButton is like inputActivity
testButton.setLocation(indent + dim.width + gap, y);
testButton.setSize(dimButton);
System.out.println("button " + dimButton + " selection " + dim);
// refreshButton is below
y += dim.height + gap;
dim = refreshButton.getPreferredSize();
refreshButton.setLocation(indent, y);
refreshButton.setSize(dim);
// updateButton to right of refreshButton
int x = indent + dim.width + gap;
updateButton.setLocation(x, y);
dim = updateButton.getPreferredSize();
updateButton.setSize(dim);
// closeButton to right of updateButton
x += dim.width + gap;
closeButton.setLocation(x, y);
dim = closeButton.getPreferredSize();
closeButton.setSize(dim);
// place logo centered at bottom
y += dim.height + gap;
logo.setLocation((width - logo.getWidth()) / 2,
height - gap - logo.getHeight());
// set overall size
y += logo.getHeight() + gap;
System.out.println("computed best size " + width + ", " + y);
setPreferredSize(new Dimension(width, y));
}
private void initComponents() {
Container wholePanel = getContentPane();
wholePanel.setLayout(null);
setLayout(null);
inputLabel = new JLabel();
inputLabel.setText("Default Input");
wholePanel.add(inputLabel);
inputSelection = new JComboBox();
inputSelection.addActionListener(this);
inputSelection.setLocation(20, 30);
inputSelection.setSize(inputSelection.getPreferredSize());
System.out.println("Adding inputSelection to panel");
wholePanel.add(inputSelection);
inputIds = new ArrayList<Integer>();
inputActivity = new ActivityLight();
wholePanel.add(inputActivity);
outputLabel = new JLabel();
outputLabel.setText("Default Output");
wholePanel.add(outputLabel);
outputSelection = new JComboBox();
outputSelection.addActionListener(this);
wholePanel.add(outputSelection);
testButton = new JButton();
testButton.setText("Test");
testButton.addActionListener(this);
wholePanel.add(testButton);
outputIds = new ArrayList<Integer>();
refreshButton = new JButton();
refreshButton.setText("Refresh Device Lists");
System.out.println("refresh " + refreshButton.getPreferredSize());
System.out.println(getLayout());
refreshButton.addActionListener(this);
wholePanel.add(refreshButton);
updateButton = new JButton();
updateButton.setText("Update Preferences");
updateButton.setSize(refreshButton.getPreferredSize());
updateButton.addActionListener(this);
wholePanel.add(updateButton);
closeButton = new JButton();
closeButton.setText("Close/Release Ports");
closeButton.setSize(refreshButton.getPreferredSize());
closeButton.addActionListener(this);
wholePanel.add(closeButton);
// load the logo from the jar file (on Linux and Windows)
ClassLoader cldr = this.getClass().getClassLoader();
ImageIcon icon;
URL logoURL = cldr.getResource("portmusic_logo.png");
if (logoURL == null) {
// on Mac, load from bundle
icon = new ImageIcon("portmusic_logo.png");
} else {
icon = new ImageIcon(logoURL);
}
logo = new JLabel(icon);
logo.setSize(logo.getPreferredSize());
wholePanel.add(logo);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
void loadDeviceChoices() throws JPortMidiException {
// initialize and load combo boxes with device descriptions
int n = jpm.countDevices();
inputSelection.removeAllItems();
inputIds.clear();
outputSelection.removeAllItems();
outputIds.clear();
for (int i = 0; i < n; i++) {
String interf = jpm.getDeviceInterf(i);
String name = jpm.getDeviceName(i);
System.out.println("name " + name);
String selection = name + " [" + interf + "]";
if (jpm.getDeviceInput(i)) {
inputIds.add(i);
inputSelection.addItem(selection);
} else {
outputIds.add(i);
outputSelection.addItem(selection);
}
}
}
void sendTestMessages() {
try {
if (!jpm.isOpenOutput()) {
int id = outputSelection.getSelectedIndex();
if (id < 0) return; // nothing selected
id = (Integer) (outputIds.get(id));
System.out.println("calling openOutput");
jpm.openOutput(id, 10, 10);
}
jpm.midiNote(0, 67, 100); // send an A (440)
jpm.midiNote(0, 67, 0, jpm.timeGet() + 500);
} catch(JPortMidiException e) {
System.out.println(e);
}
}
}

View File

@@ -0,0 +1,21 @@
README.txt
Roger B. Dannenberg
2 Jan 2009
PmDefaults is a program to set default input and output devices for PortMidi
applications. After running the PmDefaults program and choosing devices,
identifiers for these devices will be returned by
Pm_GetDefaultInputDeviceID() and Pm_GetDefaultOutputDeviceID().
Included in this directory are:
manifest.txt -- used in pmdefaults.jar
pmdefaults-icon.* -- various icons for applications
pmdefaults-license.txt -- a version of portmidi/license.txt formatted for
the windows installer
portmusic_logo.png -- a logo displayed by the pmdefaults application
readme-win32.txt -- this becomes the readme file for the pmdefaults
application. It is copied to win32/README.txt by make.bat
TO BUILD THE APPLICATION: see ../README.txt

View File

@@ -0,0 +1 @@
Main-Class: pmdefaults/PmDefaults

View File

@@ -0,0 +1 @@
java -jar /usr/share/java/pmdefaults.jar > /dev/null

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -0,0 +1,37 @@
LICENSE INFORMATION
PmDefaults is a small program to set default MIDI input and output
devices for other programs using the PortMidi library.
Latest version available at: http://sourceforge.net/projects/portmedia
Copyright (c) 1999-2000 Ross Bencina and Phil Burk
Copyright (c) 2001-2009 Roger B. Dannenberg
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The text above constitutes the entire PortMidi license; however,
the PortMusic community also makes the following non-binding requests:
Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version. It is also
requested that these non-binding requests be included along with the
license above.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

View File

@@ -0,0 +1,11 @@
README.txt
Roger B. Dannenberg
1 Jan 2009
This directory contains files that implement:
pmdefaults -- a program to set PortMidi default input/output devices
You can copy and rename this *whole directory* to move the application
to a convenient place. The application to run is pmdefaults.exe.

View File

@@ -0,0 +1,293 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class jportmidi_JPortMidiApi */
#ifndef _Included_jportmidi_JPortMidiApi
#define _Included_jportmidi_JPortMidiApi
#ifdef __cplusplus
extern "C" {
#endif
#undef jportmidi_JPortMidiApi_PM_FILT_ACTIVE
#define jportmidi_JPortMidiApi_PM_FILT_ACTIVE 16384L
#undef jportmidi_JPortMidiApi_PM_FILT_SYSEX
#define jportmidi_JPortMidiApi_PM_FILT_SYSEX 1L
#undef jportmidi_JPortMidiApi_PM_FILT_CLOCK
#define jportmidi_JPortMidiApi_PM_FILT_CLOCK 256L
#undef jportmidi_JPortMidiApi_PM_FILT_PLAY
#define jportmidi_JPortMidiApi_PM_FILT_PLAY 7168L
#undef jportmidi_JPortMidiApi_PM_FILT_TICK
#define jportmidi_JPortMidiApi_PM_FILT_TICK 512L
#undef jportmidi_JPortMidiApi_PM_FILT_FD
#define jportmidi_JPortMidiApi_PM_FILT_FD 8192L
#undef jportmidi_JPortMidiApi_PM_FILT_UNDEFINED
#define jportmidi_JPortMidiApi_PM_FILT_UNDEFINED 8192L
#undef jportmidi_JPortMidiApi_PM_FILT_RESET
#define jportmidi_JPortMidiApi_PM_FILT_RESET 32768L
#undef jportmidi_JPortMidiApi_PM_FILT_REALTIME
#define jportmidi_JPortMidiApi_PM_FILT_REALTIME 16641L
#undef jportmidi_JPortMidiApi_PM_FILT_NOTE
#define jportmidi_JPortMidiApi_PM_FILT_NOTE 50331648L
#undef jportmidi_JPortMidiApi_PM_FILT_CHANNEL_AFTERTOUCH
#define jportmidi_JPortMidiApi_PM_FILT_CHANNEL_AFTERTOUCH 536870912L
#undef jportmidi_JPortMidiApi_PM_FILT_POLY_AFTERTOUCH
#define jportmidi_JPortMidiApi_PM_FILT_POLY_AFTERTOUCH 67108864L
#undef jportmidi_JPortMidiApi_PM_FILT_AFTERTOUCH
#define jportmidi_JPortMidiApi_PM_FILT_AFTERTOUCH 603979776L
#undef jportmidi_JPortMidiApi_PM_FILT_PROGRAM
#define jportmidi_JPortMidiApi_PM_FILT_PROGRAM 268435456L
#undef jportmidi_JPortMidiApi_PM_FILT_CONTROL
#define jportmidi_JPortMidiApi_PM_FILT_CONTROL 134217728L
#undef jportmidi_JPortMidiApi_PM_FILT_PITCHBEND
#define jportmidi_JPortMidiApi_PM_FILT_PITCHBEND 1073741824L
#undef jportmidi_JPortMidiApi_PM_FILT_MTC
#define jportmidi_JPortMidiApi_PM_FILT_MTC 2L
#undef jportmidi_JPortMidiApi_PM_FILT_SONG_POSITION
#define jportmidi_JPortMidiApi_PM_FILT_SONG_POSITION 4L
#undef jportmidi_JPortMidiApi_PM_FILT_SONG_SELECT
#define jportmidi_JPortMidiApi_PM_FILT_SONG_SELECT 8L
#undef jportmidi_JPortMidiApi_PM_FILT_TUNE
#define jportmidi_JPortMidiApi_PM_FILT_TUNE 64L
#undef jportmidi_JPortMidiApi_PM_FILT_SYSTEMCOMMON
#define jportmidi_JPortMidiApi_PM_FILT_SYSTEMCOMMON 78L
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_Initialize
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Initialize
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_Terminate
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Terminate
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_HasHostError
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1HasHostError
(JNIEnv *, jclass, jobject);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetErrorText
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetErrorText
(JNIEnv *, jclass, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetHostErrorText
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetHostErrorText
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_CountDevices
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1CountDevices
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetDefaultInputDeviceID
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDefaultInputDeviceID
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetDefaultOutputDeviceID
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDefaultOutputDeviceID
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetDeviceInterf
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceInterf
(JNIEnv *, jclass, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetDeviceName
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceName
(JNIEnv *, jclass, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetDeviceInput
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceInput
(JNIEnv *, jclass, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_GetDeviceOutput
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceOutput
(JNIEnv *, jclass, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_OpenInput
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;ILjava/lang/String;I)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1OpenInput
(JNIEnv *, jclass, jobject, jint, jstring, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_OpenOutput
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;ILjava/lang/String;II)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1OpenOutput
(JNIEnv *, jclass, jobject, jint, jstring, jint, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_SetFilter
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;I)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1SetFilter
(JNIEnv *, jclass, jobject, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_SetChannelMask
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;I)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1SetChannelMask
(JNIEnv *, jclass, jobject, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_Abort
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Abort
(JNIEnv *, jclass, jobject);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_Close
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Close
(JNIEnv *, jclass, jobject);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_Read
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;Ljportmidi/JPortMidiApi/PmEvent;)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Read
(JNIEnv *, jclass, jobject, jobject);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_Poll
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Poll
(JNIEnv *, jclass, jobject);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_Write
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;Ljportmidi/JPortMidiApi/PmEvent;)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Write
(JNIEnv *, jclass, jobject, jobject);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_WriteShort
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;II)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1WriteShort
(JNIEnv *, jclass, jobject, jint, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pm_WriteSysEx
* Signature: (Ljportmidi/JPortMidiApi/PortMidiStream;I[B)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1WriteSysEx
(JNIEnv *, jclass, jobject, jint, jbyteArray);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pt_TimeStart
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pt_1TimeStart
(JNIEnv *, jclass, jint);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pt_TimeStop
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pt_1TimeStop
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pt_Time
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pt_1Time
(JNIEnv *, jclass);
/*
* Class: jportmidi_JPortMidiApi
* Method: Pt_TimeStarted
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_jportmidi_JPortMidiApi_Pt_1TimeStarted
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif
/* Header for class jportmidi_JPortMidiApi_PmEvent */
#ifndef _Included_jportmidi_JPortMidiApi_PmEvent
#define _Included_jportmidi_JPortMidiApi_PmEvent
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
/* Header for class jportmidi_JPortMidiApi_PortMidiStream */
#ifndef _Included_jportmidi_JPortMidiApi_PortMidiStream
#define _Included_jportmidi_JPortMidiApi_PortMidiStream
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,225 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="pmjni"
ProjectGUID="{7AA255C8-48BF-40AC-97BA-F7E7BA4DDAA8}"
RootNamespace="pmjni"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\pm_common&quot;;&quot;$(SolutionDir)\porttime&quot;;&quot;$(ProjectDir)&quot;;&quot;E:\Program Files\Java\jdk1.5.0_14\include&quot;;&quot;E:\Program Files\Java\jdk1.5.0_14\include\win32&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PMJNI_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="winmm.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\pm_common&quot;;&quot;$(SolutionDir)\porttime&quot;;&quot;$(ProjectDir)&quot;;&quot;E:\Program Files\Java\jdk1.5.0_14\include&quot;;&quot;E:\Program Files\Java\jdk1.5.0_14\include\win32&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PMJNI_EXPORTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="winmm.lib"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\pmjni.c"
>
</File>
<File
RelativePath="..\..\pm_common\pmutil.c"
>
</File>
<File
RelativePath="..\..\pm_win\pmwin.c"
>
</File>
<File
RelativePath="..\..\pm_win\pmwinmm.c"
>
</File>
<File
RelativePath="..\..\pm_common\portmidi.c"
>
</File>
<File
RelativePath="..\..\porttime\porttime.c"
>
</File>
<File
RelativePath="..\..\porttime\ptwinmm.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,354 @@
#include "portmidi.h"
#include "porttime.h"
#include "jportmidi_JportMidiApi.h"
#include <stdio.h>
// these macros assume JNIEnv *env is declared and valid:
//
#define CLASS(c, obj) jclass c = (*env)->GetObjectClass(env, obj)
#define ADDRESS_FID(fid, c) \
jfieldID fid = (*env)->GetFieldID(env, c, "address", "J")
// Uses Java Long (64-bit) to make sure there is room to store a
// pointer. Cast this to a C long (either 32 or 64 bit) to match
// the size of a pointer. Finally cast int to pointer. All this
// is supposed to avoid C compiler warnings and (worse) losing
// address bits.
#define PMSTREAM(obj, fid) ((PmStream *) (long) (*env)->GetLongField(env, obj, fid))
// Cast stream to long to convert integer to pointer, then expand
// integer to 64-bit jlong. This avoids compiler warnings.
#define SET_PMSTREAM(obj, fid, stream) \
(*env)->SetLongField(env, obj, fid, (jlong) (long) stream)
/*
* Method: Pm_Initialize
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Initialize
(JNIEnv *env, jclass cl)
{
return Pm_Initialize();
}
/*
* Method: Pm_Terminate
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Terminate
(JNIEnv *env, jclass cl)
{
return Pm_Terminate();
}
/*
* Method: Pm_HasHostError
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1HasHostError
(JNIEnv *env, jclass cl, jobject jstream)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
return Pm_HasHostError(PMSTREAM(jstream, fid));
}
/*
* Method: Pm_GetErrorText
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetErrorText
(JNIEnv *env, jclass cl, jint i)
{
return (*env)->NewStringUTF(env, Pm_GetErrorText(i));
}
/*
* Method: Pm_GetHostErrorText
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetHostErrorText
(JNIEnv *env, jclass cl)
{
char msg[PM_HOST_ERROR_MSG_LEN];
Pm_GetHostErrorText(msg, PM_HOST_ERROR_MSG_LEN);
return (*env)->NewStringUTF(env, msg);
}
/*
* Method: Pm_CountDevices
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1CountDevices
(JNIEnv *env, jclass cl)
{
return Pm_CountDevices();
}
/*
* Method: Pm_GetDefaultInputDeviceID
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDefaultInputDeviceID
(JNIEnv *env, jclass cl)
{
return Pm_GetDefaultInputDeviceID();
}
/*
* Method: Pm_GetDefaultOutputDeviceID
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDefaultOutputDeviceID
(JNIEnv *env, jclass cl)
{
return Pm_GetDefaultOutputDeviceID();
}
/*
* Method: Pm_GetDeviceInterf
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceInterf
(JNIEnv *env, jclass cl, jint i)
{
const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
if (!info) return NULL;
return (*env)->NewStringUTF(env, info->interf);
}
/*
* Method: Pm_GetDeviceName
*/
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceName
(JNIEnv *env, jclass cl, jint i)
{
const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
if (!info) return NULL;
return (*env)->NewStringUTF(env, info->name);
}
/*
* Method: Pm_GetDeviceInput
*/
JNIEXPORT jboolean JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceInput
(JNIEnv *env, jclass cl, jint i)
{
const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
if (!info) return (jboolean) 0;
return (jboolean) info->input;
}
/*
* Method: Pm_GetDeviceOutput
*/
JNIEXPORT jboolean JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceOutput
(JNIEnv *env, jclass cl, jint i)
{
const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
if (!info) return (jboolean) 0;
return (jboolean) info->output;
}
/*
* Method: Pm_OpenInput
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1OpenInput
(JNIEnv *env, jclass cl,
jobject jstream, jint index, jstring extras, jint bufsiz)
{
PmError rslt;
PortMidiStream *stream;
CLASS(c, jstream);
ADDRESS_FID(fid, c);
rslt = Pm_OpenInput(&stream, index, NULL, bufsiz, NULL, NULL);
SET_PMSTREAM(jstream, fid, stream);
return rslt;
}
/*
* Method: Pm_OpenOutput
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1OpenOutput
(JNIEnv *env, jclass cl, jobject jstream, jint index, jstring extras,
jint bufsiz, jint latency)
{
PmError rslt;
PortMidiStream *stream;
CLASS(c, jstream);
ADDRESS_FID(fid, c);
rslt = Pm_OpenOutput(&stream, index, NULL, bufsiz, NULL, NULL, latency);
SET_PMSTREAM(jstream, fid, stream);
return rslt;
}
/*
* Method: Pm_SetFilter
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1SetFilter
(JNIEnv *env, jclass cl, jobject jstream, jint filters)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
return Pm_SetFilter(PMSTREAM(jstream, fid), filters);
}
/*
* Method: Pm_SetChannelMask
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1SetChannelMask
(JNIEnv *env, jclass cl, jobject jstream, jint mask)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
return Pm_SetChannelMask(PMSTREAM(jstream, fid), mask);
}
/*
* Method: Pm_Abort
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Abort
(JNIEnv *env, jclass cl, jobject jstream)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
return Pm_Abort(PMSTREAM(jstream, fid));
}
/*
* Method: Pm_Close
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Close
(JNIEnv *env, jclass cl, jobject jstream)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
return Pm_Close(PMSTREAM(jstream, fid));
}
/*
* Method: Pm_Read
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Read
(JNIEnv *env, jclass cl, jobject jstream, jobject jpmevent)
{
CLASS(jstream_class, jstream);
ADDRESS_FID(address_fid, jstream_class);
jclass jpmevent_class = (*env)->GetObjectClass(env, jpmevent);
jfieldID message_fid =
(*env)->GetFieldID(env, jpmevent_class, "message", "I");
jfieldID timestamp_fid =
(*env)->GetFieldID(env, jpmevent_class, "timestamp", "I");
PmEvent buffer;
PmError rslt = Pm_Read(PMSTREAM(jstream, address_fid), &buffer, 1);
(*env)->SetIntField(env, jpmevent, message_fid, buffer.message);
(*env)->SetIntField(env, jpmevent, timestamp_fid, buffer.timestamp);
return rslt;
}
/*
* Method: Pm_Poll
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Poll
(JNIEnv *env, jclass cl, jobject jstream)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
return Pm_Poll(PMSTREAM(jstream, fid));
}
/*
* Method: Pm_Write
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1Write
(JNIEnv *env, jclass cl, jobject jstream, jobject jpmevent)
{
CLASS(jstream_class, jstream);
ADDRESS_FID(address_fid, jstream_class);
jclass jpmevent_class = (*env)->GetObjectClass(env, jpmevent);
jfieldID message_fid =
(*env)->GetFieldID(env, jpmevent_class, "message", "I");
jfieldID timestamp_fid =
(*env)->GetFieldID(env, jpmevent_class, "timestamp", "I");
// note that we call WriteShort because it's simpler than constructing
// a buffer and passing it to Pm_Write
return Pm_WriteShort(PMSTREAM(jstream, address_fid),
(*env)->GetIntField(env, jpmevent, timestamp_fid),
(*env)->GetIntField(env, jpmevent, message_fid));
}
/*
* Method: Pm_WriteShort
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1WriteShort
(JNIEnv *env, jclass cl, jobject jstream, jint when, jint msg)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
return Pm_WriteShort(PMSTREAM(jstream, fid), when, msg);
}
/*
* Method: Pm_WriteSysEx
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pm_1WriteSysEx
(JNIEnv *env, jclass cl, jobject jstream, jint when, jbyteArray jmsg)
{
CLASS(c, jstream);
ADDRESS_FID(fid, c);
jbyte *bytes = (*env)->GetByteArrayElements(env, jmsg, 0);
PmError rslt = Pm_WriteSysEx(PMSTREAM(jstream, fid), when,
(unsigned char *) bytes);
(*env)->ReleaseByteArrayElements(env, jmsg, bytes, 0);
return rslt;
}
/*
* Method: Pt_TimeStart
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pt_1TimeStart
(JNIEnv *env, jclass c, jint resolution)
{
return Pt_Start(resolution, NULL, NULL);
}
/*
* Method: Pt_TimeStop
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pt_1TimeStop
(JNIEnv *env, jclass c)
{
return Pt_Stop();
}
/*
* Method: Pt_Time
*/
JNIEXPORT jint JNICALL Java_jportmidi_JPortMidiApi_Pt_1Time
(JNIEnv *env, jclass c)
{
return Pt_Time();
}
/*
* Method: Pt_TimeStarted
*/
JNIEXPORT jboolean JNICALL Java_jportmidi_JPortMidiApi_Pt_1TimeStarted
(JNIEnv *env, jclass c)
{
return Pt_Started();
}

View File

@@ -0,0 +1,63 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Binary file not shown.