问题
Following this Midi player and wanted to add a Custom Control (CC) to reduce Channel 0 and 1 volume to 10% using ShortMessage: http://www.jsresources.org/examples/MidiPlayer.html
I find it didn't reduce the volume right after the midi song start playing.
ShortMessage volMessage = new ShortMessage();
for(int i=0;i<2;i++) {
try{
volMessage.setMessage(ShortMessage.CONTROL_CHANGE,i, 7, 10);
} catch(InvalidMidiDataException e) {}
midiReceiver.send(volMessage,-1);
}
Has anyone done using ShortMessage to control MIDI channels?
回答1:
You're attempting to end the message in the catch
block - it should be immediately after the .setMessage()
call in the try
block!
回答2:
MIDI CC 7 will only act as a volume control if the instrument conforms to the GM (General MIDI) standard. If you want to control the volume, you should do it in the mixer with the rendered audio output.
Also, if I'm not mistaken, the 2nd data byte is a value between 0-127, not 0-100. So if you want 10% volume, that would be a value of 12 or 13. ;)
来源:https://stackoverflow.com/questions/9108996/midi-song-with-cc