aboutsummaryrefslogtreecommitdiff
path: root/visualization
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-12 23:33:51 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-12 23:33:51 +0800
commita84ae874f0334172900d611fc098de8433f54e4c (patch)
tree4f2b185dfa734ad5cf2ede916a07573efe8a310a /visualization
parent59304aa1b2c6d278e76f72509183fee96bbb8cae (diff)
downloadQMidiPlayer-a84ae874f0334172900d611fc098de8433f54e4c.tar.xz
Now channel labels are displayed correctly.
Add an option to change the tint of the chequer board. Show unsigned integer options in hexadecimal format. Fixed a crash caused by attemting seeking when no file is being played.
Diffstat (limited to 'visualization')
-rw-r--r--visualization/qmpvisualization.cpp26
-rw-r--r--visualization/qmpvisualization.hpp2
2 files changed, 21 insertions, 7 deletions
diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp
index 70299a6..f2c663e 100644
--- a/visualization/qmpvisualization.cpp
+++ b/visualization/qmpvisualization.cpp
@@ -8,9 +8,10 @@
int viewdist=100;
int notestretch=100;//length of quarter note
int minnotelength=100;
-int noteappearance=1,showpiano=1,stairpiano=1,savevp=1;
+int noteappearance=1,showpiano=1,stairpiano=1,savevp=1,showlabel=1;
int wwidth=800,wheight=600,wsupersample=1,wmultisample=1;
int fov=60,vsync=1,tfps=60;
+DWORD chkrtint=0xFF999999;
DWORD iccolors[]={0XFFFF0000,0XFFFF8000,0XFFFFBF00,0XFFFFFF00,
0XFFBFFF00,0XFF80FF00,0XFF00FF00,0XFF00FFBF,
0XFF00FFFF,0XFF333333,0XFF00BFFF,0XFF007FFF,
@@ -54,12 +55,14 @@ void qmpVisualization::showThread()
noteappearance=api->getOptionBool("Visualization/3dnotes");
showpiano=api->getOptionBool("Visualization/showpiano");
stairpiano=api->getOptionBool("Visualization/stairpiano");
+ showlabel=api->getOptionBool("Visualization/showlabel");
savevp=api->getOptionBool("Visualization/savevp");
vsync=api->getOptionBool("Visualization/vsync");
tfps=api->getOptionInt("Visualization/tfps");
viewdist=api->getOptionInt("Visualization/viewdist");
notestretch=api->getOptionInt("Visualization/notestretch");
minnotelength=api->getOptionInt("Visualization/minnotelen");
+ chkrtint=api->getOptionUint("Visualization/chkrtint");
sm=smGetInterface(SMELT_APILEVEL);
sm->smVidMode(wwidth,wheight,true);
sm->smUpdateFunc(h);sm->smQuitFunc(closeh);
@@ -77,6 +80,8 @@ void qmpVisualization::showThread()
tdscn=sm->smTargetCreate(wwidth*wsupersample,wheight*wsupersample,wmultisample);
if(!font.loadTTF("/usr/share/fonts/truetype/freefont/FreeMono.ttf",16))
printf("W: Font load failed.\n");
+ if(!fonthdpi.loadTTF("/usr/share/fonts/truetype/freefont/FreeMono.ttf",180))
+ printf("W: Font load failed.\n");
if(!font2.loadTTF("/usr/share/fonts/truetype/wqy/wqy-microhei.ttc",16))
printf("W: Font load failed.\n");
pos[0]=0;pos[1]=120;pos[2]=70;
@@ -120,6 +125,7 @@ void qmpVisualization::close()
}
font.releaseTTF();
font2.releaseTTF();
+ fonthdpi.releaseTTF();
sm->smTextureFree(chequer);
if(bgtex)sm->smTextureFree(bgtex);
sm->smTargetFree(tdscn);
@@ -142,7 +148,7 @@ bool qmpVisualization::update()
{
smQuad q;
for(int i=0;i<4;++i)
- {q.v[i].col=0xFF999999;q.v[i].z=showpiano?-5:0;}
+ {q.v[i].col=chkrtint;q.v[i].z=showpiano?-5:0;}
q.tex=chequer;q.blend=BLEND_ALPHABLEND;
q.v[0].x=q.v[3].x=-120;q.v[1].x=q.v[2].x=120;
q.v[0].y=q.v[1].y=-120;q.v[2].y=q.v[3].y=120;
@@ -212,10 +218,14 @@ bool qmpVisualization::update()
p3d[i]->setKeyTravelDist(j,traveld[i][j]/10.);
}
p3d[i]->render(smvec3d(0.756*api->getPitchBend(i),stairpiano?55-i*7:62-i*8,stairpiano*i*2));
- std::string s=api->getChannelPresetString(i);
- wchar_t ws[1024];mbstowcs(ws,s.c_str(),1024);
- font.updateString(ws);
- //font.render(-42,stairpiano?55-i*7:62-i*8,stairpiano*i*2,0xFFFFFFFF,ALIGN_RIGHT);
+ if(showlabel)
+ {
+ std::string s=api->getChannelPresetString(i);
+ wchar_t ws[1024];mbstowcs(ws,s.c_str(),1024);
+ fonthdpi.updateString(ws);
+ fonthdpi.render(-49,stairpiano?56-i*7:63-i*8,stairpiano*i*2+0.1,0xFFFFFFFF,ALIGN_RIGHT,.008,0.01);
+ fonthdpi.render(-49.05,stairpiano?56.05-i*7:63.05-i*8,stairpiano*i*2+0.2,0xFF000000,ALIGN_RIGHT,.008,0.01);
+ }
}
if(playing)ctk+=(int)(1e6/(api->getRawTempo()/api->getDivision())*sm->smGetDelta());
while(pool.size()&&elb<pool.size()&&((double)ctk-pool[elb]->tce)*lpt>viewdist*2)++elb;
@@ -291,6 +301,7 @@ void qmpVisualization::init()
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);
+ api->registerOptionBool("Visualization-Appearance","Show channel labels","Visualization/showlabel",true);
api->registerOptionBool("Visualization-Video","Enable VSync","Visualization/vsync",true);
api->registerOptionBool("Visualization-Video","Save Viewport","Visualization/savevp",true);
api->registerOptionInt("Visualization-Video","Window Width","Visualization/wwidth",320,3200,800);
@@ -302,6 +313,7 @@ void qmpVisualization::init()
api->registerOptionInt("Visualization-Appearance","View distance","Visualization/viewdist",20,1000,100);
api->registerOptionInt("Visualization-Appearance","Note stretch","Visualization/notestretch",20,500,100);
api->registerOptionInt("Visualization-Appearance","Minimum note length","Visualization/minnotelen",20,500,100);
+ api->registerOptionUint("Visualization-Appearance","Chequer board tint","Visualization/chkrtint",0,0xFFFFFFFF,0xFF999999);
api->registerOptionString("Visualization-Appearance","Background Image","Visualization/background","");
api->registerOptionDouble("","","Visualization/px",-999999999,999999999,0);
api->registerOptionDouble("","","Visualization/py",-999999999,999999999,120);
@@ -317,12 +329,14 @@ void qmpVisualization::init()
noteappearance=api->getOptionBool("Visualization/3dnotes");
showpiano=api->getOptionBool("Visualization/showpiano");
stairpiano=api->getOptionBool("Visualization/stairpiano");
+ showlabel=api->getOptionBool("Visualization/showlabel");
savevp=api->getOptionBool("Visualization/savevp");
vsync=api->getOptionBool("Visualization/vsync");
tfps=api->getOptionInt("Visualization/tfps");
viewdist=api->getOptionInt("Visualization/viewdist");
notestretch=api->getOptionInt("Visualization/notestretch");
minnotelength=api->getOptionInt("Visualization/minnotelen");
+ chkrtint=api->getOptionUint("Visualization/chkrtint");
}
void qmpVisualization::deinit()
{
diff --git a/visualization/qmpvisualization.hpp b/visualization/qmpvisualization.hpp
index 6cac638..3305f4f 100644
--- a/visualization/qmpvisualization.hpp
+++ b/visualization/qmpvisualization.hpp
@@ -49,7 +49,7 @@ class qmpVisualization:public qmpPluginIntf
SMELT *sm;
SMTRG tdscn;
SMTEX chequer,bgtex;
- smTTFont font,font2;
+ smTTFont font,font2,fonthdpi;
qmpVirtualPiano3D* p3d[16];
smEntity3DBuffer* nebuf;
float pos[3],rot[3],lastx,lasty;