Reputation: 1253
I have used the same javax.sound.midi example as thequerist of question Terminate Java Midi output. There the question was about terminating a sequence after playing it once instead of looping it.
I wonder how I can "inject" a command to tell the sequencer (or rather the synthesizer?) to stop playing at the push of a button.
So far I've tried closing synthesizer and sequencer, but the sound is still playing. Also neither deleting the track nor switching off all notes in the cannels (as suggested in Java stop MIDI playback) worked:
if (synth != null) {
javax.sound.midi.MidiChannel[] channels = synth.getChannels();
channels[0].allNotesOff();
channels[0].allSoundOff();
}
I would like to be able to play another sequence after stopping the current one.
Upvotes: 0
Views: 526
Reputation: 20059
As far as I understand it, Midi support in the Sun JRE uses a completely external (and native) midi implementation. I had a number of issues with it myself (volume control not working properly, e.g. set volume to 0 and its still audible. Sound quality is also far below what other midi players deliver). There are probably limitations in the native bindings you can't easily work around.
I solved my issues by switching to Gervill, a pure java implementation that was intended as a replacement of the native java midi support (there are license issues preventing the midi part to be released as open source). AFAIK they did not switch for whatever reason, but maybe they still will in a future java release.
Upvotes: 1