aboutsummaryrefslogtreecommitdiff
path: root/visualization
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-01 17:25:08 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-01 17:25:08 +0800
commitafeb558e50ad8d80f044439d39193d1cbc566580 (patch)
treeb5a692ee2994ced73a3d5832857db1a5e4597b88 /visualization
parent893bec26cd1bc83fd85bb7dfdfd6225d9f6ee5b5 (diff)
downloadQMidiPlayer-afeb558e50ad8d80f044439d39193d1cbc566580.tar.xz
Fixed visualization viewport randomly reverting to default.
Fixed unexpected pitch wheel activity in rendered video. Remove type checking in the option syntax.
Diffstat (limited to 'visualization')
-rw-r--r--visualization/qmpvisualization.cpp49
-rw-r--r--visualization/renderer/main.cpp2
-rw-r--r--visualization/renderer/qmppluginapistub.cpp4
-rw-r--r--visualization/renderer/qmpsettingsro.cpp58
-rw-r--r--visualization/renderer/qmpvisrendercore.cpp4
-rw-r--r--visualization/renderer/qmpvisrendercore.hpp1
6 files changed, 39 insertions, 79 deletions
diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp
index d63b1e3..09f80d6 100644
--- a/visualization/qmpvisualization.cpp
+++ b/visualization/qmpvisualization.cpp
@@ -129,28 +129,22 @@ void qmpVisualization::showThread()
if(!font2.loadTTF((std::string(getenv("windir")?getenv("windir"):"")+"/Fonts/msyh.ttc").c_str(),fontsize))
if(!font2.loadTTF((std::string(getenv("windir")?getenv("windir"):"")+"/Fonts/segoeui.ttf").c_str(),fontsize))
fprintf(stderr,"W: Font load failed.\n");
- if(horizontal)
- {
- pos[0]=-20;pos[1]=45;pos[2]=0;
- rot[0]=0;rot[1]=90;rot[2]=90;
- }
- else
+ if(pos[0]<-1e8)
{
- pos[0]=0;pos[1]=120;pos[2]=70;
- rot[0]=0;rot[1]=75;rot[2]=90;
+ if(horizontal)
+ {
+ pos[0]=-20;pos[1]=45;pos[2]=0;
+ rot[0]=0;rot[1]=90;rot[2]=90;
+ }
+ else
+ {
+ pos[0]=0;pos[1]=120;pos[2]=70;
+ rot[0]=0;rot[1]=75;rot[2]=90;
+ }
}
debug=false;
ctk=api->getCurrentTimeStamp();
lst=std::chrono::steady_clock::now();
- if(savevp)
- {
- pos[0]=api->getOptionDouble("Visualization/px");
- pos[1]=api->getOptionDouble("Visualization/py");
- pos[2]=api->getOptionDouble("Visualization/pz");
- rot[0]=api->getOptionDouble("Visualization/rx");
- rot[1]=api->getOptionDouble("Visualization/ry");
- rot[2]=api->getOptionDouble("Visualization/rz");
- }
sm->smMainLoop();
sm->smFinale();
}
@@ -943,12 +937,12 @@ void qmpVisualization::init()
api->registerOptionInt("Visualization-Appearance","Minimum note length","Visualization/minnotelen",20,500,100);
api->registerOptionUint("Visualization-Appearance","Chequer board tint (AARRGGBB)","Visualization/chkrtint",0,0xFFFFFFFF,0xFF999999);
api->registerOptionString("Visualization-Appearance","Background Image","Visualization/background","",true);
- api->registerOptionDouble("","","Visualization/px",-999999999,999999999,0);
- api->registerOptionDouble("","","Visualization/py",-999999999,999999999,120);
- api->registerOptionDouble("","","Visualization/pz",-999999999,999999999,70);
- api->registerOptionDouble("","","Visualization/rx",-999999999,999999999,0);
- api->registerOptionDouble("","","Visualization/ry",-999999999,999999999,75);
- api->registerOptionDouble("","","Visualization/rz",-999999999,999999999,90);
+ api->registerOptionDouble("","","Visualization/px",-999999999,999999999,-1e9);
+ api->registerOptionDouble("","","Visualization/py",-999999999,999999999,-1e9);
+ api->registerOptionDouble("","","Visualization/pz",-999999999,999999999,-1e9);
+ api->registerOptionDouble("","","Visualization/rx",-999999999,999999999,-1e9);
+ api->registerOptionDouble("","","Visualization/ry",-999999999,999999999,-1e9);
+ api->registerOptionDouble("","","Visualization/rz",-999999999,999999999,-1e9);
for(int i=0;i<16;++i)
{
api->registerOptionUint("","","Visualization/chActiveColor"+std::to_string(i),0,0xFFFFFFFF,accolors[i]);
@@ -980,6 +974,15 @@ void qmpVisualization::init()
accolors[i]=api->getOptionUint("Visualization/chActiveColor"+std::to_string(i));
iccolors[i]=api->getOptionUint("Visualization/chInactiveColor"+std::to_string(i));
}
+ if(savevp)
+ {
+ pos[0]=api->getOptionDouble("Visualization/px");
+ pos[1]=api->getOptionDouble("Visualization/py");
+ pos[2]=api->getOptionDouble("Visualization/pz");
+ rot[0]=api->getOptionDouble("Visualization/rx");
+ rot[1]=api->getOptionDouble("Visualization/ry");
+ rot[2]=api->getOptionDouble("Visualization/rz");
+ }
memset(pss,0,sizeof(pss));
}
void qmpVisualization::deinit()
diff --git a/visualization/renderer/main.cpp b/visualization/renderer/main.cpp
index cca8a12..c15d846 100644
--- a/visualization/renderer/main.cpp
+++ b/visualization/renderer/main.cpp
@@ -25,9 +25,9 @@ int main(int argc,char **argv)
qmpVisRenderCore core(&clp);
if(clp.positionalArguments().empty())
clp.showHelp(1);
+ core.loadSettings();
if(!core.loadVisualizationLibrary())
return 1;
- core.loadSettings();
if(clp.positionalArguments().size())
core.setMIDIFile(clp.positionalArguments().front().toStdString().c_str());
core.startRender();
diff --git a/visualization/renderer/qmppluginapistub.cpp b/visualization/renderer/qmppluginapistub.cpp
index d37e191..1be4880 100644
--- a/visualization/renderer/qmppluginapistub.cpp
+++ b/visualization/renderer/qmppluginapistub.cpp
@@ -79,12 +79,16 @@ int qmpPluginAPIStub::registerUIHook(std::string e, callback_t cb, void *userdat
{
if(e=="main.start")
core->startcb=cb;
+ if(e=="main.reset")
+ core->resetcb=cb;
return 0;
}
void qmpPluginAPIStub::unregisterUIHook(std::string e, int hook)
{
if(e=="main.start")
core->startcb=nullptr;
+ if(e=="main.reset")
+ core->resetcb=nullptr;
}
void qmpPluginAPIStub::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name){}
diff --git a/visualization/renderer/qmpsettingsro.cpp b/visualization/renderer/qmpsettingsro.cpp
index a66943b..bf8096f 100644
--- a/visualization/renderer/qmpsettingsro.cpp
+++ b/visualization/renderer/qmpsettingsro.cpp
@@ -168,59 +168,7 @@ void qmpSettingsRO::load(const char *path)
void qmpSettingsRO::setopt(std::string key, std::string val)
{
- if(options.find(key)==options.end())
- {
- std::string nkey="Visualization/"+key;
- if(options.find(nkey)==options.end())
- {
- qDebug("invalid option key %s",key.c_str());
- return;
- }
- else key=nkey;
- }
- char *rptr;
- switch(options[key].type)
- {
- case qmpOptionR::ParameterType::parameter_int:
- {
- long long v=strtoll(val.c_str(),&rptr,10);
- if(rptr==val.c_str()||v>INT_MAX||v<INT_MIN)
- qDebug("invalid value for option %s",key.c_str());
- setOptionInt(key,static_cast<int>(v));
- }
- break;
- case qmpOptionR::ParameterType::parameter_uint:
- {
- long long v=strtoll(val.c_str(),&rptr,10);
- if(rptr==val.c_str()||v>UINT32_MAX||v<0)
- qDebug("invalid value for option %s",key.c_str());
- setOptionUint(key,static_cast<uint32_t>(v));
- }
- break;
- case qmpOptionR::ParameterType::parameter_double:
- {
- errno=0;
- double v=strtod(val.c_str(),&rptr);
- if(rptr==val.c_str()||errno)
- qDebug("invalid value for option %s",key.c_str());
- setOptionDouble(key,v);
- }
- break;
- case qmpOptionR::ParameterType::parameter_bool:
- {
- if(val!="true"&&val!="false")
- qDebug("invalid value for option %s",key.c_str());
- setOptionBool(key,val=="true");
- }
- break;
- case qmpOptionR::ParameterType::parameter_str:
- case qmpOptionR::ParameterType::parameter_url:
- setOptionString(key,val);
- break;
- case qmpOptionR::ParameterType::parameter_enum:
- setOptionEnumIntOptName(key,val);
- break;
- default:
- break;
- }
+ settings.insert(QString(key.c_str()),QString(val.c_str()));
+ if(key.find("Visualization/")!=0)
+ settings.insert("Visualization/"+QString(key.c_str()),QString(val.c_str()));
}
diff --git a/visualization/renderer/qmpvisrendercore.cpp b/visualization/renderer/qmpvisrendercore.cpp
index a2733a7..d4acea9 100644
--- a/visualization/renderer/qmpvisrendercore.cpp
+++ b/visualization/renderer/qmpvisrendercore.cpp
@@ -36,6 +36,7 @@ bool qmpVisRenderCore::loadVisualizationLibrary()
vp=getintf(api);
switchmode(&qmpVisRenderCore::framefunc,!clp->isSet("show-window"));
vp->init();
+ resetcb(nullptr,nullptr);
return true;
}
@@ -53,7 +54,10 @@ void qmpVisRenderCore::loadSettings()
{
int sp=o.indexOf('=');
if(!~sp)
+ {
qDebug("invalid option pair: %s",o.toStdString().c_str());
+ continue;
+ }
QString key=o.left(sp);
QString value=o.mid(sp+1);
msettings->setopt(key.toStdString(),value.toStdString());
diff --git a/visualization/renderer/qmpvisrendercore.hpp b/visualization/renderer/qmpvisrendercore.hpp
index 27337ba..d32e4d7 100644
--- a/visualization/renderer/qmpvisrendercore.hpp
+++ b/visualization/renderer/qmpvisrendercore.hpp
@@ -33,6 +33,7 @@ private:
qmpPluginIntf *vp;
qmpFuncBaseIntf *vf;
callback_t startcb;
+ callback_t resetcb;
void *mp;
qmpPluginAPIStub *api;
CMidiPlayer *player;