如何控制MIDI通道的音量
我有这个代码:
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
Instrument[] instrument = synthesizer.getDefaultSoundbank().getInstruments();
synthesizer.loadInstrument(instrument[29]);
MidiChannel[] channels = synthesizer.getChannels();
MidiChannel channel = channels[1];
channel.programChange(29);
channel.noteOn(noteNumber, 127);
Teszthang.sleep(2000);
channel.noteOff(noteNumber);
这是一个示例,以最大音量(127)播放声音 2 秒。但我想控制频道的音量,比如2秒后,音量再过2秒淡出。我怎么能这么做呢?我知道这些方法:
channel.controlChange(controller, value);
channel.setPolyPressure(noteNumber, pressure);
但这些方法不会改变任何音量!我不知道如何使用这些方法。在播放 noteOn()
后,如何更改频道的音量?
I have this code:
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
Instrument[] instrument = synthesizer.getDefaultSoundbank().getInstruments();
synthesizer.loadInstrument(instrument[29]);
MidiChannel[] channels = synthesizer.getChannels();
MidiChannel channel = channels[1];
channel.programChange(29);
channel.noteOn(noteNumber, 127);
Teszthang.sleep(2000);
channel.noteOff(noteNumber);
so this is an example, to play a sound in max volume (127) for 2 seconds. but i want to control the channel's volume, like after 2 seconds, the volume fade out in an another 2 seconds. How could I do that? I know these methods:
channel.controlChange(controller, value);
channel.setPolyPressure(noteNumber, pressure);
but these don't change any volume! I don't know how to use these methods. How could I change the channel's volume after the noteOn()
while it has been playing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 CC 7 设置频道音量。
请参阅:http://improv.sapp.org/doc/class/MidiOutput /controllers/controllers.html
You can use CC 7 for setting channel volume.
see: http://improv.sapp.org/doc/class/MidiOutput/controllers/controllers.html
有时,MIDI 文件中有一些音量事件,因此您无法更改通道音量。
获取序列后,删除这些事件:
Sometimes you have some volume events in the midi file so you cannot change channel volume.
After getting the sequence, remove these events :