Changing the sequencer in a Sequencer object in MidiSystem

38 views Asked by At

I'm working on a Java program that uses a Sequencer that I get from MidiSystem while using a JFrame object that let's me pick different sequences to play. So far, the only way I can play a new sequence is to stop the program and start over. Is there a way I can change the sequence or track while the JFrame stays active instead of stopping the program and restarting. Thanks.

1

There are 1 answers

0
jjazzboss On
// Get the default sequencer connected to the default synth
Sequencer sequencer = MidiSystem.getSequencer();

// Create a Midi sequence
Sequence newSequence = new Sequence(...);

... // Add track(s) to newSequence

// Sets the current sequence on which the sequencer operates.
sequencer.setSequence(sequence)