How to control the MIDI channel's volume

后端 未结 2 1776
清酒与你
清酒与你 2020-12-19 14:46

I have this code:

Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
Instrument[] instrument = synthesizer.getDefaultSoundbank().getI         


        
相关标签:
2条回答
  • 2020-12-19 14:56

    You can use CC 7 for setting channel volume.

    channel.controlChange(7, value);
    

    see: http://improv.sapp.org/doc/class/MidiOutput/controllers/controllers.html

    0 讨论(0)
  • 2020-12-19 15:17

    Sometimes you have some volume events in the midi file so you cannot change channel volume. After getting the sequence, remove these events :

    Track[] tracks = sequence.getTracks();
    for (Track track : tracks){
    for(int i = 0; i < track.size(); i++){
        if(!track.remove(track.get(i))){
            System.out.println("MIDI Event not removed");
        }
    }}
    
    0 讨论(0)
提交回复
热议问题