📄 mididevice.java
字号:
/*
* MidiDevice.java
*/
package midi;
/** Base class for MIDI in, out, and sync devices */
public abstract class MidiDevice {
/*--------------- Constant Values ------------------*/
/* MIDI status byte definitions */
public static final int MidiNoteOff = 0x80;
public static final int MidiNoteOn = 0x90;
public static final int MidiKeyAftertouch = 0xA0;
public static final int MidiControlChange = 0xB0;
public static final int MidiProgramChange = 0xC0;
public static final int MidiChannelAftertouch = 0xD0;
public static final int MidiPitchBend = 0xE0;
public static final int MidiSysEx = 0xF0;
public static final int MidiMTCQuarterFrame = 0xF1;
public static final int MidiSongPositionPtr = 0xF2;
public static final int MidiSongSelect = 0xF3;
/* 0xF4, 0xF5 undefined */
public static final int MidiTuneRequest = 0xF6;
public static final int MidiEndSysEx = 0xF7;
public static final int MidiTimingClock = 0xF8;
/* 0xF9 undefined */
public static final int MidiStart = 0xFA;
public static final int MidiContinue = 0xFB;
public static final int MidiStop = 0xFC;
/* 0xFD undefined */
public static final int MidiActiveSense = 0xFE;
public static final int MidiSystemReset = 0xFF;
/* mask for system messages */
public static final int MidiSystemMessage = 0xF0;
/*--- Windows MIDI Mapper device index (from MMSYSTEM.H) ---*/
public static final int MIDI_MAPPER = -1;
/*--- ERROR RETURN CODES (from MMSYSTEM.H) ---*/
/* General device error return values */
public static final int MMSYSERR_NOERROR = 0; /* no error */
public static final int MMSYSERR_ERROR = 1; /* unspecified error */
public static final int MMSYSERR_BADDEVICEID = 2; /* device ID out of range */
public static final int MMSYSERR_NOTENABLED = 3; /* driver failed enable */
public static final int MMSYSERR_ALLOCATED = 4; /* device already allocated */
public static final int MMSYSERR_INVALHANDLE = 5; /* device handle is invalid */
public static final int MMSYSERR_NODRIVER = 6; /* no device driver present */
public static final int MMSYSERR_NOMEM = 7; /* memory allocation error */
public static final int MMSYSERR_NOTSUPPORTED= 8; /* function isn't supported */
public static final int MMSYSERR_BADERRNUM = 9; /* error value out of range */
public static final int MMSYSERR_INVALFLAG = 10; /* invalid flag passed */
public static final int MMSYSERR_INVALPARAM = 11; /* invalid parameter passed */
public static final int MMSYSERR_HANDLEBUSY = 12; /* handle being used */
/* MIDI error return values */
public static final int MIDIERR_UNPREPARED = 64; /* header not prepared */
public static final int MIDIERR_STILLPLAYING = 65; /* still something playing */
public static final int MIDIERR_NOMAP = 66; /* no configured instruments */
public static final int MIDIERR_NOTREADY = 67; /* hardware is still busy */
public static final int MIDIERR_NODEVICE = 68; /* port no longer connected */
public static final int MIDIERR_INVALIDSETUP = 69; /* invalid MIF */
public static final int MIDIERR_BADOPENMODE = 70; /* operation unsupported w/ open mode */
public static final int MIDIERR_DONT_CONTINUE= 71; /* thru device 'eating' a message */
/*------------ End of Constant Values --------------*/
/** MIDI device index
This number is valid and unchanging whether device is open or closed.
*/
protected int deviceId;
/** MIDI device handle
This number is valid only when the device is open, and may change
if the device is closed and then reopened
*/
protected int deviceHandle = 0;
/** Empty constructor not allowed */
private MidiDevice() throws MidiBadDeviceException {
throw new MidiBadDeviceException("Device ID not specified");
}
/** Construct a MidiDevice with a particular ID */
protected MidiDevice(int id) throws MidiBadDeviceException {
// MIDI_MAPPER is a Windows-defined MIDI filter used for performing MIDI
// message translation on the fly.
if (id < 0 && id != MIDI_MAPPER) {
throw new MidiBadDeviceException(id);
}
deviceId = id;
}
/** Open the device; initialize deviceHandle if successful */
public abstract void Open() throws MidiException;
/** Close the device */
public abstract void Close() throws MidiException;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -