* Loads the given sound from it's program memory to the edit buffer. This
* is a sort of reset.
*/
public void loadSoundFromProgramToEdit(int snd) {
assertValidSoundNumber(snd);
SysexMessage sms = new SysexMessage();
byte[] bytes = null;
bytes = new byte[12];
bytes[0] = (byte) SysexMessage.SYSTEM_EXCLUSIVE; // SysEx (SOX)
bytes[1] = RackAttack.WALDORF_MANUFACTURER_BYTE; // Waldorf (IDW)
bytes[2] = RackAttack.RACK_ATTACK_MODEL_BYTE; // RackAttack (IDM)
bytes[3] = 0x00; // Default ID (IDD)
bytes[4] = RackAttack.MOV_COMMAND; // CMD (SNDP)
bytes[5] = RackAttack.MCMD_RECALL_SOUND;
bytes[6] = RackAttack.MCMD_MOV1_RECALL_SOUND;
bytes[7] = (byte) (snd & 0xFF); // SNDN
bytes[8] = (byte) (bytes[4] + bytes[5] + bytes[6] + bytes[7] & 0x7F); // CKSUM
bytes[9] = (byte) SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE; // EOX
// a bit tricky but flushes SysEx-Buffers (in any sort of device)
bytes[10] = (byte) SysexMessage.SYSTEM_EXCLUSIVE; // SysEx (SOX)
bytes[11] = (byte) SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE; // EOX
try {
sms.setMessage(bytes, bytes.length);
enqueueEvent(sms);
} catch (InvalidMidiDataException e) {
log.error("error", e);
} catch (MidiUnavailableException e) {
log.error("error", e);