Skip to content

Commit

Permalink
Fix lingering notes with newer fluidsynth versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
chirs241097 committed Nov 10, 2023
1 parent 07ee50b commit 095716f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
19 changes: 12 additions & 7 deletions core/qmpmidiplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ SEvent *CMidiPlayer::getEvent(uint32_t id)
}
void CMidiPlayer::prePlayInit()
{
playerPanic(true);
playerReset();
for (size_t i = 0; i < mididev.size(); ++i)
if (mididev[i].refcnt)
mididev[i].dev->reset(0xFF);
Expand Down Expand Up @@ -382,16 +382,21 @@ CMidiPlayer::~CMidiPlayer()
delete midiFile;
delete midiReaders;
}
void CMidiPlayer::playerPanic(bool reset)
void CMidiPlayer::playerReset()
{
for (auto &i : mididev)
if (i.refcnt)
{
if (reset)
i.dev->reset(0xff);
else
for (uint8_t j = 0; j < 16; ++j)
i.dev->panic(j);
i.dev->reset(0xff);
}
}
void CMidiPlayer::playerPanic()
{
for (auto &i : mididev)
if (i.refcnt)
{
for (uint8_t j = 0; j < 16; ++j)
i.dev->panic(j);
}
}
bool CMidiPlayer::playerLoadFile(const char *fn)
Expand Down
3 changes: 2 additions & 1 deletion core/qmpmidiplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class CMidiPlayer
void playerInit();
void playerDeinit();
void playerThread();
void playerPanic(bool reset = false);
void playerReset();
void playerPanic();

//playing control methods
uint32_t getStamp(int id);
Expand Down
9 changes: 6 additions & 3 deletions qmidiplayer-desktop/qmpmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ void qmpMainWindow::updateWidgets()
}
delete playerTh;
playerTh = nullptr;
player->playerPanic(true);
player->playerPanic();
player->playerReset();
chnlw->on_pbUnmute_clicked();
chnlw->on_pbUnsolo_clicked();
ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
Expand Down Expand Up @@ -355,7 +356,8 @@ void qmpMainWindow::switchTrack(QString s, bool interrupt)
playerTh = nullptr;
}
timer->stop();
player->playerPanic(true);
player->playerPanic();
player->playerReset();
ui->hsTimer->setValue(0);
chnlw->on_pbUnmute_clicked();
chnlw->on_pbUnsolo_clicked();
Expand Down Expand Up @@ -669,7 +671,8 @@ void qmpMainWindow::on_pbStop_clicked()
player->playerDeinit();
setFuncEnabled("Render", stopped);
setFuncEnabled("ReloadSynth", stopped);
player->playerPanic(true);
player->playerPanic();
player->playerReset();
if (playerTh)
{
playerTh->join();
Expand Down

0 comments on commit 095716f

Please sign in to comment.