diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-04-18 23:34:22 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-04-18 23:34:22 +0800 |
commit | 41d78f3a67e2356008911b07f8cc0d0cdafd7fda (patch) | |
tree | f9ab616fb25b718b4299b15b90e54c86cb131161 | |
parent | b21f97f416cea5d9d86e3b28bd797b42491fc5a9 (diff) | |
download | QMidiPlayer-41d78f3a67e2356008911b07f8cc0d0cdafd7fda.tar.xz |
Use std::vector for the event list. Add panic action.
Minor changes on the panic function.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | core/qmpmidiplay.cpp | 21 | ||||
-rw-r--r-- | core/qmpmidiplay.hpp | 5 | ||||
-rw-r--r-- | core/qmpmidiread.cpp | 36 | ||||
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | doc/mainwindow.html | 3 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpmainwindow.cpp | 12 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpmainwindow.hpp | 3 | ||||
-rw-r--r-- | qmidiplayer-desktop/translations/qmp_zh_CN.ts | 15 |
10 files changed, 77 insertions, 32 deletions
@@ -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... @@ -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 <cstring> #include <cstdint> #include <cstdlib> +#include <vector> #include <fluidsynth.h> #include "qmpmidimappers.hpp" struct SEvent @@ -29,9 +30,9 @@ class CMidiCallBack class CMidiFile { private: - SEvent *eventList[10000000]; + std::vector<SEvent*>eventList; 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<len;++c){++byteread;str[c]=fgetc(f);} } else for(c=0;c<len;++c){++byteread;str[c]=fgetc(f);} - eventList[eventc++]=new SEvent(curid,curt,type,len,0,str); + eventList.push_back(new SEvent(curid,curt,type,len,0,str)); if(!strcmp(str,GM1SysX))std=1; if(!strcmp(str,GM2SysX))std=2; if(!strcmp(str,GSSysEx))std=3; @@ -213,24 +213,24 @@ int CMidiFile::chunkReader(int hdrXp) } CMidiFile::CMidiFile(const char* fn) { - title=copyright=NULL;notes=eventc=0;std=0;valid=1; + title=copyright=NULL;notes=0;std=0;valid=1; try { if(!(f=fopen(fn,"rb")))throw (fprintf(stderr,"E: file %s doesn't exist!\n",fn),2); chunkReader(1); for(uint32_t i=0;i<trk;i+=chunkReader(0)); fclose(f); - std::sort(eventList,eventList+eventc,cmp); + std::sort(eventList.begin(),eventList.end(),cmp); } catch(int){fprintf(stderr,"E: %s is not a supported file.\n",fn);valid=0;} } CMidiFile::~CMidiFile() { - for(uint32_t i=0;i<eventc;++i)delete eventList[i]; + for(uint32_t i=0;i<eventList.size();++i)delete eventList[i];eventList.clear(); if(title)delete[] title;if(copyright)delete[] copyright; } -const SEvent* CMidiFile::getEvent(uint32_t id){return id<eventc?eventList[id]:NULL;} -uint32_t CMidiFile::getEventCount(){return eventc;} +const SEvent* CMidiFile::getEvent(uint32_t id){return id<eventList.size()?eventList[id]:NULL;} +uint32_t CMidiFile::getEventCount(){return eventList.size();} uint32_t CMidiFile::getDivision(){return divs;} uint32_t CMidiFile::getNoteCount(){return notes;} uint32_t CMidiFile::getStandard(){return std;} diff --git a/debian/changelog b/debian/changelog index 6a3e3e0..9ef843b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +qmidiplayer (0.7.2-3) UNRELEASED; urgency=low + + * New upstream release. + + -- chrisoft <chirs241097@gmail.com> 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', <br> is always placed in the folder that the source midi file is in.<br> MIDI mapping does not apply to render results.</li> + <li>Panic.<br> + If somehow the player messed up, use this action to turn off all the notes. + </li> </ul> <br><a href="index.html">Return</a> </div> 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 @@ <source>?</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../qmpmainwindow.cpp" line="68"/> + <source>File Information</source> + <translation type="unfinished">文件信息</translation> + </message> + <message> + <location filename="../qmpmainwindow.cpp" line="69"/> + <source>Render to Wave</source> + <translation type="unfinished">输出到wav文件</translation> + </message> + <message> + <location filename="../qmpmainwindow.cpp" line="70"/> + <source>Panic</source> + <translation type="unfinished">关闭所有音符</translation> + </message> </context> <context> <name>qmpPlistWindow</name> |