有人可以告诉我如何使用音库或合成器控制MIDI音序器的音量而不是吗?
我希望在按顺序继续播放下一个MIDI之前使MIDI淡出
if(midiplay)
{
midi = s + savereq;
try {
//System.out.println("Play MIDI " + midi);
if (musicSr != null)
{
/* This is where I want it to fade out*/
musicSr.stop(); //stop sequencer
musicSr.close(); //close sequencer
}
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(musicSr.LOOP_CONTINUOUSLY);
musicSr.start();
} catch (Exception ex) {
ex.printStackTrace();
}
midiplay = false;
}
答案 0 :(得分:4)
在每个曲目中,对于曲目中使用的每个频道,请拨打add以在适当的时间位置添加多个事件:
track.add(new MidiEvent(
new ShortMessage(ShortMessage.CONTROL_CHANGE, channel, 7, volume),
tick));