aboutsummaryrefslogtreecommitdiff
path: root/qmpmidiread.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-12-31 23:49:04 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-12-31 23:49:04 +0800
commit3db127ce64eadb54568e218124744a1de713667e (patch)
treee360f2cba2afb1c369e28907aa19934cf3c45ca5 /qmpmidiread.cpp
parentb1be9e45b5abdf0a03181b9cee8dc208a762fe57 (diff)
downloadQMidiPlayer-3db127ce64eadb54568e218124744a1de713667e.tar.xz
Inanimate Dream. (WTF)
Diffstat (limited to 'qmpmidiread.cpp')
-rw-r--r--qmpmidiread.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/qmpmidiread.cpp b/qmpmidiread.cpp
index b960369..0d9a7bc 100644
--- a/qmpmidiread.cpp
+++ b/qmpmidiread.cpp
@@ -130,7 +130,17 @@ retry:
{
++byteread;if(str)str[c]=fgetc(f);else fgetc(f);
}
- eventList[eventc++]=new SEvent(curid,curt,type,metatype,0,str);
+ if(str)str[c]='\0';eventList[eventc++]=new SEvent(curid,curt,type,metatype,0,str);
+ if(str&&metatype==0x03&&!title)
+ {
+ title=new char[len+8];
+ strcpy(title,str);
+ }
+ if(str&&metatype==0x02&&!copyright)
+ {
+ copyright=new char[len+8];
+ strcpy(copyright,str);
+ }
if(len<=1024&&len>0)delete[] str;
}
}
@@ -188,6 +198,7 @@ void CMidiFile::chunkReader(int hdrXp)
}
CMidiFile::CMidiFile(const char* fn)
{
+ title=copyright=NULL;
if(!(f=fopen(fn,"rb")))exit((printf("E: file %s doesn't exist!\n",fn),2));
chunkReader(1);
for(uint32_t i=0;i<trk;++i)chunkReader(0);
@@ -198,7 +209,10 @@ CMidiFile::CMidiFile(const char* fn)
CMidiFile::~CMidiFile()
{
for(uint32_t i=0;i<eventc;++i)delete eventList[i];
+ 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;}
uint32_t CMidiFile::getDivision(){return divs;}
+const char* CMidiFile::getTitle(){return title;}
+const char* CMidiFile::getCopyright(){return copyright;}