diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-05-24 19:52:08 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-05-24 19:52:08 +0800 |
commit | ded6dd1c8f7cbe2991e90f69f95730b39eaa95cf (patch) | |
tree | 46f55ade709960f4407b836432b76901d00aa693 | |
parent | b059dd6fa25ad50f549cb1384042b07b6cfe06bf (diff) | |
download | QMidiPlayer-ded6dd1c8f7cbe2991e90f69f95730b39eaa95cf.tar.xz |
Add seeking with arrow buttons in visualization.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | doc/visualization.html | 18 | ||||
-rw-r--r-- | include/qmpcorepublic.hpp | 2 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpmainwindow.cpp | 26 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpmainwindow.hpp | 2 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.cpp | 4 | ||||
-rw-r--r-- | qmidiplayer.pro | 7 | ||||
-rw-r--r-- | visualization/qmpvisualization.cpp | 4 |
8 files changed, 54 insertions, 14 deletions
@@ -1,3 +1,6 @@ +2016-05-24 0.8.1 alpha +Add seeking with arrow buttons in visualization. + 2016-05-23 0.8.1 alpha Add horizontal visualization mode. Add build date in version page. @@ -313,4 +316,4 @@ Implemented the play list. Implemented the stop button, fixed several bugs. 2015-12-25 primitive version -Implemented the GUI based on the previous CLI version.
\ No newline at end of file +Implemented the GUI based on the previous CLI version. diff --git a/doc/visualization.html b/doc/visualization.html index b35d3de..d11f3fa 100644 --- a/doc/visualization.html +++ b/doc/visualization.html @@ -32,15 +32,15 @@ <h3>Controls</h3> <pre> forward - | ↱Hold left mouse button and drag: - up | down ┌──┬──┐ Adjust viewport. - ↓ ↓ ↓ │ │ │ - Q W E R←reset viewport ├──┴──┤ - A S D │ │ - ↑ ↑ ↑ │ │ -left | right │ │ - | └─────┘ - backward + | ↱Hold left mouse button and drag: + up | down ┌──┬──┐ Adjust viewport. + ↓ ↓ ↓ │ │ │ + Q W E R←reset viewport ├──┴──┤ + A S D │ │ + ↑ ↑ ↑ │ │ +left | right ← → │ │ + | Seek left/right └─────┘ + backward (Hold shift to seek 5% instead of 1%) </pre> <h3>Options</h3> <ul> diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp index 17a3910..13afe3e 100644 --- a/include/qmpcorepublic.hpp +++ b/include/qmpcorepublic.hpp @@ -67,6 +67,8 @@ class qmpPluginAPI virtual uint32_t getCurrentPolyphone(); virtual uint32_t getMaxPolyphone(); virtual uint32_t getCurrentTimeStamp(); + virtual uint32_t getCurrentPlaybackPercentage(); + virtual void playerSeek(uint32_t percentage); virtual double getPitchBend(int ch); virtual bool getChannelMask(int ch); virtual std::string getTitle(); diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp index de15412..73724ec 100644 --- a/qmidiplayer-desktop/qmpmainwindow.cpp +++ b/qmidiplayer-desktop/qmpmainwindow.cpp @@ -425,7 +425,7 @@ void qmpMainWindow::on_hsTimer_sliderReleased() } else { - if(stopped){ui->hsTimer->setValue(0);}return; + if(stopped){ui->hsTimer->setValue(0);return;} player->setTCeptr(player->getStamp(ui->hsTimer->value()),ui->hsTimer->value()); offset=ui->hsTimer->value()/100.*player->getFtime(); char ts[100]; @@ -434,6 +434,30 @@ void qmpMainWindow::on_hsTimer_sliderReleased() } } +uint32_t qmpMainWindow::getPlaybackPercentage(){return ui->hsTimer->value();} +void qmpMainWindow::playerSeek(uint32_t percentage) +{ + if(percentage>100)percentage=100; + if(percentage<0)percentage=0; + if(playing) + { + if(percentage==100){on_pbNext_clicked();return;} + player->setTCeptr(player->getStamp(percentage),percentage); + player->playerPanic();ui->hsTimer->setValue(percentage); + offset=percentage/100.*player->getFtime(); + st=std::chrono::steady_clock::now(); + } + else + { + if(stopped){ui->hsTimer->setValue(0);return;} + player->setTCeptr(player->getStamp(percentage),percentage); + offset=percentage/100.*player->getFtime();ui->hsTimer->setValue(percentage); + char ts[100]; + sprintf(ts,"%02d:%02d",(int)(offset)/60,(int)(offset)%60); + ui->lbCurTime->setText(ts); + } +} + void qmpMainWindow::on_vsMasterVol_valueChanged() { if(!stopped)player->setGain(ui->vsMasterVol->value()/250.); diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp index 9fc5d14..ef07798 100644 --- a/qmidiplayer-desktop/qmpmainwindow.hpp +++ b/qmidiplayer-desktop/qmpmainwindow.hpp @@ -64,6 +64,8 @@ class qmpMainWindow:public QMainWindow QString getFileName(); std::string getTitle(); std::wstring getWTitle(); + uint32_t getPlaybackPercentage(); + void playerSeek(uint32_t percentage); int pharseArgs(); int registerVisualizationIntf(qmpVisualizationIntf* intf); void unregisterVisualizationIntf(int handle); diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 565bdf1..7d6f36e 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -128,6 +128,10 @@ uint32_t qmpPluginAPI::getMaxPolyphone() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getMaxPolyphone():0;} uint32_t qmpPluginAPI::getCurrentTimeStamp() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getTick():0;} +uint32_t qmpPluginAPI::getCurrentPlaybackPercentage() +{return qmw?qmw->getPlaybackPercentage():0;} +void qmpPluginAPI::playerSeek(uint32_t percentage) +{if(qmw)qmw->playerSeek(percentage);} double qmpPluginAPI::getPitchBend(int ch) {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getPitchBend(ch):0;} bool qmpPluginAPI::getChannelMask(int ch) diff --git a/qmidiplayer.pro b/qmidiplayer.pro index 3466c67..62515f5 100644 --- a/qmidiplayer.pro +++ b/qmidiplayer.pro @@ -4,12 +4,13 @@ TEMPLATE = subdirs SUBDIRS = \ qmidiplayer-desktop \ qmidiplayer-lite \ - visualization + sample-plugin } android { SUBDIRS = \ qmidiplayer-lite } -SUBDIRS += \ - sample-plugin +!win32 { +SUBDIRS += visualization\ +} diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp index 4042a24..e9d1977 100644 --- a/visualization/qmpvisualization.cpp +++ b/visualization/qmpvisualization.cpp @@ -247,6 +247,10 @@ bool qmpVisualization::update() if(sm->smGetKeyState(SMK_O))rot[2]-=1; //printf("pos: %f %f %f\n",pos[0],pos[1],pos[2]); //printf("rot: %f %f %f\n",rot[0],rot[1],rot[2]); + if(sm->smGetKeyState(SMK_RIGHT)==SMKST_HIT) + api->playerSeek(api->getCurrentPlaybackPercentage()+(sm->smGetKeyState(SMK_SHIFT)?5:1)); + if(sm->smGetKeyState(SMK_LEFT)==SMKST_HIT) + api->playerSeek(api->getCurrentPlaybackPercentage()-(sm->smGetKeyState(SMK_SHIFT)?5:1)); double lpt=(double)notestretch/api->getDivision()/10.*(horizontal?0.25:1); memset(notestatus,0,sizeof(notestatus)); for(uint32_t i=elb;i<pool.size();++i) |