aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-01 23:49:05 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-01 23:49:05 +0800
commit85ccf22f3d2340e80ce2a109bbe610da1b92ca7d (patch)
tree8127dc287d9a4df6a6c7985e55087491153b5523
parent90f018721ae7ee6ac154d757516378b9c45ec1bf (diff)
downloadQMidiPlayer-85ccf22f3d2340e80ce2a109bbe610da1b92ca7d.tar.xz
Give the visualization a clearer look...
Now highlights playing notes. Avoid a crash in file reading.
-rw-r--r--ChangeLog5
-rw-r--r--core/qmpmidiread.cpp11
-rw-r--r--include/qmpcorepublic.hpp7
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp5
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp2
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.hpp5
-rw-r--r--visualization/qmpvisualization.cpp11
7 files changed, 36 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d27893..2dda1bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
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.
2016-04-29 0.7.8 beta
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;i<sl.size();++i)
- {
ui->lwSoundfont->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 <map>
#include <QDialog>
#include <QCloseEvent>
#include <QSettings>
#include <QListWidget>
#include <QComboBox>
+#include <QFormLayout>
#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<std::string,QWidget*> customOptWidgets;
+ std::map<std::string,QFormLayout*> 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)*lpt<minnotelength/100.)a.z=((double)pool[i]->tcs-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);