Skip to content

Commit

Permalink
Unspecified instruments are now listed as "unspecified", not "piano".
Browse files Browse the repository at this point in the history
  • Loading branch information
isalin committed Dec 23, 2018
1 parent ea6401b commit a57ddf1
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions TBbard/src/bard/MidiParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,37 +268,18 @@ private void estimateOctaveQuality(int instrument){

private void checkIfChannelIsIndexed(int instrument) {
if(instruments[instrument] != null) return;

System.out.println("Instrument in channel " + instrument + " does not appear to be indexed. Setting it to unspecified.");
try {
Synthesizer syn;

syn = MidiSystem.getSynthesizer();
//System.out.print("Channel: " + sm.getChannel() + " ");



syn.open();
Instrument[] instr = syn.getDefaultSoundbank().getInstruments();

//System.out.println();

Pattern pattern = Pattern.compile("Instrument: (.*?) +bank.*");
Matcher matcher = pattern.matcher(instr[instrument].toString());

if(matcher.matches()){
if(instruments[instrument] == null) instruments[instrument] = (instrument + 1) + ". " + matcher.group(1);
else {
if(!instruments[instrument].contains(matcher.group(1))) {
instruments[instrument] += ", " + matcher.group(1);
}
}

if(true){
if(instruments[instrument] == null) instruments[instrument] = (instrument + 1) + ". Unspecified";

}



//System.out.print(((ShortMessage) message).getData1());
} catch (MidiUnavailableException e) {
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Expand Down

0 comments on commit a57ddf1

Please sign in to comment.