aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-25 23:46:17 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-25 23:46:17 +0800
commit4ffde0ad55d041229793ca4457123bcbcbf8e0c0 (patch)
tree9457cee58f3a1f35ebe63de79c6811b1c16e36dc /core
parent800a0417e9ed175f220c472842a283202c77060b (diff)
downloadQMidiPlayer-4ffde0ad55d041229793ca4457123bcbcbf8e0c0.tar.xz
Plugin API now works correctly. Port old visualization code.
Diffstat (limited to 'core')
-rw-r--r--core/qmpmidiplay.cpp6
-rw-r--r--core/qmpmidiplay.hpp3
-rw-r--r--core/qmpmidiread.cpp8
3 files changed, 10 insertions, 7 deletions
diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp
index 4e28be0..ca2878c 100644
--- a/core/qmpmidiplay.cpp
+++ b/core/qmpmidiplay.cpp
@@ -49,7 +49,7 @@ void CMidiPlayer::fluidDeinitialize()
}
void CMidiPlayer::processEvent(const SEvent *e)
{
- SEventCallBackData cbd(e->type,e->p1,e->p2);
+ SEventCallBackData cbd(e->type,e->p1,e->p2,tceptr);
for(int i=0;i<16;++i)if(eventHandlerCB[i])
eventHandlerCB[i]->callBack(&cbd,eventHandlerCBuserdata[i]);
switch(e->type&0xF0)
@@ -317,9 +317,7 @@ void CMidiPlayer::playerPanic(bool reset)
}
bool CMidiPlayer::playerLoadFile(const char* fn)
{
- midiFile=new CMidiFile(fn);
- memcpy(midiFile->eventReaderCB,this->eventReaderCB,sizeof(this->eventReaderCB));
- memcpy(midiFile->eventReaderCBuserdata,this->eventReaderCBuserdata,sizeof(this->eventReaderCBuserdata));
+ midiFile=new CMidiFile(fn,this->eventReaderCB,this->eventReaderCBuserdata);
if(!midiFile->isValid())return false;
divs=midiFile->getDivision();
fileTimer1Pass();
diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp
index 35fecea..a89a925 100644
--- a/core/qmpmidiplay.hpp
+++ b/core/qmpmidiplay.hpp
@@ -23,7 +23,6 @@ struct SEvent
};
class CMidiFile
{
- friend class CMidiPlayer;
private:
std::vector<SEvent*>eventList;
char *title,*copyright;
@@ -45,7 +44,7 @@ class CMidiFile
int chunkReader(int hdrXp);
void dumpEvents();
public:
- CMidiFile(const char* fn);
+ CMidiFile(const char* fn,IMidiCallBack** ercb,void** ercbdata);
~CMidiFile();
const SEvent* getEvent(uint32_t id);
uint32_t getEventCount();
diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp
index 762ce5d..380b603 100644
--- a/core/qmpmidiread.cpp
+++ b/core/qmpmidiread.cpp
@@ -172,6 +172,10 @@ int CMidiFile::eventReader()//returns 0 if End of Track encountered
error(0,"W: Unknown event type %#x",type);
}
lasttype=type;++curid;
+ SEvent* le=eventList[eventList.size()-1];
+ SEventCallBackData cbd(le->type,le->p1,le->p2,le->time);
+ for(int i=0;i<16;++i)if(eventReaderCB[i])
+ eventReaderCB[i]->callBack(&cbd,eventReaderCBuserdata[i]);
return 1;
}
void CMidiFile::trackChunkReader()
@@ -222,9 +226,11 @@ void CMidiFile::dumpEvents()
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)
+CMidiFile::CMidiFile(const char* fn,IMidiCallBack **ercb,void **ercbdata)
{
title=copyright=NULL;notes=0;std=0;valid=1;
+ memcpy(eventReaderCB,ercb,sizeof(eventReaderCB));
+ memcpy(eventReaderCBuserdata,ercbdata,sizeof(eventReaderCBuserdata));
try
{
if(!(f=fopen(fn,"rb")))throw (fprintf(stderr,"E: file %s doesn't exist!\n",fn),2);