break;
case 0x00: // nop
smafMessage = new NopMessage(duration);
break;
default:
smafMessage = new UndefinedMessage(duration);
Debug.println("unknown 0xff, 0x" + StringUtil.toHex2(e2));
break;
}
} else if (e1 != 0x00) { // note
int gateTime = readOneToTwo(is);
//Debug.println("gateTime: " + gateTime + ", 0x" + StringUtil.toHex4(gateTime));
smafMessage = getHandyPhoneStandardMessage(duration, e1, gateTime);
} else { // e1 == 0x00 other event
int e2 = read(is);
if (e2 == 0x00) {
int e3 = read(is);
if (e3 == 0x00) {
smafMessage = new EndOfSequenceMessage(duration);
} else {
smafMessage = new UndefinedMessage(duration);
Debug.println("unknown 0x00, 0x00, 0x" + StringUtil.toHex2(e3));
}
} else {
int channel = (e2 & 0xc0) >> 6;
int event = (e2 & 0x30) >> 4;
int data = e2 & 0x0f;
switch (event) {
case 3:
int value = read(is);
switch (data) {
case 0: // program change - 0x00 ~ 0x7f
smafMessage = new ProgramChangeMessage(duration, channel, value);
break;
case 1: // bank select - normal: 0x00 ~ 0x7f, drum: 0x80 ~ 0xff
smafMessage = new BankSelectMessage(duration, channel, value);
break;
case 2: // octave shift - 0x00, 0x01, 0x02, 0x03, 0x04, 0x81, 0x82, 0x83, 0x84
smafMessage = new OctaveShiftMessage(duration, channel, value);
break;
case 3: // modulation - 0x00 ~ 0x7f
smafMessage = new ModulationMessage(duration, channel, value);
break;
case 4: // pitch bend - 0x00 ~ 0x40 ~ 0x7f
smafMessage = new PitchBendMessage(duration, channel, value << 7);
break;
case 7: // volume - 0x00 ~ 0x7f
smafMessage = new VolumeMessage(duration, channel, value);
break;
case 0x0a: // pan - 0x00 ~ x040 ~ 0x7f
smafMessage = new PanMessage(duration, channel, value);
break;
case 0x0b: // expression - normal: 0x00 ~ 0x7f
smafMessage = new ExpressionMessage(duration, channel, value);
break;
default:
smafMessage = new UndefinedMessage(duration);
Debug.println("unknown 0x00, 0x" + StringUtil.toHex2(e2) + ", 3, " + StringUtil.toHex2(data));
break;
}
break;
case 2: // modulation (short) 0x01 ~ 0x0e