aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/qmpmidiplay.cpp2
-rw-r--r--core/qmpmidiplay.hpp7
-rw-r--r--core/qmpmidiread.cpp15
3 files changed, 22 insertions, 2 deletions
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;
+}