You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public abstract class OnMidiInputEventListener2 implements OnMidiInputEventListener{
public abstract void onSendData(@nonnull MidiInputDevice sender, @nonnull byte[] data, int offset, int count);
protected final void onSendData(@NonNull MidiInputDevice sender, int command) {
byte[] data = new byte[1];
data[0] = (byte)command;
onSendData(sender, data, 0, data.length);
}
protected final void onSendData(@NonNull MidiInputDevice sender, int command, int data1) {
byte[] data = new byte[2];
data[0] = (byte)command;
data[1] = (byte)data1;
onSendData(sender, data, 0, data.length);
}
protected final void onSendData(@NonNull MidiInputDevice sender, int command, int data1, int data2) {
byte[] data = new byte[3];
data[0] = (byte)command;
data[1] = (byte)data1;
data[2] = (byte)data2;
onSendData(sender, data, 0, data.length);
}
@Override
public void onMidiSystemExclusive(@NonNull MidiInputDevice sender, @NonNull byte[] systemExclusive) {
onSendData(sender, systemExclusive, 0, systemExclusive.length);
}
public static final int COMMAND_CH_NOTEOFF = 0x80;
public static final int COMMAND_CH_NOTEON = 0x90;
public static final int COMMAND_CH_POLYPRESSURE = 0xa0;
public static final int COMMAND_CH_CONTROLCHANGE = 0xb0;
public static final int COMMAND_CH_PROGRAMCHANGE = 0xc0;
public static final int COMMAND_CH_CHANNELPRESSURE = 0xd0;
public static final int COMMAND_CH_PITCH = 0xe0;
public static final int COMMAND_SYSEX = 0xf0;
public static final int COMMAND_MIDITIMECODE = 0xf1;
public static final int COMMAND_SONGPOSITION = 0xf2;
public static final int COMMAND_SONGSELECT = 0xf3;
public static final int COMMAND_F4 = 0xf4;
public static final int COMMAND_F5 = 0xf5;
public static final int COMMAND_TUNEREQUEST = 0xf6;
public static final int COMMAND_SYSEX_END = 0xf7;
public static final int COMMAND_TRANSPORT_MIDICLOCK = 0xf8;
public static final int COMMAND_F9 = 0xf9;
public static final int COMMAND_TRANSPOORT_START = 0xfa;
public static final int COMMAND_TRANSPORT_CONTINUE = 0xfb;
public static final int COMMAND_TRNASPORT_STOP = 0xfc;
public static final int COMMAND_FD = 0xfd;
public static final int COMMAND_ACTIVESENSING = 0xfe;
public static final int COMMAND_META_OR_RESET = 0xff;
@Override
public void onMidiNoteOff(@NonNull MidiInputDevice sender, int channel, int note, int velocity) {
if (channel < 0 || channel >= 16) {
return;
}
if (note < 0 || note >= 128) {
return;
}
if (velocity < 0 || velocity >= 128) {
return;
}
onSendData(sender, COMMAND_CH_NOTEOFF + channel, note, velocity);
}
@Override
public void onMidiNoteOn(@NonNull MidiInputDevice sender, int channel, int note, int velocity) {
if (channel < 0 || channel >= 16) {
return;
}
if (note < 0 || note >= 128) {
return;
}
if (velocity < 0 || velocity >= 128) {
return;
}
onSendData(sender, COMMAND_CH_NOTEON + channel, note, velocity);
}
@Override
public void onMidiPolyphonicAftertouch(@NonNull MidiInputDevice sender, int channel, int note, int pressure) {
if (channel < 0 || channel >= 16) {
return;
}
if (note < 0 || note >= 128) {
return;
}
if (pressure < 0 || pressure >= 128) {
return;
}
onSendData(sender, COMMAND_CH_POLYPRESSURE + channel, note, pressure);
}
@Override
public void onMidiControlChange(@NonNull MidiInputDevice sender, int channel, int function, int value) {
if (channel < 0 || channel >= 16) {
return;
}
if (function < 0 || function >= 128) {
return;
}
if (value < 0 || value >= 128) {
return;
}
onSendData(sender, COMMAND_CH_CONTROLCHANGE + channel, function, value);
}
@Override
public void onMidiProgramChange(@NonNull MidiInputDevice sender, int channel, int program) {
if (channel < 0 || channel >= 16) {
return;
}
if (program < 0 || program >= 128) {
return;
}
onSendData(sender, COMMAND_CH_CONTROLCHANGE + channel, program);
}
@Override
public void onMidiChannelAftertouch(@NonNull MidiInputDevice sender, int channel, int pressure) {
if (channel < 0 || channel >= 16) {
return;
}
if (pressure < 0 || pressure >= 128) {
return;
}
onSendData(sender, COMMAND_CH_CHANNELPRESSURE + channel, pressure);
}
@Override
public void onMidiPitchWheel(@NonNull MidiInputDevice sender, int channel, int amount) {
if (channel < 0 || channel >= 16) {
return;
}
if (amount < 0 || amount >= 161384) {
return;
}
int hi = (amount >> 7) & 0x7f;
int lo = (amount) & 0x7f;
onSendData(sender, COMMAND_CH_PITCH + channel, lo, hi);
}
@Override
public void onMidiTimeCodeQuarterFrame(@NonNull MidiInputDevice sender, int timing) {
if (timing < 0 || timing >= 128) {
return;
}
onSendData(sender, COMMAND_MIDITIMECODE,timing);
}
@Override
public void onMidiSongSelect(@NonNull MidiInputDevice sender, int song) {
if (song < 0 || song >= 128) {
return;
}
onSendData(sender, COMMAND_SONGSELECT,song);
}
@Override
public void onMidiSongPositionPointer(@NonNull MidiInputDevice sender, int position) {
if (position < 0 || position >= 16364) {
return;
}
int hi = (position >> 7) & 0x7f;
int lo = position & 0x7f;
onSendData(sender, COMMAND_SONGSELECT, lo, hi);
}
@Override
public void onMidiTuneRequest(@NonNull MidiInputDevice sender) {
onSendData(sender, COMMAND_TUNEREQUEST);
}
@Override
public void onMidiTimingClock(@NonNull MidiInputDevice sender) {
onSendData(sender, COMMAND_TRANSPORT_MIDICLOCK);
}
@Override
public void onMidiStart(@NonNull MidiInputDevice sender) {
onSendData(sender, COMMAND_TRANSPOORT_START);
}
@Override
public void onMidiContinue(@NonNull MidiInputDevice sender) {
onSendData(sender, COMMAND_TRANSPORT_CONTINUE);
}
@Override
public void onMidiStop(@NonNull MidiInputDevice sender) {
onSendData(sender, COMMAND_TRNASPORT_STOP);
}
@Override
public void onMidiActiveSensing(@NonNull MidiInputDevice sender) {
onSendData(sender, COMMAND_ACTIVESENSING);
}
@Override
public void onMidiReset(@NonNull MidiInputDevice sender) {
onSendData(sender, COMMAND_META_OR_RESET);
}
@Override
public void onRPNMessage(@NonNull MidiInputDevice sender, int channel, int function, int value) {
int rlsb = 100; //lo
int rmsb = 101; //hi
int rlsb_value = function & 0x7f;
int rmsb_value = (function >> 7) & 0x7f;
int msb = 6; //hi
int lsb = 38; //lo
int msb_value = (value >> 7) & 0x7f;
int lsb_value = value & 0x7f;
onSendData(sender, COMMAND_CH_CONTROLCHANGE+ channel, rmsb, rmsb_value);
onSendData(sender, COMMAND_CH_CONTROLCHANGE+ channel, rlsb, rlsb_value);
onSendData(sender, COMMAND_CH_CONTROLCHANGE + channel, msb, msb_value);
onSendData(sender, COMMAND_CH_CONTROLCHANGE+ channel, lsb, lsb_value);
}
@Override
public void onNRPNMessage(@NonNull MidiInputDevice sender, int channel, int function, int value) {
int nlsb = 98; //lo
int nmsb = 99; //hi
int rlsb_value = function & 0x7f;
int rmsb_value = (function >> 7) & 0x7f;
int msb = 6; //hi
int lsb = 38; //lo
int msb_value = (value >> 7) & 0x7f;
int lsb_value = value & 0x7f;
onSendData(sender, COMMAND_CH_CONTROLCHANGE+ channel, nmsb, rmsb_value);
onSendData(sender, COMMAND_CH_CONTROLCHANGE+ channel, nlsb, rlsb_value);
onSendData(sender, COMMAND_CH_CONTROLCHANGE + channel, msb, msb_value);
onSendData(sender, COMMAND_CH_CONTROLCHANGE+ channel, lsb, lsb_value);
}
}
`
The text was updated successfully, but these errors were encountered:
すいません。
教えてください。
OnMidiInputEventListener2をつくって、バイト配列に 復号しようとしているのですが、
最後のRPNとNRPのところ、7ビットか14ビットか判定できないので、複合できません。
パラメータに7ビットか14ビットか教えるものが欲しいです。
これであっているか、教えていただけますと幸いです。
`OnMidiInputEventListener2.java
package jp.kshoji.blemidi.listener;
import androidx.annotation.NonNull;
import org.star_advance.midimixer.libs.midi.MXMidiStatic;
import jp.kshoji.blemidi.device.MidiInputDevice;
public abstract class OnMidiInputEventListener2 implements OnMidiInputEventListener{
public abstract void onSendData(@nonnull MidiInputDevice sender, @nonnull byte[] data, int offset, int count);
}
`
The text was updated successfully, but these errors were encountered: