02-15-2024, 07:56 PM
Maybe the logic could be implemented as a spezial type of MidiEvent in MobileSheets directly.
Here is the code, I used for mapping Ketron BankNr / RegisterNr to Midi-CC / MIDI_PC
Code:
public class MidiEvent {
private int ketronBankNr = -1;
private int ketronRegNr = -1;
private int pc = -1;
private int cc = -1;
public MidiEvent(int ketronBankNr, int ketronRegisterNr){
if (ketronBankNr>4 | ketronBankNr < 1)
throw new IndexOutOfBoundsException("Registerbank ungültig");
if (ketronRegisterNr > 1000 | ketronRegisterNr < 1)
throw new IndexOutOfBoundsException("Registeriungsnummer ungültig");
this.ketronBankNr = ketronBankNr;
this.ketronRegNr = ketronRegisterNr;
calculateEvent();
}
/**
* @return the pc
*/
public int getPc() {
return pc;
}
/**
* @return the cc
*/
public int getCc() {
return cc;
}
@Override
public String toString(){
return String.format("BANK:%d REG:%d CC:%d PC:%d", ketronBankNr, ketronRegNr, cc, pc);
}
private void calculateEvent(){
int regNr = ketronRegNr -1; // Midi Offset 0; bank Offset 1;
int bankNr = ketronBankNr;
// Bank 1 - 4 => cc 0 = 0, 8, 16, 24
int bank[] = {0, 8, 16, 24};
// ControlChange 00:
// Value 0 - 7 Bank 1
// Value 8 - 15 Bank 2
// Value 16 - 23 Bank 3
// Value 24 - 31 Bank 4
// Regnr 0-127 cc 00 = 0;
// Regnr 128-255 cc 00 = 1;
// Regnr 256-382 cc 00 = 2;
// Regnr 382-509 cc 00 = 3;
// Regnr 509-636 cc 00 = 4;
// Regnr 636-763 cc 00 = 5;
// Regnr 763-890 cc 00 = 6;
// Regnr 890-1000 cc 00 = 7;
// Beim Überlauf über 10xx nächste Bank 8 und offset aus regNr wieder 0;
this.pc = regNr % 128;
this.cc = Math.round(regNr / 128) + bank[bankNr-1];
}
}