Skip to content

Commit

Permalink
Fix #84
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Apr 12, 2022
1 parent a54b713 commit 195e5ba
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/main/java/io/github/arrayv/utils/Sounds.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.arrayv.utils;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -342,20 +343,14 @@ public String[] getInstrumentList() {
}

private void loadInstruments(InputStream stream) {
try {
this.synth.loadAllInstruments(MidiSystem.getSoundbank(stream));
try (BufferedInputStream bis = new BufferedInputStream(stream)) {
this.synth.loadAllInstruments(MidiSystem.getSoundbank(bis));
} catch (NullPointerException e) {
JErrorPane.invokeCustomErrorMessage("soundfont/sfx.sf2 missing: Couldn't find the default soundbank for the program's sound effects! The OS default will be used instead.");
} catch (InvalidMidiDataException e) {
JErrorPane.invokeCustomErrorMessage("soundfont/sfx.sf2 invalid or corrupt: The file for the program's default soundbank was not recognized as a proper MIDI soundfont! The OS default will be used instead.");
} catch (IOException e) {
JErrorPane.invokeErrorMessage(e);
} finally {
try {
stream.close();
} catch (Exception e) {
JErrorPane.invokeErrorMessage(e);
}
}

if (this.channels == null) {
Expand Down

0 comments on commit 195e5ba

Please sign in to comment.