Java stop MIDI playback

前端 未结 2 1746
借酒劲吻你
借酒劲吻你 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:04

    I'm guessing you need to call Player.allNotesOff() before calling sequencer.stop(). Untested, so please let me know if it didn't work.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题