aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-11 23:38:21 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-11 23:38:21 +0800
commit59304aa1b2c6d278e76f72509183fee96bbb8cae (patch)
treead50b86aaf71497588372de7089ff71b05b00a7b
parentd4c66cbcfb1411312b2c2f3c83e76a4882b8577a (diff)
downloadQMidiPlayer-59304aa1b2c6d278e76f72509183fee96bbb8cae.tar.xz
Fixed a crash caused by the visualization plugin.
Fixed a bug when piano is hidden but the option "arrange channels on a stair" is enabled. Add channel label display. However it's still buggy so it's currently disabled.
-rw-r--r--ChangeLog7
-rw-r--r--include/qmpcorepublic.hpp1
-rw-r--r--qmidiplayer-desktop/qmpchanneleditor.cpp4
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.cpp10
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp10
-rw-r--r--qmidiplayer-desktop/qmppresetselect.cpp6
-rw-r--r--visualization/qmpvisualization.cpp32
7 files changed, 49 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b7c6f3..cabc955 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-05-11 0.8.1 alpha
+Fixed a bug when piano is hidden but the option "arrange
+channels on a stair" is enabled.
+Fixed a crash caused by the visualization plugin.
+Add channel label display. However it's still buggy so it's
+currently disabled.
+
2016-05-07 0.8.1 alpha
Added two new options.
Fixed several crashes related to options without a description.
diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp
index 0d040f9..8db9329 100644
--- a/include/qmpcorepublic.hpp
+++ b/include/qmpcorepublic.hpp
@@ -64,6 +64,7 @@ class qmpPluginAPI
virtual double getPitchBend(int ch);
virtual bool getChannelMask(int ch);
virtual std::string getTitle();
+ virtual std::string getChannelPresetString(int ch);
virtual int registerVisualizationIntf(qmpVisualizationIntf* intf);
virtual void unregisterVisualizationIntf(int intfhandle);
diff --git a/qmidiplayer-desktop/qmpchanneleditor.cpp b/qmidiplayer-desktop/qmpchanneleditor.cpp
index 9b61e64..206a2fa 100644
--- a/qmidiplayer-desktop/qmpchanneleditor.cpp
+++ b/qmidiplayer-desktop/qmpchanneleditor.cpp
@@ -28,8 +28,8 @@ void qmpChannelEditor::setupWindow(int chid)
int b,p;
player->getChannelPreset(ch,&b,&p,str);
ui->lbPresetName->setText(str);
- sprintf(str,"BK: %d",b);ui->lbBank->setText(str);
- sprintf(str,"PC: %d",p);ui->lbPreset->setText(str);
+ sprintf(str,"BK: %03d",b);ui->lbBank->setText(str);
+ sprintf(str,"PC: %03d",p);ui->lbPreset->setText(str);
ui->lbChannelNumber->setText(QString::number(ch+1));
#define setupControl(ccid,lb,d,ccname)\
b=player->getCC(ch,ccid);\
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp
index 7def34d..e0a1522 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.cpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.cpp
@@ -66,10 +66,10 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) :
connect(ui->twChannels->cellWidget(i,5),SIGNAL(onClick(int)),this,SLOT(showChannelEditorWindow(int)));
}
ui->twChannels->setColumnWidth(0,24);
- ui->twChannels->setColumnWidth(1,32);
- ui->twChannels->setColumnWidth(2,32);
+ ui->twChannels->setColumnWidth(1,24);
+ ui->twChannels->setColumnWidth(2,24);
ui->twChannels->setColumnWidth(3,192);
- ui->twChannels->setColumnWidth(4,192);
+ ui->twChannels->setColumnWidth(4,208);
ui->twChannels->setColumnWidth(5,32);
}
@@ -136,10 +136,10 @@ void qmpChannelsWindow::channelWindowsUpdate()
}
for(int i=0;i<16;++i)
{
- char data[128],nm[24];
+ char data[128],nm[25];
int b,p;
qmpMainWindow::getInstance()->getPlayer()->getChannelPreset(i,&b,&p,nm);
- sprintf(data,"%d:%d %s",b,p,nm);
+ sprintf(data,"%03d:%03d %s",b,p,nm);
if(fused)
{
if(strcmp(((QLabel*)ui->twChannels->cellWidget(i,4))->
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index b05ca0c..d67e08a 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -113,6 +113,16 @@ bool qmpPluginAPI::getChannelMask(int ch)
{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getChannelMask(ch):false;}
std::string qmpPluginAPI::getTitle()
{return qmw?qmw->getTitle():"";}
+std::string qmpPluginAPI::getChannelPresetString(int ch)
+{
+ int b,p;char nm[25],ret[33];ret[0]=0;
+ if(qmw&&qmw->getPlayer())
+ {
+ qmw->getPlayer()->getChannelPreset(ch,&b,&p,nm);
+ sprintf(ret,"%03d:%03d %s",b,p,nm);
+ }
+ return std::string(ret);
+}
int qmpPluginAPI::registerEventHandlerIntf(IMidiCallBack *cb,void *userdata)
{return qmw->getPlayer()->setEventHandlerCB(cb,userdata);}
diff --git a/qmidiplayer-desktop/qmppresetselect.cpp b/qmidiplayer-desktop/qmppresetselect.cpp
index ef67d70..2edb522 100644
--- a/qmidiplayer-desktop/qmppresetselect.cpp
+++ b/qmidiplayer-desktop/qmppresetselect.cpp
@@ -49,7 +49,7 @@ void qmpPresetSelector::setupWindow(int chid)
plyr->getChannelPreset(chid,&b,&p,name);
for(int i=0;i<ui->lwBankSelect->count();++i)
{
- sscanf(ui->lwBankSelect->item(i)->text().toStdString().c_str(),"%d",&r);
+ sscanf(ui->lwBankSelect->item(i)->text().toStdString().c_str(),"%3d",&r);
if(r==b){ui->lwBankSelect->setCurrentRow(i);break;}
}
r=0;
@@ -57,7 +57,7 @@ void qmpPresetSelector::setupWindow(int chid)
for(int i=0,cr=0;i<128;++i)
if(strlen(presets[b][i]))
{
- sprintf(name,"%d %s",i,presets[b][i]);
+ sprintf(name,"%03d %s",i,presets[b][i]);
if(i==p)r=cr;
ui->lwPresetSelect->addItem(name);
cr++;
@@ -94,7 +94,7 @@ void qmpPresetSelector::on_lwBankSelect_currentRowChanged()
for(int i=0;i<128;++i)
if(strlen(presets[b][i]))
{
- sprintf(name,"%d %s",i,presets[b][i]);
+ sprintf(name,"%03d %s",i,presets[b][i]);
ui->lwPresetSelect->addItem(name);
}
}
diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp
index 23b981d..70299a6 100644
--- a/visualization/qmpvisualization.cpp
+++ b/visualization/qmpvisualization.cpp
@@ -99,7 +99,12 @@ void qmpVisualization::show()
void qmpVisualization::close()
{
shouldclose=true;
- rendererTh->join();delete rendererTh;
+ if(rendererTh)
+ {
+ rendererTh->join();
+ delete rendererTh;
+ rendererTh=NULL;
+ }else return;
if(showpiano)for(int i=0;i<16;++i)delete p3d[i];
if(noteappearance==1)delete nebuf;
@@ -184,8 +189,8 @@ bool qmpVisualization::update()
if(fabs((double)pool[i]->tcs-ctk)*lpt<viewdist*2||fabs((double)pool[i]->tce-ctk)*lpt<viewdist*2)
{
if(api->getChannelMask(pool[i]->ch))continue;
- smvec3d a(0.63*((double)pool[i]->key-64)+.1,(stairpiano?(56-pool[i]->ch*7.):(64-pool[i]->ch*8.)),((double)pool[i]->tce-ctk)*lpt+stairpiano*pool[i]->ch*2.);
- smvec3d b(0.63*((double)pool[i]->key-64)+.7,(stairpiano?(56-pool[i]->ch*7.):(64-pool[i]->ch*8.))+.4,((double)pool[i]->tcs-ctk)*lpt+stairpiano*pool[i]->ch*2.);
+ smvec3d a(0.63*((double)pool[i]->key-64)+.1,(stairpiano?(56-pool[i]->ch*7.):(64-pool[i]->ch*8.)),((double)pool[i]->tce-ctk)*lpt+(stairpiano&&showpiano)*pool[i]->ch*2.);
+ smvec3d b(0.63*((double)pool[i]->key-64)+.7,(stairpiano?(56-pool[i]->ch*7.):(64-pool[i]->ch*8.))+.4,((double)pool[i]->tcs-ctk)*lpt+(stairpiano&&showpiano)*pool[i]->ch*2.);
bool isnoteon=pool[i]->tcs<=ctk&&pool[i]->tce>=ctk;if(isnoteon)
a.x=0.63*((double)pool[i]->key-64+api->getPitchBend(pool[i]->ch))+.1,
b.x=0.63*((double)pool[i]->key-64+api->getPitchBend(pool[i]->ch))+.7;
@@ -207,6 +212,10 @@ 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(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;
@@ -232,17 +241,17 @@ bool qmpVisualization::update()
wchar_t ws[1024];memset(ws,0,sizeof(ws));
mbstowcs(ws,api->getTitle().c_str(),1024);
font2.updateString(L"Title: %ls",ws);
- font2.render(1,wheight-64,0xFFFFFFFF,ALIGN_LEFT);
- font2.render(0,wheight-65,0xFF000000,ALIGN_LEFT);
+ font2.render(1,wheight-64,0.5,0xFFFFFFFF,ALIGN_LEFT);
+ font2.render(0,wheight-65,0.5,0xFF000000,ALIGN_LEFT);
font.updateString(L"Tempo: %.2f",api->getRealTempo());
- font.render(1,wheight-44,0xFFFFFFFF,ALIGN_LEFT);
- font.render(0,wheight-45,0xFF000000,ALIGN_LEFT);
+ font.render(1,wheight-44,0.5,0xFFFFFFFF,ALIGN_LEFT);
+ font.render(0,wheight-45,0.5,0xFF000000,ALIGN_LEFT);
font.updateString(L"Current tick: %d",ctk);
- font.render(1,wheight-24,0xFFFFFFFF,ALIGN_LEFT);
- font.render(0,wheight-25,0xFF000000,ALIGN_LEFT);
+ font.render(1,wheight-24,0.5,0xFFFFFFFF,ALIGN_LEFT);
+ font.render(0,wheight-25,0.5,0xFF000000,ALIGN_LEFT);
font.updateString(L"FPS: %.2f",sm->smGetFPS());
- font.render(1,wheight-4,0xFFFFFFFF,ALIGN_LEFT);
- font.render(0,wheight-5,0xFF000000,ALIGN_LEFT);
+ font.render(1,wheight-4,0.5,0xFFFFFFFF,ALIGN_LEFT);
+ font.render(0,wheight-5,0.5,0xFF000000,ALIGN_LEFT);
sm->smRenderEnd();
return shouldclose;
}
@@ -275,6 +284,7 @@ void qmpVisualization::init()
vi=new CDemoVisualization(this);
h=new CMidiVisualHandler(this);
closeh=new CloseHandler(this);
+ rendererTh=NULL;
hvif=api->registerVisualizationIntf(vi);
herif=api->registerEventReaderIntf(cb,NULL);
hehif=api->registerEventHandlerIntf(hcb,NULL);