Frage

How do I control the volume of a MIDI sequencer?

Instead of everything just automatically stopping, I want the volume to fade out and close.

if (musicSr != null)
{
    musicSr.stop();
    musicSr.close();

    musicSr = null;
    musicS = null;

    File music = new File(midi);
    if(music.exists())
    {
        musicS = MidiSystem.getSequence(music);
    }

    // Create a sequencer for the sequence
    musicSr = MidiSystem.getSequencer();
    musicSr.open();
    musicSr.setSequence(musicS);
    musicSr.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
    musicSr.start();
}
War es hilfreich?

Lösung

Volume changes (and for that matter, any gradual changes) are not directly supported by the Sequencer interface.

To change the volume, you have to send actual volume change messages to the target device. That is, insert the control change messages into the sequencer's tracks at the appropriate time position.

To get a fade out effect, use multiple message with decreasing values.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top