aboutsummaryrefslogtreecommitdiff
path: root/visualization
diff options
context:
space:
mode:
Diffstat (limited to 'visualization')
-rw-r--r--visualization/extrasmeltutils.cpp12
-rw-r--r--visualization/extrasmeltutils.hpp2
-rw-r--r--visualization/qmpvirtualpiano3d.cpp2
-rw-r--r--visualization/qmpvisualization.cpp52
-rw-r--r--visualization/qmpvisualization.hpp11
5 files changed, 27 insertions, 52 deletions
diff --git a/visualization/extrasmeltutils.cpp b/visualization/extrasmeltutils.cpp
index 6c8dd93..7e766f4 100644
--- a/visualization/extrasmeltutils.cpp
+++ b/visualization/extrasmeltutils.cpp
@@ -3,9 +3,9 @@
#include <algorithm>
#include <smcolor.hpp>
#include "extrasmeltutils.hpp"
-SMELT* smEntity3DBuffer::sm=NULL;
-SMELT* smParticle::sm=NULL;
-SMELT* smParticleSystem::sm=NULL;
+SMELT* smEntity3DBuffer::sm=nullptr;
+SMELT* smParticle::sm=nullptr;
+SMELT* smParticleSystem::sm=nullptr;
smVertex makeVertex(float x,float y,float z,DWORD color,float tx,float ty)
{smVertex v;v.x=x;v.y=y;v.z=z;v.col=color;v.tx=tx;v.ty=ty;return v;}
void smEntity3D::addVerices(int n,...)
@@ -93,7 +93,7 @@ void smParticle::update()
q.v[3].x=v3.x+pos.x;q.v[3].y=v3.y+pos.y;q.v[3].z=v3.z+pos.z;
}
smParticleSystem::smParticleSystem()
-{sm=smGetInterface(SMELT_APILEVEL);particles.clear();posGenerator=NULL;active=false;}
+{sm=smGetInterface(SMELT_APILEVEL);particles.clear();posGenerator=nullptr;active=false;}
smParticleSystem::~smParticleSystem()
{for(unsigned i=0;i<particles.size();++i)delete particles[i];particles.clear();}
void smParticleSystem::setParticleSystemInfo(smParticleSystemInfo _psinfo)
@@ -104,7 +104,7 @@ void smParticleSystem::setPSEmissionPosGen(smPSEmissionPositionGenerator *_gen)
void smParticleSystem::setPSLookAt(smvec3d at){lookat=true;lookatpos=at;}
void smParticleSystem::unsetPSLookAt(){lookat=false;}
void smParticleSystem::startPS()
-{active=true;nemdelay=0;re.setSeed(time(NULL));}
+{active=true;nemdelay=0;re.setSeed(time(nullptr));}
void smParticleSystem::stopPS()
{active=false;}
void smParticleSystem::updatePS()
@@ -166,7 +166,7 @@ void smParticleSystem::updatePS()
}
}
while(!particles.empty()&&particles.back()->dead)
- {delete particles.back();particles.back()=NULL;particles.pop_back();}
+ {delete particles.back();particles.back()=nullptr;particles.pop_back();}
}
void smParticleSystem::renderPS()
{for(unsigned i=0;i<particles.size();++i)particles[i]->render();}
diff --git a/visualization/extrasmeltutils.hpp b/visualization/extrasmeltutils.hpp
index 08868a7..fe9bb73 100644
--- a/visualization/extrasmeltutils.hpp
+++ b/visualization/extrasmeltutils.hpp
@@ -42,7 +42,7 @@ class smXLinePSGenerator:public smPSEmissionPositionGenerator
smRandomEngine re;
double var;
public:
- smXLinePSGenerator(double _var){re.setSeed(time(NULL));var=_var;}
+ smXLinePSGenerator(double _var){re.setSeed(time(nullptr));var=_var;}
smvec3d genPos(){return smvec3d(re.nextDouble(-var,var),0,0);}
};
class smParticleSystemInfo
diff --git a/visualization/qmpvirtualpiano3d.cpp b/visualization/qmpvirtualpiano3d.cpp
index bd40524..b622dd5 100644
--- a/visualization/qmpvirtualpiano3d.cpp
+++ b/visualization/qmpvirtualpiano3d.cpp
@@ -12,7 +12,7 @@ qmpVirtualPiano3D::qmpVirtualPiano3D()
qmpVirtualPiano3D::~qmpVirtualPiano3D()
{
delete wkcf;delete wkeb;delete wkd;delete wkg;delete wka;delete bk;
- wkcf=wkeb=wkd=wkg=wka=bk=NULL;delete ebuf;ebuf=NULL;
+ wkcf=wkeb=wkd=wkg=wka=bk=nullptr;delete ebuf;ebuf=nullptr;
}
void qmpVirtualPiano3D::render(smvec3d p)
{
diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp
index 1452ca9..c8dbcff 100644
--- a/visualization/qmpvisualization.cpp
+++ b/visualization/qmpvisualization.cpp
@@ -41,9 +41,9 @@ bool cmp(MidiVisualEvent* a,MidiVisualEvent* b)
if(a->tcs<b->tcs)return true;if(a->tcs>b->tcs)return false;
if(a->tce<b->tce)return true;return false;
}
-void CReaderCallBack::callBack(void *callerdata,void *)
+void CReaderCallBack::callBack(const void *callerdata,void *)
{
- SEventCallBackData* cbd=(SEventCallBackData*)callerdata;
+ const SEvent* cbd=(const SEvent*)callerdata;
switch(cbd->type&0xF0)
{
case 0x80:
@@ -57,11 +57,11 @@ void CReaderCallBack::callBack(void *callerdata,void *)
break;
case 0xF0:
if(cbd->type==0xFF&&cbd->p1==0x58)
- par->tspool.push_back(std::make_pair(cbd->time,cbd->p2));
+ par->tspool.push_back(std::make_pair(cbd->time,(cbd->str[0]<<24)|(cbd->str[1]<<16)));
break;
}
}
-void CEventHandlerCallBack::callBack(void*,void*)
+void CEventHandlerCallBack::callBack(const void*,void*)
{
if(par->ctk>par->api->getCurrentTimeStamp()+par->api->getDivision()/3)
par->elb=0;
@@ -69,7 +69,7 @@ void CEventHandlerCallBack::callBack(void*,void*)
fprintf(stderr,"Visualization: out of sync! %u vs %u ad: %u\n",par->ctk,par->api->getCurrentTimeStamp());*/
par->ctk=par->api->getCurrentTimeStamp();
}
-void CFRFinishedCallBack::callBack(void*,void*)
+void CFRFinishedCallBack::callBack(const void*,void*)
{
std::sort(par->tspool.begin(),par->tspool.end());
for(uint32_t tk=0,n=4,s=0;tk<=par->api->getMaxTick();){
@@ -153,7 +153,7 @@ void qmpVisualization::showThread()
}else memset(pss,0,sizeof(pss));
if(showpiano&&!horizontal)for(int i=0;i<16;++i)p3d[i]=new qmpVirtualPiano3D();
memset(traveld,0,sizeof(traveld));
- if(noteappearance==1)nebuf=new smEntity3DBuffer();else nebuf=NULL;
+ if(noteappearance==1)nebuf=new smEntity3DBuffer();else nebuf=nullptr;
tdscn=sm->smTargetCreate(wwidth*wsupersample,wheight*wsupersample,wmultisample);
tdparticles=sm->smTargetCreate(wwidth*wsupersample,wheight*wsupersample,wmultisample);
if(!api->getOptionString("Visualization/font2").length()||!font.loadTTF(api->getOptionString("Visualization/font2").c_str(),fontsize))
@@ -206,7 +206,7 @@ void qmpVisualization::close()
{
rendererTh->join();
delete rendererTh;
- rendererTh=NULL;
+ rendererTh=nullptr;
}else return;
if(showpiano&&!horizontal)for(int i=0;i<16;++i)delete p3d[i];
@@ -746,7 +746,7 @@ void qmpVisualization::drawCube(smvec3d a,smvec3d b,DWORD col,SMTEX tex)
}
qmpVisualization::qmpVisualization(qmpPluginAPI* _api){api=_api;}
-qmpVisualization::~qmpVisualization(){api=NULL;}
+qmpVisualization::~qmpVisualization(){api=nullptr;}
void qmpVisualization::init()
{
cb=new CReaderCallBack(this);
@@ -754,17 +754,17 @@ void qmpVisualization::init()
h=new CMidiVisualHandler(this);
frcb=new CFRFinishedCallBack(this);
closeh=new CloseHandler(this);
- rendererTh=NULL;playing=false;
+ rendererTh=nullptr;playing=false;
memset(spectra,0,sizeof(spectra));
memset(spectrar,0,sizeof(spectrar));
api->registerFunctionality(this,"Visualization","Visualization",api->isDarkTheme()?":/img/visualization_i.svg":":/img/visualization.svg",0,true);
- uihb=api->registerUIHook("main.start",qmpVisualization::cbstart,(void*)this);
- uihs=api->registerUIHook("main.stop",qmpVisualization::cbstop,(void*)this);
- uihp=api->registerUIHook("main.pause",qmpVisualization::cbpause,(void*)this);
- uihr=api->registerUIHook("main.reset",qmpVisualization::cbreset,(void*)this);
- herif=api->registerEventReaderIntf(cb,NULL);
- hehif=api->registerEventHandlerIntf(hcb,NULL);
- hfrf=api->registerFileReadFinishedHandlerIntf(frcb,NULL);
+ uihb=api->registerUIHook("main.start",[this](const void*,void*){this->start();},nullptr);
+ uihs=api->registerUIHook("main.stop",[this](const void*,void*){this->stop();},nullptr);
+ uihp=api->registerUIHook("main.pause",[this](const void*,void*){this->pause();},nullptr);
+ uihr=api->registerUIHook("main.reset",[this](const void*,void*){this->reset();},nullptr);
+ herif=api->registerEventReaderIntf(cb,nullptr);
+ hehif=api->registerEventHandlerIntf(hcb,nullptr);
+ hfrf=api->registerFileReadFinishedHandlerIntf(frcb,nullptr);
api->registerOptionBool("Visualization-Appearance","Show Piano","Visualization/showpiano",true);
api->registerOptionBool("Visualization-Appearance","3D Notes","Visualization/3dnotes",true);
api->registerOptionBool("Visualization-Appearance","Arrange channels on a stair","Visualization/stairpiano",true);
@@ -850,26 +850,6 @@ const char* qmpVisualization::pluginGetName()
{return "QMidiPlayer Default Visualization Plugin";}
const char* qmpVisualization::pluginGetVersion()
{return "0.8.6";}
-void qmpVisualization::cbstart(void *,void *usrd)
-{
- qmpVisualization* v=(qmpVisualization*)usrd;
- v->start();
-}
-void qmpVisualization::cbstop(void *,void *usrd)
-{
- qmpVisualization* v=(qmpVisualization*)usrd;
- v->stop();
-}
-void qmpVisualization::cbpause(void *,void *usrd)
-{
- qmpVisualization* v=(qmpVisualization*)usrd;
- v->pause();
-}
-void qmpVisualization::cbreset(void *,void *usrd)
-{
- qmpVisualization* v=(qmpVisualization*)usrd;
- v->reset();
-}
void qmpVisualization::pushNoteOn(uint32_t tc,uint32_t ch,uint32_t key,uint32_t vel)
{
diff --git a/visualization/qmpvisualization.hpp b/visualization/qmpvisualization.hpp
index 23be1a9..4e0412b 100644
--- a/visualization/qmpvisualization.hpp
+++ b/visualization/qmpvisualization.hpp
@@ -18,7 +18,7 @@ class CReaderCallBack:public ICallBack
qmpVisualization *par;
public:
CReaderCallBack(qmpVisualization *_par){par=_par;}
- void callBack(void *callerdata,void *userdata);
+ void callBack(const void *callerdata,void *userdata);
};
class CEventHandlerCallBack:public ICallBack
{
@@ -26,7 +26,7 @@ class CEventHandlerCallBack:public ICallBack
qmpVisualization *par;
public:
CEventHandlerCallBack(qmpVisualization *_par){par=_par;}
- void callBack(void*,void*);
+ void callBack(const void*,void*);
};
class CFRFinishedCallBack:public ICallBack
{
@@ -34,7 +34,7 @@ class CFRFinishedCallBack:public ICallBack
qmpVisualization *par;
public:
CFRFinishedCallBack(qmpVisualization *_par){par=_par;}
- void callBack(void*,void*);
+ void callBack(const void*,void*);
};
struct MidiVisualEvent
{
@@ -95,11 +95,6 @@ class qmpVisualization:public qmpPluginIntf,public qmpFuncBaseIntf
void deinit();
const char* pluginGetName();
const char* pluginGetVersion();
-
- static void cbstart(void* cbd,void* usrd);
- static void cbstop(void* cbd,void* usrd);
- static void cbpause(void* cbd,void* usrd);
- static void cbreset(void* cbd,void* usrd);
};
class CMidiVisualHandler:public smHandler