Methods Summary |
---|
private void | checkBank(int bank)
if (bank < 0 || bank > 16383) {
throw new IllegalArgumentException("Bank is out of range");
}
|
private void | checkChannel(int channel)
if (channel < 0 || channel > 15) {
throw new IllegalArgumentException("Channel is out of range");
}
|
private void | checkData(int data)
if (data < 0 || data > 127) {
throw new IllegalArgumentException("Data is out of range");
}
|
private void | checkLongMidiEvent(byte[] data, int offset, int length)
if (data == null) {
throw new IllegalArgumentException("Data is null for long MIDI event ");
} else if ((offset >= data.length) || (offset < 0)) {
if (data.length != 0) {
throw new IllegalArgumentException("Invalid offset for long MIDI event");
}
} else if ((length > data.length) || (length < 0)) {
throw new IllegalArgumentException("Length is out of range for long MIDI event");
}
|
private void | checkProgram(int program)
if (program < 0 || program > 127) {
throw new IllegalArgumentException("Program is out of range");
}
|
private void | checkState()
if (_player.state < Player.PREFETCHED) {
throw new IllegalStateException("Not prefetched");
}
|
private void | checkType(int type)
if (type < 0x80 || type > 0xFF || type == 0xF0 || type == 0xF7) {
throw new IllegalArgumentException("Type is out of range");
}
|
private void | checkVolume(int volume)
if (volume < 0 || volume > 127) {
throw new IllegalArgumentException("Volume is out of range");
}
|
public synchronized int[] | getBankList(boolean custom)
checkState();
int[] bl1 = new int[20];
int len = nGetBankList(_player.hNative, custom, bl1);
if(len < 0) throw new MediaException("BankList failure");
int[] bl2 = new int[len];
for(int i=0; i<len; i++)
bl2[i] = bl1[i];
return bl2;
|
public synchronized int | getChannelVolume(int channel)
checkState();
checkChannel(channel);
if (_player != null && _player.hNative != 0) {
return nGetChannelVolume(_player.hNative, channel);
} else {
return -1;
}
|
public synchronized java.lang.String | getKeyName(int bank, int prog, int key)
checkState();
checkBank(bank);
checkProgram(prog);
if((key < 0) || (key > 127))
throw new IllegalArgumentException("key out of range");
byte[] str = new byte[64];
int len = nGetKeyName(_player.hNative, bank, prog, key, str);
if(len < 0) throw new MediaException("KeyName failure");
return new String(str, 0, len);
|
public synchronized int | getMaxPitch()
if (_player != null && _player.hNative != 0) {
return nGetMaxPitch(_player.hNative);
} else {
return 0;
}
|
public synchronized int | getMaxRate()
if (_player != null && _player.hNative != 0) {
return nGetMaxRate(_player.hNative);
} else {
return 0;
}
|
public synchronized int | getMinPitch()
if (_player != null && _player.hNative != 0) {
return nGetMinPitch(_player.hNative);
} else {
return 0;
}
|
public synchronized int | getMinRate()
if (_player != null && _player.hNative != 0) {
return nGetMinRate(_player.hNative);
} else {
return 0;
}
|
public synchronized int | getPitch()
if (_player != null && _player.hNative != 0) {
return nGetPitch(_player.hNative);
} else {
return 0;
}
|
public synchronized int[] | getProgram(int channel)
checkState();
checkChannel(channel);
int[] p = new int[2];
int len = nGetProgram(_player.hNative, channel, p);
if(len < 0) throw new MediaException("GetProgram failure");
return p;
|
public synchronized int[] | getProgramList(int bank)
checkState();
checkBank(bank);
int[] pl1 = new int[200];
int len = nGetProgramList(_player.hNative, bank, pl1);
if(len < 0) throw new MediaException("ProgramList failure");
int[] pl2 = new int[len];
for(int i=0; i<len; i++)
pl2[i] = pl1[i];
return pl2;
|
public synchronized java.lang.String | getProgramName(int bank, int prog)
checkState();
checkBank(bank);
checkProgram(prog);
byte[] str = new byte[64];
int len = nGetProgramName(_player.hNative, bank, prog, str);
if(len < 0) throw new MediaException("ProgramName failure");
return new String(str, 0, len);
|
public synchronized int | getRate()
if (_player != null && _player.hNative != 0) {
return _cachedRate == -1 ? nGetRate(_player.hNative) : _cachedRate;
} else {
return 0;
}
|
public synchronized int | getTempo()
if (_player != null && _player.hNative != 0) {
return nGetTempo(_player.hNative);
} else {
return 0;
}
|
public synchronized boolean | isBankQuerySupported()
return nIsBankQuerySupported(_player.hNative);
|
public synchronized int | longMidiEvent(byte[] data, int offset, int length)
checkState();
checkLongMidiEvent(data, offset, length);
if (_player != null && _player.hNative != 0) {
return nLongMidiEvent(_player.hNative, data, offset, length);
} else {
return -1;
}
|
private native int | nGetBankList(int handle, boolean custom, int[] list)
|
private native int | nGetChannelVolume(int handle, int channel)
|
private native int | nGetKeyName(int handle, int bank, int prog, int key, byte[] keyname)
|
private native int | nGetMaxPitch(int handle)
|
private native int | nGetMaxRate(int handle)
|
private native int | nGetMinPitch(int handle)
|
private native int | nGetMinRate(int handle)
|
private native int | nGetPitch(int handle)
|
private native int | nGetProgram(int handle, int channel, int[] program)
|
private native int | nGetProgramList(int handle, int bank, int[] proglist)
|
private native int | nGetProgramName(int handle, int bank, int prog, byte[] progname)
|
private native int | nGetRate(int handle)
|
private native int | nGetTempo(int handle)
|
private native boolean | nIsBankQuerySupported(int handle)
|
private native int | nLongMidiEvent(int handle, byte[] data, int offset, int length)
|
private native void | nSetChannelVolume(int handle, int channel, int volume)
|
private native int | nSetPitch(int handle, int pitch)
|
private native void | nSetProgram(int handle, int channel, int bank, int program)
|
private native int | nSetRate(int handle, int rate)
|
private native int | nSetTempo(int handle, int tempo)
|
private native void | nShortMidiEvent(int handle, int type, int data1, int data2)
|
public synchronized void | playerClosed()
_player = null;
|
public synchronized void | playerStarted()
if (_cachedRate != -1) {
// NOTE - MMAPI SPEC is not clear about this
// set cached rate at enter playing state
nSetRate(_player.hNative, _cachedRate);
_cachedRate = -1;
}
|
public synchronized void | playerStopped()
|
public synchronized void | setChannelVolume(int channel, int volume)
checkState();
checkChannel(channel);
checkVolume(volume);
if (_player != null && _player.hNative != 0) {
nSetChannelVolume(_player.hNative, channel, volume);
}
|
public synchronized int | setPitch(int millisemitones)
int max = getMaxPitch();
int min = getMinPitch();
if (millisemitones > max) {
millisemitones = max;
} else if (millisemitones < min) {
millisemitones = min;
}
if (_player != null && _player.hNative != 0) {
return nSetPitch(_player.hNative, millisemitones);
} else {
return 0;
}
|
public synchronized void | setProgram(int channel, int bank, int program)
checkState();
checkChannel(channel);
if(bank != -1) checkBank(bank);
checkProgram(program);
if (_player != null && _player.hNative != 0) {
nSetProgram(_player.hNative, channel, bank, program);
}
|
public synchronized int | setRate(int millirate)
if (_player == null)
return 0;
int max = getMaxRate();
int min = getMinRate();
if (millirate > max) {
millirate = max;
} else if (millirate < min) {
millirate = min;
}
if (_player.state >= Player.STARTED) {
_cachedRate = -1;
return nSetRate(_player.hNative, millirate);
} else {
_cachedRate = millirate;
return millirate;
}
|
public synchronized int | setTempo(int millitempo)
if (millitempo < 0) {
millitempo = 0;
}
if (_player != null && _player.hNative != 0) {
return nSetTempo(_player.hNative, millitempo);
} else {
return 0;
}
|
public synchronized void | shortMidiEvent(int type, int data1, int data2)
checkState();
checkType(type);
checkData(data1);
checkData(data2);
if (_player != null && _player.hNative != 0) {
nShortMidiEvent(_player.hNative, type, data1, data2);
}
|