Java Midi 音序器在几次后停止产生声音。如何调试/解决?
我正在编写一些代码来使用 Java 声音库播放音乐。
private Sequencer sequencer ;
...
void play(Sequence sequence) {
sequencer.open() ;
sequencer.setSequence(sequence) ;
sequencer.start() ; // plays sequence
sequencer.close() ;
}
当我调用 play 方法 19 次时,扬声器会发出声音。然而,当我调用它的第20次时,却没有发出任何声音。无论如何,这种情况总是会发生。我需要重新启动程序才能再次发出声音。
这个问题有一些解决方法吗?或者有什么方法可以调试这个?或者我可以在哪里获得 MIDI 声音 API 支持?
I'm writing some code to play music using the Java sound library.
private Sequencer sequencer ;
...
void play(Sequence sequence) {
sequencer.open() ;
sequencer.setSequence(sequence) ;
sequencer.start() ; // plays sequence
sequencer.close() ;
}
When I invoke the play method 19 times, sound comes out of my speaker. However, the 20th time I invoke it, no sound comes out. This always happens, no matter what. I need to restart the program to get sound again.
Is there some workaround for this issue? Or some way to debug this? Or some place I can get support on the MIDI sound API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道为什么它停止了。也许这与 MIDI 中只有 16 个通道有关,但您可以重复使用音序器并更改其序列,而不是多次打开音序器。这就是我所拥有的并且它对我有用:
I don't know why it stops. Maybe it has something to do with there being only 16 channels in midi, but rather than opening the sequencer multiple times, you can reuse the sequencer and change it's sequence. This is what I have and it works for me: