768 |
run() { |
run() { |
769 |
try { |
try { |
770 |
SamplerModel sm = CC.getSamplerModel(); |
SamplerModel sm = CC.getSamplerModel(); |
771 |
MidiInstrumentInfo[] iS = CC.getClient().getMidiInstruments(mapId); |
int[][] entries = CC.getClient().getMidiInstrumentEntries(mapId); |
772 |
MidiInstrumentMap map = sm.getMidiInstrumentMapById(mapId); |
MidiInstrumentMap map = sm.getMidiInstrumentMapById(mapId); |
773 |
|
System.out.println(entries.length); |
774 |
boolean found = false; |
boolean found = false; |
775 |
|
|
776 |
for(MidiInstrument instr : map.getAllMidiInstruments()) { |
for(MidiInstrument instr : map.getAllMidiInstruments()) { |
777 |
for(int i = 0; i < iS.length; i++) { |
for(int i = 0; i < entries.length; i++) { |
778 |
if(instr.getInfo().equals(iS[i])) { |
if(entries[i] == null) continue; |
779 |
iS[i] = null; |
|
780 |
|
if(equal(instr, entries[i])) { |
781 |
|
entries[i] = null; |
782 |
found = true; |
found = true; |
783 |
} |
} |
784 |
} |
} |
788 |
} |
} |
789 |
found = false; |
found = false; |
790 |
} |
} |
791 |
|
|
792 |
for(MidiInstrumentInfo mii : iS) { |
for(int[] entry : entries) { |
793 |
if(mii != null) { |
if(entry != null) { |
794 |
MidiInstrument instr = new MidiInstrument(mii); |
MidiInstrumentInfo i; |
795 |
map.mapMidiInstrument(mii.getEntry(), instr); |
i = CC.getClient().getMidiInstrumentInfo ( |
796 |
|
entry[0], entry[1], entry[2] |
797 |
|
); |
798 |
|
MidiInstrument instr = new MidiInstrument(i); |
799 |
|
map.mapMidiInstrument(i.getEntry(), instr); |
800 |
} |
} |
801 |
} |
} |
802 |
} catch(Exception x) { |
} catch(Exception x) { |
804 |
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
805 |
} |
} |
806 |
} |
} |
807 |
|
|
808 |
|
private boolean |
809 |
|
equal(MidiInstrument instr, int[] entry) { |
810 |
|
if ( |
811 |
|
instr.getInfo().getMapId() == entry[0] && |
812 |
|
instr.getInfo().getMidiBank() == entry[1] && |
813 |
|
instr.getInfo().getMidiProgram() == entry[2] |
814 |
|
) return true; |
815 |
|
|
816 |
|
return false; |
817 |
|
} |
818 |
|
|
819 |
|
public int |
820 |
|
getMapId() { return mapId; } |
821 |
|
|
822 |
|
/** |
823 |
|
* Used to decrease the traffic. All task in the queue |
824 |
|
* equal to this are removed. |
825 |
|
*/ |
826 |
|
public boolean |
827 |
|
equals(Object obj) { |
828 |
|
if(obj == null) return false; |
829 |
|
if(!(obj instanceof UpdateInstruments)) return false; |
830 |
|
if(((UpdateInstruments)obj).getMapId() != getMapId()) return false; |
831 |
|
|
832 |
|
return true; |
833 |
|
} |
834 |
} |
} |
835 |
|
|
836 |
} |
} |