diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-06-01 23:02:21 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-06-01 23:02:21 +0800 |
commit | d97a417012d7e510b08c2e7d9a71997605c48e88 (patch) | |
tree | f13402745af921be0d791c5a10f9ad8fda78ef72 | |
parent | c6f549a963ece1ed757793540d42d50111c19a80 (diff) | |
download | QMidiPlayer-d97a417012d7e510b08c2e7d9a71997605c48e88.tar.xz |
Initial event modifier and event filter stub.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | core/qmpmidiplay.cpp | 2 | ||||
-rw-r--r-- | core/qmpmidiplay.hpp | 7 | ||||
-rw-r--r-- | core/qmpmidiread.cpp | 15 | ||||
-rw-r--r-- | include/qmpcorepublic.hpp | 18 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.cpp | 3 |
6 files changed, 45 insertions, 9 deletions
@@ -1,10 +1,13 @@ -2016-05-29 0.8.2 alpha +2016-06-01 0.8.2 alpha +Initial event modifier and event filter stub. + +2016-05-31 0.8.2 alpha Update documentation. -2016-05-29 0.8.2 alpha +2016-05-30 0.8.2 alpha Added an option to change font size used by the visualization. -2016-05-28 0.8.2 alpha +2016-05-29 0.8.2 alpha Allow disabling soundfonts in the soundfont setting tab. 2016-05-28 0.8.2 alpha diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index 855ccb7..31784e3 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -574,3 +574,5 @@ int CMidiPlayer::setEventReaderCB(IMidiCallBack *cb,void *userdata) } void CMidiPlayer::unsetEventReaderCB(int id) {eventReaderCB[id]=NULL;eventReaderCBuserdata[id]=NULL;} +void CMidiPlayer::discardLastEvent(){midiFile?midiFile->discardLastEvent():(void)0;} +void CMidiPlayer::commitEventChange(SEventCallBackData d){midiFile?midiFile->commitEventChange(d):(void)0;} diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp index f922940..6436192 100644 --- a/core/qmpmidiplay.hpp +++ b/core/qmpmidiplay.hpp @@ -29,7 +29,7 @@ class CMidiFile uint32_t std;//standard 0=? 1=GM 2=GM2 3=GS 4=XG uint32_t fmt,trk,divs; FILE *f; - int byteread,valid; + int byteread,valid,eventdiscarded; uint32_t notes,curt,curid; IMidiCallBack* eventReaderCB[16]; void* eventReaderCBuserdata[16]; @@ -54,6 +54,8 @@ class CMidiFile const char* getTitle(); const char* getCopyright(); bool isValid(); + void discardLastEvent(); + void commitEventChange(SEventCallBackData d); }; class CMidiPlayer { @@ -161,5 +163,8 @@ class CMidiPlayer void unsetEventHandlerCB(int id); int setEventReaderCB(IMidiCallBack *cb,void *userdata); void unsetEventReaderCB(int id); + + void discardLastEvent(); + void commitEventChange(SEventCallBackData d); }; #endif diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp index 9b1d932..33a1bd4 100644 --- a/core/qmpmidiread.cpp +++ b/core/qmpmidiread.cpp @@ -50,7 +50,7 @@ int CMidiFile::eventReader()//returns 0 if End of Track encountered { uint32_t delta=readVL();curt+=delta; char type=fgetc(f);++byteread;uint32_t p1,p2; - static char lasttype; + static char lasttype;eventdiscarded=0; if(!(type&0x80)){fseek(f,-1,SEEK_CUR);--byteread;type=lasttype;} switch(type&0xF0) { @@ -257,3 +257,16 @@ uint32_t CMidiFile::getStandard(){return std;} bool CMidiFile::isValid(){return valid;} const char* CMidiFile::getTitle(){return title;} const char* CMidiFile::getCopyright(){return copyright;} + +void CMidiFile::discardLastEvent() +{ + if(eventdiscarded)return;eventdiscarded=1; + delete eventList[eventList.size()-1];eventList.pop_back(); +} +void CMidiFile::commitEventChange(SEventCallBackData d) +{ + eventList[eventList.size()-1]->time=d.time; + eventList[eventList.size()-1]->type=d.type; + eventList[eventList.size()-1]->p1=d.p1; + eventList[eventList.size()-1]->p2=d.p2; +} diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp index 13afe3e..d578018 100644 --- a/include/qmpcorepublic.hpp +++ b/include/qmpcorepublic.hpp @@ -3,15 +3,16 @@ #include <cstdint> #include <vector> #include <string> -//This struct is used by event reader callbacks and event handler callbacks -//as caller data struct #ifdef _WIN32 #define EXPORTSYM __declspec(dllexport) #else #define EXPORTSYM __attribute__ ((visibility ("default"))) #endif -struct SEventCallBackData +//This struct is used by event reader callbacks and event handler callbacks +//as caller data struct +class SEventCallBackData { +public: uint32_t time,type,p1,p2; SEventCallBackData(uint32_t _t,uint32_t _p1,uint32_t _p2,uint32_t _tm){type=_t;p1=_p1;p2=_p2;time=_tm;} }; @@ -24,7 +25,7 @@ class IMidiCallBack virtual void callBack(void* callerdata,void* userdata)=0; virtual ~IMidiCallBack(){} }; -//Main plugin pinterface. +//Main plugin interface. class qmpPluginIntf { public: @@ -75,6 +76,15 @@ class qmpPluginAPI virtual std::wstring getWTitle(); virtual std::string getChannelPresetString(int ch); + //WARNING!!: This function should be called from event reader callbacks only and + //it is somehow dangerous -- other plugins might be unaware of the removal of the + //event. The design might be modified afterward. + virtual void discardLastEvent(); + //WARNING!!: This function should be called from event reader callbacks only and + //it is somehow dangerous -- other plugins might be unaware of the event change. + //The design might be modified afterward. + virtual void commitEventChange(SEventCallBackData d); + virtual int registerVisualizationIntf(qmpVisualizationIntf* intf); virtual void unregisterVisualizationIntf(int intfhandle); virtual int registerEventReaderIntf(IMidiCallBack* cb,void* userdata); diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 7d6f36e..99ac92f 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -151,6 +151,9 @@ std::string qmpPluginAPI::getChannelPresetString(int ch) return std::string(ret); } +void qmpPluginAPI::discardLastEvent(){} +void qmpPluginAPI::commitEventChange(SEventCallBackData){} + int qmpPluginAPI::registerEventHandlerIntf(IMidiCallBack *cb,void *userdata) {return qmw->getPlayer()->setEventHandlerCB(cb,userdata);} void qmpPluginAPI::unregisterEventHandlerIntf(int intfhandle) |