From 41d78f3a67e2356008911b07f8cc0d0cdafd7fda Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Mon, 18 Apr 2016 23:34:22 +0800 Subject: Use std::vector for the event list. Add panic action. Minor changes on the panic function. --- ChangeLog | 5 ++++ INSTALL | 2 +- core/qmpmidiplay.cpp | 21 ++++++++++------ core/qmpmidiplay.hpp | 5 ++-- core/qmpmidiread.cpp | 36 +++++++++++++-------------- debian/changelog | 7 ++++++ doc/mainwindow.html | 3 +++ qmidiplayer-desktop/qmpmainwindow.cpp | 12 +++++++-- qmidiplayer-desktop/qmpmainwindow.hpp | 3 ++- qmidiplayer-desktop/translations/qmp_zh_CN.ts | 15 +++++++++++ 10 files changed, 77 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36f364d..6e2d0b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-04-18 0.7.2 beta +Use std::vector for the event list. +Add panic action. +Minor changes on the panic function. + 2016-04-17 0.7.2 beta A little more documentaion work... diff --git a/INSTALL b/INSTALL index 6c30758..373aaf8 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,3 @@ Use qmake or Qt Creator. -Dependencies: libfluidsynth 1.1.4+, Qt5 (not sure whether 4 will work). +Dependencies: libfluidsynth 1.1.4+, Qt5 (not sure whether 4 will work) and RtMidi. C++11 is required to build the project. diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index 780b8f7..43ae17e 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -287,16 +287,21 @@ CMidiPlayer::~CMidiPlayer() } void CMidiPlayer::playerPanic(bool reset) { - if(reset)for(int i=0;i<16;++i) + for(int i=0;i<16;++i) { - fluid_synth_pitch_bend(synth,i,8192); - fluid_synth_cc(synth,i,7,100); - fluid_synth_cc(synth,i,10,64); - fluid_synth_cc(synth,i,11,127); - if(deviceusage[i])for(int j=0;j<16;++j)mapper->reset(i,j); + if(reset) + { + fluid_synth_pitch_bend(synth,i,8192); + fluid_synth_cc(synth,i,7,100); + fluid_synth_cc(synth,i,10,64); + fluid_synth_cc(synth,i,11,127); + } + fluid_synth_cc(synth,i,64,0); + //all sounds off causes the minus polyphone bug... + fluid_synth_all_notes_off(synth,i); + if(deviceusage[i])for(int j=0;j<16;++j) + reset?mapper->reset(i,j):mapper->panic(i,j); } - //all sounds off causes the minus polyphone bug... - for(int i=0;i<16;++i)fluid_synth_all_notes_off(synth,i); } bool CMidiPlayer::playerLoadFile(const char* fn) { diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp index b0fb387..f2d7a4a 100644 --- a/core/qmpmidiplay.hpp +++ b/core/qmpmidiplay.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "qmpmidimappers.hpp" struct SEvent @@ -29,9 +30,9 @@ class CMidiCallBack class CMidiFile { private: - SEvent *eventList[10000000]; + std::vectoreventList; char *title,*copyright; - uint32_t eventc,std;//standard 0=? 1=GM 2=GM2 3=GS 4=XG + uint32_t std;//standard 0=? 1=GM 2=GM2 3=GS 4=XG uint32_t fmt,trk,divs; FILE *f; int byteread,valid; diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp index fd2e0d9..115b7b3 100644 --- a/core/qmpmidiread.cpp +++ b/core/qmpmidiread.cpp @@ -56,37 +56,37 @@ retry: { case 0x80://Note Off p1=fgetc(f);p2=fgetc(f);byteread+=2; - eventList[eventc++]=new SEvent(curid,curt,type,p1,p2); + eventList.push_back(new SEvent(curid,curt,type,p1,p2)); break; case 0x90://Note On p1=fgetc(f);p2=fgetc(f);byteread+=2; if(p2) { ++notes; - eventList[eventc++]=new SEvent(curid,curt,type,p1,p2); + eventList.push_back(new SEvent(curid,curt,type,p1,p2)); } else - eventList[eventc++]=new SEvent(curid,curt,(type&0x0F)|0x80,p1,p2); + eventList.push_back(new SEvent(curid,curt,(type&0x0F)|0x80,p1,p2)); break; case 0xA0://Note Aftertouch p1=fgetc(f);p2=fgetc(f);byteread+=2; - eventList[eventc++]=new SEvent(curid,curt,type,p1,p2); + eventList.push_back(new SEvent(curid,curt,type,p1,p2)); break; case 0xB0://Controller Change p1=fgetc(f);p2=fgetc(f);byteread+=2; - eventList[eventc++]=new SEvent(curid,curt,type,p1,p2); + eventList.push_back(new SEvent(curid,curt,type,p1,p2)); break; case 0xC0://Patch Change p1=fgetc(f);++byteread; - eventList[eventc++]=new SEvent(curid,curt,type,p1,0); + eventList.push_back(new SEvent(curid,curt,type,p1,0)); break; case 0xD0://Channel Aftertouch p1=fgetc(f);++byteread; - eventList[eventc++]=new SEvent(curid,curt,type,p1,0); + eventList.push_back(new SEvent(curid,curt,type,p1,0)); break; case 0xE0://Pitch wheel p1=fgetc(f);p2=fgetc(f);byteread+=2; - eventList[eventc++]=new SEvent(curid,curt,type,(p1|(p2<<7))&0x3FFF,0); + eventList.push_back(new SEvent(curid,curt,type,(p1|(p2<<7))&0x3FFF,0)); break; case 0xF0: if((type&0x0F)==0x0F)//Meta Event @@ -107,7 +107,7 @@ retry: break; case 0x51://Set Tempo p1=readDW();p1&=0x00FFFFFF; - eventList[eventc++]=new SEvent(curid,curt,type,metatype,p1); + eventList.push_back(new SEvent(curid,curt,type,metatype,p1)); break; case 0x54://SMTPE offset, not handled. fgetc(f);fgetc(f);fgetc(f); @@ -117,12 +117,12 @@ retry: case 0x58://Time signature fgetc(f);++byteread; p1=readDW(); - eventList[eventc++]=new SEvent(curid,curt,type,metatype,p1); + eventList.push_back(new SEvent(curid,curt,type,metatype,p1)); break; case 0x59://Key signature fgetc(f);++byteread; p1=readSW(); - eventList[eventc++]=new SEvent(curid,curt,type,metatype,p1); + eventList.push_back(new SEvent(curid,curt,type,metatype,p1)); break; case 0x01:case 0x02:case 0x03: case 0x04:case 0x05:case 0x06: @@ -134,7 +134,7 @@ retry: { ++byteread;if(str)str[c]=fgetc(f);else fgetc(f); } - if(str)str[c]='\0';eventList[eventc++]=new SEvent(curid,curt,type,metatype,0,str); + if(str)str[c]='\0';eventList.push_back(new SEvent(curid,curt,type,metatype,0,str)); if(str&&metatype==0x03&&!title) { title=new char[len+8]; @@ -159,7 +159,7 @@ retry: for(c=1;c Mon, 18 Apr 2016 23:32:47 +0800 + + qmidiplayer (0.7.2-2) UNRELEASED; urgency=low * New upstream release. diff --git a/doc/mainwindow.html b/doc/mainwindow.html index 22fb0bb..d6438d2 100644 --- a/doc/mainwindow.html +++ b/doc/mainwindow.html @@ -42,6 +42,9 @@ The output wave file, with the name (source file name)+'.wav',
is always placed in the folder that the source midi file is in.
MIDI mapping does not apply to render results. +
  • Panic.
    + If somehow the player messed up, use this action to turn off all the notes. +

  • Return diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp index b01df10..82537d2 100644 --- a/qmidiplayer-desktop/qmpmainwindow.cpp +++ b/qmidiplayer-desktop/qmpmainwindow.cpp @@ -65,10 +65,12 @@ void qmpMainWindow::init() infow=new qmpInfoWindow(this); helpw=new qmpHelpWindow(this); timer=new QTimer(this); - fnA1=new QAction("File Information",ui->lbFileName); - fnA2=new QAction("Render to Wave",ui->lbFileName); + fnA1=new QAction(tr("File Information"),ui->lbFileName); + fnA2=new QAction(tr("Render to Wave"),ui->lbFileName); + fnA3=new QAction(tr("Panic"),ui->lbFileName); ui->lbFileName->addAction(fnA1); ui->lbFileName->addAction(fnA2); + ui->lbFileName->addAction(fnA3); if(singleFS){player->fluidPreInitialize();playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) LOAD_SOUNDFONT;} @@ -90,6 +92,7 @@ void qmpMainWindow::init() ui->vsMasterVol->setValue(qmpSettingsWindow::getSettingsIntf()->value("Audio/Gain",50).toInt()); connect(fnA1,SIGNAL(triggered()),this,SLOT(onfnA1())); connect(fnA2,SIGNAL(triggered()),this,SLOT(onfnA2())); + connect(fnA3,SIGNAL(triggered()),this,SLOT(onfnA3())); connect(timer,SIGNAL(timeout()),this,SLOT(updateWidgets())); connect(timer,SIGNAL(timeout()),chnlw,SLOT(channelWindowsUpdate())); connect(timer,SIGNAL(timeout()),infow,SLOT(updateInfo())); @@ -544,6 +547,11 @@ void qmpMainWindow::onfnA2() renderTh=new std::thread(&CMidiPlayer::rendererThread,player); } +void qmpMainWindow::onfnA3() +{ + player->playerPanic(); +} + void qmpMainWindow::on_pbSettings_clicked() { if(ui->pbSettings->isChecked())settingsw->show();else settingsw->close(); diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp index e17a792..729eb7f 100644 --- a/qmidiplayer-desktop/qmpmainwindow.hpp +++ b/qmidiplayer-desktop/qmpmainwindow.hpp @@ -57,6 +57,7 @@ class qmpMainWindow:public QMainWindow void on_pbSettings_clicked(); void onfnA1(); void onfnA2(); + void onfnA3(); void on_pushButton_clicked(); @@ -80,7 +81,7 @@ class qmpMainWindow:public QMainWindow qmpSettingsWindow *settingsw; qmpHelpWindow *helpw; - QAction *fnA1,*fnA2; + QAction *fnA1,*fnA2,*fnA3; void playerSetup(); private: diff --git a/qmidiplayer-desktop/translations/qmp_zh_CN.ts b/qmidiplayer-desktop/translations/qmp_zh_CN.ts index 4810b05..d834231 100644 --- a/qmidiplayer-desktop/translations/qmp_zh_CN.ts +++ b/qmidiplayer-desktop/translations/qmp_zh_CN.ts @@ -365,6 +365,21 @@ ? + + + File Information + 文件信息 + + + + Render to Wave + 输出到wav文件 + + + + Panic + 关闭所有音符 + qmpPlistWindow -- cgit v1.2.3