aboutsummaryrefslogtreecommitdiff
path: root/core/qmpmidiread.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-20 23:29:39 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-20 23:29:39 +0800
commit32568af90e5c521c68432a7e77b6dd8bf524adde (patch)
treee2bed775bf9953f26ad94531da2a20ec9f967482 /core/qmpmidiread.cpp
parentb68f60e023175b144664de092c31416fa5b58880 (diff)
downloadQMidiPlayer-32568af90e5c521c68432a7e77b6dd8bf524adde.tar.xz
UI refinements and fix to two memory leaks.
Minor improvement in MIDI reading process.
Diffstat (limited to 'core/qmpmidiread.cpp')
-rw-r--r--core/qmpmidiread.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp
index 115b7b3..762ce5d 100644
--- a/core/qmpmidiread.cpp
+++ b/core/qmpmidiread.cpp
@@ -51,7 +51,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;
-retry:
+ if(!(type&0x80)){fseek(f,-1,SEEK_CUR);--byteread;type=lasttype;}
switch(type&0xF0)
{
case 0x80://Note Off
@@ -164,11 +164,12 @@ retry:
if(!strcmp(str,GM2SysX))std=2;
if(!strcmp(str,GSSysEx))std=3;
if(!strcmp(str,XGSysEx))std=4;
+ delete[] str;
}
else error(0,"W: Unknown event type %#x",type);
break;
default:
- fseek(f,-1,SEEK_CUR);--byteread;type=lasttype;goto retry;
+ error(0,"W: Unknown event type %#x",type);
}
lasttype=type;++curid;
return 1;
@@ -211,6 +212,16 @@ int CMidiFile::chunkReader(int hdrXp)
}
else return trackChunkReader(),1;
}
+void CMidiFile::dumpEvents()
+{
+ for(uint32_t i=0;i<eventList.size();++i)
+ if(eventList[i]->str)
+ printf("type %x #%d @%d p1 %d p2 %d str %s\n",eventList[i]->type,
+ eventList[i]->iid,eventList[i]->time,eventList[i]->p1,eventList[i]->p2,eventList[i]->str);
+ else
+ printf("type %x #%d @%d p1 %d p2 %d\n",eventList[i]->type,
+ eventList[i]->iid,eventList[i]->time,eventList[i]->p1,eventList[i]->p2);
+}
CMidiFile::CMidiFile(const char* fn)
{
title=copyright=NULL;notes=0;std=0;valid=1;