From aec5e972e8968255e8843eb22314b96a8f23b041 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Tue, 10 Sep 2019 23:55:48 +0800 Subject: We refactorin', eh? Hell yeah. (Almost) Completely rewritten qmpChannelsWindow, one of the oldest component, now with a dedicated data model. Removed dumb design (CMidiPlayer::getChstates). Now QMidiPlayer requires C++14 to build. More refactoring like this coming up soon. --- core/qmpmidiplay.cpp | 6 ++++-- core/qmpmidiplay.hpp | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index 6ff465f..46a2dae 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -22,6 +22,8 @@ bool CMidiPlayer::processEvent(const SEvent *e) for(auto i=event_handlers.begin();i!=event_handlers.end();++i) i->second.first((void*)e,i->second.second); uint8_t ch=e->type&0x0F; + if((e->type&0xF0)<0xF0) + levtt[ch]=std::chrono::system_clock::now(); switch(e->type&0xF0) { case 0x80://Note off @@ -29,7 +31,6 @@ bool CMidiPlayer::processEvent(const SEvent *e) case 0x90://Note on if((mute>>ch)&1&&e->p2)return false;//muted if(solo&&!((solo>>ch)&1)&&e->p2)return false;//excluded by solo flags - if(e->p2)chstate[ch]=1; return true; case 0xB0://CC if(e->p1==100)rpnid[ch]=e->p2; @@ -505,7 +506,8 @@ void CMidiPlayer::setChannelOutput(int ch,int outid) dold.dev->onUnmapped(ch,--dold.refcnt); } } -uint8_t* CMidiPlayer::getChstates(){return chstate;} +const std::chrono::system_clock::time_point* CMidiPlayer::getLastEventTS() +{return levtt;} int CMidiPlayer::setEventHandlerCB(ICallBack *cb,void *userdata) { for(int i=0;i<16;++i) diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp index da9e9ef..4d950fa 100644 --- a/core/qmpmidiplay.hpp +++ b/core/qmpmidiplay.hpp @@ -64,7 +64,7 @@ class CMidiPlayer uint16_t mute,solo; double ftime; bool sendSysEx,waitvoice; - uint8_t chstate[16],chstatus[16][130];//0..127: cc 128: pc + uint8_t chstatus[16][130];//0..127: cc 128: pc qmpMidiOutFluid* internalFluid; uint32_t ctempo,ctsn,ctsd,divs,cks; double dpt;//time per tick @@ -76,6 +76,7 @@ class CMidiPlayer //playback correction uint32_t ttick; std::chrono::high_resolution_clock::time_point ttime; + std::chrono::system_clock::time_point levtt[16]; struct SMidiDev { std::string name; @@ -155,7 +156,7 @@ class CMidiPlayer int getChannelOutput(int ch); qmpMidiOutDevice* getChannelOutputDevice(int ch); void setChannelOutput(int ch,int outid); - uint8_t* getChstates(); + const std::chrono::system_clock::time_point* getLastEventTS(); int setEventHandlerCB(ICallBack *cb,void *userdata); void unsetEventHandlerCB(int id); int setEventReaderCB(ICallBack *cb,void *userdata); -- cgit v1.2.3