aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/qmpmidiplay.cpp2
-rw-r--r--core/qmpmidiplay.hpp4
-rw-r--r--core/qmpmidiread.cpp16
3 files changed, 18 insertions, 4 deletions
diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp
index d5df23c..76c7d16 100644
--- a/core/qmpmidiplay.cpp
+++ b/core/qmpmidiplay.cpp
@@ -321,7 +321,7 @@ void CMidiPlayer::playerPanic(bool reset)
}
bool CMidiPlayer::playerLoadFile(const char* fn)
{
- midiReaders->readFile(fn);notes=0;
+ notes=0;midiReaders->readFile(fn);
if(!midiReaders->isValid())return false;
divs=midiReaders->getDivision();
for(int i=0;i<16;++i)if(fileReadFinishCB[i])
diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp
index b911844..ebc62d6 100644
--- a/core/qmpmidiplay.hpp
+++ b/core/qmpmidiplay.hpp
@@ -38,8 +38,9 @@ class CMidiFileReaderCollection{
std::vector<std::pair<IMidiFileReader*,std::string>> readers;
CMidiFile* file;
uint32_t maxtk;
- void destructFile(CMidiFile*& f);
IMidiFileReader* currentReader;
+ void destructFile(CMidiFile*& f);
+ void dumpFile();
public:
CMidiFileReaderCollection();
~CMidiFileReaderCollection();
@@ -59,6 +60,7 @@ public:
};
class CMidiPlayer
{
+ friend class CMidiFileReaderCollection;
private:
CMidiFileReaderCollection *midiReaders;
uint32_t stamps[101],notes;
diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp
index b36fffc..92573d2 100644
--- a/core/qmpmidiread.cpp
+++ b/core/qmpmidiread.cpp
@@ -12,7 +12,6 @@ const char* GM1SysX={"\xF0\x7E\x7F\x09\x01\xF7"};
const char* GM2SysX={"\xF0\x7E\x7F\x09\x03\xF7"};
const char* GSSysEx={"\xF0\x41\x10\x42\x12\x40\x00\x7F\x00\x41\xF7"};
const char* XGSysEx={"\xF0\x43\x10\x4C\x00\x00\x7E\x00\xF7"};
-bool cmp(SEvent a,SEvent b){return a.time-b.time?a.time<b.time:a.iid<b.iid;}
void CSMFReader::error(int fatal,const char* format,...)
{
va_list ap;
@@ -240,7 +239,7 @@ CMidiFile* CSMFReader::readFile(const char* fn)
chunkReader(1);
for(uint32_t i=0;i<trk;i+=chunkReader(0));
fclose(f);f=NULL;
- std::sort(ret->eventList.begin(),ret->eventList.end(),cmp);
+ std::sort(ret->eventList.begin(),ret->eventList.end());
}
catch(std::runtime_error&){fprintf(stderr,"E: %s is not a supported file.\n",fn);ret->valid=0;fclose(f);f=NULL;}
return ret;
@@ -270,6 +269,18 @@ void CMidiFileReaderCollection::destructFile(CMidiFile*& f)
delete f;
f=NULL;
}
+void CMidiFileReaderCollection::dumpFile()
+{
+ if(!file)return;
+ std::vector<SEvent> &eventList=file->eventList;
+ for(uint32_t i=0;i<eventList.size();++i)
+ if(eventList[i].str.length())
+ 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.c_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);
+}
CMidiFileReaderCollection::CMidiFileReaderCollection()
{
file=NULL;readers.clear();currentReader=NULL;
@@ -301,6 +312,7 @@ void CMidiFileReaderCollection::readFile(const char* fn)
for(unsigned i=0;i<readers.size();++i)
{
currentReader=readers[i].first;
+ CMidiPlayer::getInstance()->notes=0;
CMidiFile* t=readers[i].first->readFile(fn);
if(t->valid){file=t;break;}
else destructFile(t);