From 85ccf22f3d2340e80ce2a109bbe610da1b92ca7d Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 1 May 2016 23:49:05 +0800 Subject: Give the visualization a clearer look... Now highlights playing notes. Avoid a crash in file reading. --- ChangeLog | 5 +++++ core/qmpmidiread.cpp | 11 +++++++---- include/qmpcorepublic.hpp | 7 +++++++ qmidiplayer-desktop/qmpplugin.cpp | 5 +++++ qmidiplayer-desktop/qmpsettingswindow.cpp | 2 -- qmidiplayer-desktop/qmpsettingswindow.hpp | 5 +++++ visualization/qmpvisualization.cpp | 11 +++++++---- 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d27893..2dda1bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-04-30 0.7.8 beta +Give the visualization a clearer look... +Now highlights playing notes. +Avoid a crash in file reading. + 2016-04-30 0.7.8 beta Fixed a bug in RPN handling. diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp index 380b603..9b1d932 100644 --- a/core/qmpmidiread.cpp +++ b/core/qmpmidiread.cpp @@ -172,10 +172,13 @@ int CMidiFile::eventReader()//returns 0 if End of Track encountered error(0,"W: Unknown event type %#x",type); } lasttype=type;++curid; - SEvent* le=eventList[eventList.size()-1]; - SEventCallBackData cbd(le->type,le->p1,le->p2,le->time); - for(int i=0;i<16;++i)if(eventReaderCB[i]) - eventReaderCB[i]->callBack(&cbd,eventReaderCBuserdata[i]); + if(eventList.size()) + { + SEvent* le=eventList[eventList.size()-1]; + SEventCallBackData cbd(le->type,le->p1,le->p2,le->time); + for(int i=0;i<16;++i)if(eventReaderCB[i]) + eventReaderCB[i]->callBack(&cbd,eventReaderCBuserdata[i]); + } return 1; } void CMidiFile::trackChunkReader() diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp index 54365b6..e17bf84 100644 --- a/include/qmpcorepublic.hpp +++ b/include/qmpcorepublic.hpp @@ -71,16 +71,23 @@ class qmpPluginAPI virtual int registerEventHandlerIntf(IMidiCallBack* cb,void* userdata); virtual void unregisterEventHandlerIntf(int intfhandle); + //if desc=="", the option won't be visible in the settings form. + //it will only show up in the configuration file. virtual void registerOptionInt(std::string desc,std::string key,int min,int max,int defaultval); virtual int getOptionInt(std::string key); + virtual void setOptionInt(std::string key,int val); virtual void registerOptionUint(std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval); virtual unsigned getOptionUint(std::string key); + virtual void setOptionUint(std::string key,unsigned val); virtual void registerOptionBool(std::string desc,std::string key,bool defaultval); virtual bool getOptionBool(std::string key); + virtual void setOptionBool(std::string key,bool val); virtual void registerOptionDouble(std::string desc,std::string key,double min,double max,double defaultval); virtual double getOptionDouble(std::string key); + virtual void setOptionDouble(std::string key,double val); virtual void registerOptionString(std::string desc,std::string key,std::string defaultval); virtual std::string getOptionString(std::string key); + virtual void setOptionString(std::string key,std::string val); }; #ifdef QMP_MAIN } diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 7a250ff..ce041ec 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -120,11 +120,16 @@ void qmpPluginAPI::unregisterVisualizationIntf(int intfhandle) void qmpPluginAPI::registerOptionInt(std::string,std::string,int,int,int){} int qmpPluginAPI::getOptionInt(std::string){return 0;} +void qmpPluginAPI::setOptionInt(std::string,int){} void qmpPluginAPI::registerOptionUint(std::string,std::string,unsigned,unsigned,unsigned){} unsigned qmpPluginAPI::getOptionUint(std::string){return 0;} +void qmpPluginAPI::setOptionUint(std::string,unsigned){} void qmpPluginAPI::registerOptionBool(std::string,std::string,bool){} bool qmpPluginAPI::getOptionBool(std::string){return false;} +void qmpPluginAPI::setOptionBool(std::string,bool){} void qmpPluginAPI::registerOptionDouble(std::string,std::string,double,double,double){} double qmpPluginAPI::getOptionDouble(std::string){return 0;} +void qmpPluginAPI::setOptionDouble(std::string,double){} void qmpPluginAPI::registerOptionString(std::string,std::string,std::string){} std::string qmpPluginAPI::getOptionString(std::string){return "";} +void qmpPluginAPI::setOptionString(std::string,std::string){} diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp index d59d2be..a0daf48 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.cpp +++ b/qmidiplayer-desktop/qmpsettingswindow.cpp @@ -265,9 +265,7 @@ void qmpSettingsWindow::on_pbAdd_clicked() { QStringList sl=QFileDialog::getOpenFileNames(this,"Add File","","SoundFont files (*.sf2)"); for(int i=0;ilwSoundfont->addItem(new QListWidgetItem(sl.at(i))); - } } void qmpSettingsWindow::on_pbRemove_clicked() diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp index f7bfae9..554afd3 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.hpp +++ b/qmidiplayer-desktop/qmpsettingswindow.hpp @@ -1,11 +1,13 @@ #ifndef QMPSETTINGSWINDOW_H #define QMPSETTINGSWINDOW_H +#include #include #include #include #include #include +#include #include "qmpplugin.hpp" namespace Ui { @@ -23,6 +25,7 @@ class qmpSettingsWindow:public QDialog void settingsInit(); QListWidget* getSFWidget(); void updatePluginList(qmpPluginManager *pmgr); + int getOptionInt(std::string key); signals: void dialogClosing(); @@ -43,6 +46,8 @@ class qmpSettingsWindow:public QDialog private: Ui::qmpSettingsWindow *ui; void settingsUpdate(); + std::map customOptWidgets; + std::map customOptPages; static QSettings *settings; static QComboBox* outwidget; public: diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp index 1a11334..28a10d4 100644 --- a/visualization/qmpvisualization.cpp +++ b/visualization/qmpvisualization.cpp @@ -9,10 +9,14 @@ const int viewdist=100; const int notestretch=100;//length of quarter note const int minnotelength=100; const int noteappearance=1; -DWORD chcolors[]={0XFFFF0000,0XFFFF8000,0XFFFFBF00,0XFFFFFF00, +DWORD iccolors[]={0XFFFF0000,0XFFFF8000,0XFFFFBF00,0XFFFFFF00, 0XFFBFFF00,0XFF80FF00,0XFF00FF00,0XFF00FFBF, 0XFF00FFFF,0XFF333333,0XFF00BFFF,0XFF007FFF, 0XFF0000FF,0XFF7F00FF,0XFFBF00FF,0XFFFF00BF}; +DWORD accolors[]={0XFFFF9999,0XFFFFCC99,0XFFFFEE99,0XFFFFFF99, + 0XFFEEFF99,0XFFCCFF99,0XFF99FF99,0XFF99FFCC, + 0XFF99FFFF,0XFF999999,0XFF99EEFF,0XFF99CCFF, + 0XFF9999FF,0XFFCC99FF,0XFFEE99FF,0XFFFF99EE}; bool cmp(MidiVisualEvent* a,MidiVisualEvent* b) { @@ -138,16 +142,15 @@ bool qmpVisualization::update() if(api->getChannelMask(pool[i]->ch))continue; smvec3d a(((double)pool[i]->key-64),15+pool[i]->ch*-3.,((double)pool[i]->tce-ctk)*lpt); smvec3d b(((double)pool[i]->key-64)+.9,15+pool[i]->ch*-3.+.6,((double)pool[i]->tcs-ctk)*lpt); - if(pool[i]->tcs<=ctk&&pool[i]->tce>=ctk) + bool isnoteon=pool[i]->tcs<=ctk&&pool[i]->tce>=ctk;if(isnoteon) a.x=((double)pool[i]->key-64+api->getPitchBend(pool[i]->ch)), b.x=((double)pool[i]->key-64+api->getPitchBend(pool[i]->ch))+.9; if(((double)pool[i]->tce-pool[i]->tcs)*lpttcs-ctk)*lpt-minnotelength/100.; - drawCube(a,b,SETA(chcolors[pool[i]->ch],pool[i]->vel),0); + drawCube(a,b,SETA(isnoteon?accolors[pool[i]->ch]:iccolors[pool[i]->ch],int(pool[i]->vel*(isnoteon?2.0:1.6))),0); } } if(playing)ctk+=(int)(1e6/(api->getRawTempo()/api->getDivision())*sm->smGetDelta()); while(pool.size()&&((double)ctk-pool[elb]->tce)*lpt>viewdist*2)++elb; - //if(ctk>fintk)return true; sm->smRenderEnd(); for(int i=0;i<4;++i){q.v[i].col=0xFFFFFFFF;q.v[i].z=0;} q.tex=sm->smTargetTexture(tdscn); -- cgit v1.2.3