Java stop MIDI playback

前端 未结 2 1753
借酒劲吻你
借酒劲吻你 2021-01-21 14:23

Hi I have java application which plays midi messages from sequence. I\'m doing this using jfugue library.

the problem is when I\'m tryingto stop playback with stop butto

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-21 15:05

    When MIDI plays music, it uses a combination of NOTE_ON and NOTE_OFF events. It sounds like when you press the stop button, the sequence is stopping after a NOTE_ON event had been sent, but before a NOTE_OFF event was sent. That means the sound will continue to play indefinitely.

    Player.allNotesOff() in JFugue makes a call to JavaSound's allNotesOff() method in the Channel class; this call is made for each MIDI Channel (there are 16 channels). It's unfortunate that this solution isn't working. Try calling Player.allNotesOff() after sequencer.stop(), see if that helps.

提交回复
热议问题