[英]Pausing Java Sequencer Resets Tempo
我正在編寫一些代碼,這些代碼在運行時會自動開始播放midi序列,並且用戶可以通過按鍵隨時暫停。 他們的關鍵事件處理工作正常,但是,我得到一個非常奇怪的錯誤,其中暫停序列器:
public void pause() {
// if the sequencer is playing, pause its playback
if (this.isPlaying) {
this.sequencer.stop();
} else { // otherwise "restart" the music
this.sequencer.start();
}
this.isPlaying = !this.isPlaying;
}
重置音序器的速度。 歌曲/音序器開始以120000 MPQ播放(從我的輸入加載)並重置為500000 MPQ。 有誰知道為什么會發生這種情況? 謝謝。
事實證明,調用start()會將音序器的速度重置為默認值500000 mpq。 對於有同樣問題的人來說,這是解決方案:
public void pause() {
// if the sequencer is playing, pause its playback
if (this.isPlaying) {
this.sequencer.stop();
} else { // otherwise "restart" the music
// store the tempo before it gets reset
long tempo = this.sequencer.getTempoInMPQ();
// restart the sequencer
this.sequencer.start();
// set/fix the tempo
this.sequencer.setTempoInMPQ(tempo);
}
this.isPlaying = !this.isPlaying;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.