aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp111
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp1
-rw-r--r--qmidiplayer-desktop/qmpplistwindow.cpp12
-rw-r--r--qmidiplayer-desktop/qmpplistwindow.hpp3
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp2
5 files changed, 47 insertions, 82 deletions
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 876b0e9..56d3824 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -229,6 +229,7 @@ void qmpMainWindow::dropEvent(QDropEvent *event)
for(int i=0;i<l.size();++i)
sl.push_back(l.at(i).toLocalFile());
plistw->insertItems(sl);
+ switchTrack(plistw->getLastItem());
}
void qmpMainWindow::dragEnterEvent(QDragEnterEvent *event)
{
@@ -259,32 +260,7 @@ void qmpMainWindow::updateWidgets()
}
else
{
- timer->stop();player->playerDeinit();playerTh->join();
- delete playerTh;playerTh=NULL;
- ui->hsTimer->setValue(0);
- for(int i=0;i<16;++i)if(VIs[i])VIs[i]->stop();
- if(singleFS)player->playerPanic(true);
- chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
- QString fns=plistw->getNextItem();setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.'))+" - QMidiPlayer");
- ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
- onfnChanged();
- LOAD_FILE;
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
- ui->lbFinTime->setText(ts);
- player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize();
- for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
- }}
- for(int i=0;i<16;++i)if(VIs[i])VIs[i]->start();
- player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
- player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt());
- playerTh=new std::thread(&CMidiPlayer::playerThread,player);
-#ifdef _WIN32
- SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL);
-#endif
- st=std::chrono::steady_clock::now();offset=0;
- timer->start(UPDATE_INTERVAL);
+
}
}
if(renderTh)
@@ -323,6 +299,35 @@ void qmpMainWindow::updateWidgets()
}
QString qmpMainWindow::getFileName(){return ui->lbFileName->text();}
+void qmpMainWindow::switchTrack(QString s)
+{
+ timer->stop();player->playerDeinit();playerTh->join();
+ delete playerTh;playerTh=NULL;
+ ui->hsTimer->setValue(0);
+ for(int i=0;i<16;++i)if(VIs[i])VIs[i]->stop();
+ if(singleFS)player->playerPanic(true);
+ chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
+ QString fns=s;setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.'))+" - QMidiPlayer");
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
+ onfnChanged();
+ LOAD_FILE;
+ char ts[100];
+ sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
+ ui->lbFinTime->setText(ts);
+ player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize();
+ for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
+ LOAD_SOUNDFONT;
+ }}
+ for(int i=0;i<16;++i)if(VIs[i])VIs[i]->start();
+ player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
+ player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt());
+ playerTh=new std::thread(&CMidiPlayer::playerThread,player);
+#ifdef _WIN32
+ SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL);
+#endif
+ st=std::chrono::steady_clock::now();offset=0;
+ timer->start(UPDATE_INTERVAL);
+}
std::string qmpMainWindow::getTitle()
{
if(!qmpSettingsWindow::getSettingsIntf())return "";
@@ -541,62 +546,12 @@ void qmpMainWindow::on_pbChannels_clicked()
void qmpMainWindow::on_pbPrev_clicked()
{
- timer->stop();player->playerDeinit();
- if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;}
- if(singleFS)player->playerPanic(true);
- for(int i=0;i<16;++i)if(VIs[i])VIs[i]->stop();
- ui->hsTimer->setValue(0);chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
- QString fns=plistw->getPrevItem();if(fns.length()==0)return on_pbStop_clicked();
- setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.'))+" - QMidiPlayer");
- ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
- onfnChanged();
- LOAD_FILE;
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
- ui->lbFinTime->setText(ts);
- player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize();
- for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
- }}
- for(int i=0;i<16;++i)if(VIs[i])VIs[i]->start();
- player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
- player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt());
- playerTh=new std::thread(&CMidiPlayer::playerThread,player);
-#ifdef _WIN32
- SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL);
-#endif
- st=std::chrono::steady_clock::now();offset=0;
- timer->start(UPDATE_INTERVAL);
+ switchTrack(plistw->getPrevItem());
}
void qmpMainWindow::on_pbNext_clicked()
{
- timer->stop();player->playerDeinit();
- if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;}
- if(singleFS)player->playerPanic(true);
- for(int i=0;i<16;++i)if(VIs[i])VIs[i]->stop();
- ui->hsTimer->setValue(0);chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
- QString fns=plistw->getNextItem();if(fns.length()==0)return on_pbStop_clicked();
- ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
- setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.'))+" - QMidiPlayer");
- onfnChanged();
- LOAD_FILE;
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
- ui->lbFinTime->setText(ts);
- player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize();
- for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
- }}
- for(int i=0;i<16;++i)if(VIs[i])VIs[i]->start();
- player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
- player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt());
- playerTh=new std::thread(&CMidiPlayer::playerThread,player);
-#ifdef _WIN32
- SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL);
-#endif
- st=std::chrono::steady_clock::now();offset=0;
- timer->start(UPDATE_INTERVAL);
+ switchTrack(plistw->getNextItem());
}
void qmpMainWindow::selectionChanged()
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index 71161c2..0b835e7 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -65,6 +65,7 @@ class qmpMainWindow:public QMainWindow
QTimer* getTimer(){return timer;}
bool isFinalizing(){return fin;}
QString getFileName();
+ void switchTrack(QString s);
std::string getTitle();
std::wstring getWTitle();
uint32_t getPlaybackPercentage();
diff --git a/qmidiplayer-desktop/qmpplistwindow.cpp b/qmidiplayer-desktop/qmpplistwindow.cpp
index 5805fcb..799f99a 100644
--- a/qmidiplayer-desktop/qmpplistwindow.cpp
+++ b/qmidiplayer-desktop/qmpplistwindow.cpp
@@ -228,11 +228,19 @@ void qmpPlistWindow::on_pbShuffle_clicked()
}
}
-QString qmpPlistWindow::getFirstItem()
+QString qmpPlistWindow::getFirstItem(bool a)
{
if(ui->lwFiles->count()==0)return QString();
int id=0;
- if(shuffle)id=rand()%ui->lwFiles->count();
+ if(shuffle&&!a)id=rand()%ui->lwFiles->count();
+ ui->lwFiles->setCurrentRow(id);
+ return ui->lwFiles->item(id)->text();
+}
+QString qmpPlistWindow::getLastItem(bool a)
+{
+ if(ui->lwFiles->count()==0)return QString();
+ int id=ui->lwFiles->count()-1;
+ if(shuffle&&!a)id=rand()%ui->lwFiles->count();
ui->lwFiles->setCurrentRow(id);
return ui->lwFiles->item(id)->text();
}
diff --git a/qmidiplayer-desktop/qmpplistwindow.hpp b/qmidiplayer-desktop/qmpplistwindow.hpp
index 6ceeb60..b1deab4 100644
--- a/qmidiplayer-desktop/qmpplistwindow.hpp
+++ b/qmidiplayer-desktop/qmpplistwindow.hpp
@@ -26,7 +26,8 @@ class qmpPlistWindow : public QDialog
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
int getRepeat();
- QString getFirstItem();
+ QString getFirstItem(bool a=false);
+ QString getLastItem(bool a=false);
QString getNextItem();
QString getPrevItem();
QString getSelectedItem();
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index 5de1dd5..7370e20 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -192,7 +192,7 @@ int qmpPluginAPI::registerVisualizationIntf(qmpVisualizationIntf* intf)
void qmpPluginAPI::unregisterVisualizationIntf(int intfhandle)
{qmw->unregisterVisualizationIntf(intfhandle);}
int qmpPluginAPI::registerFileReadFinishedHandlerIntf(IMidiCallBack* cb,void* userdata)
-{qmw->getPlayer()->setFileReadFinishedCB(cb,userdata);}
+{return qmw->getPlayer()->setFileReadFinishedCB(cb,userdata);}
void qmpPluginAPI::unregisterFileReadFinishedHandlerIntf(int intfhandle)
{qmw->getPlayer()->unsetFileReadFinishedCB(intfhandle);}
void qmpPluginAPI::registerFileReader(IMidiFileReader* reader,std::string name)