From cd8432e47e1e9b332f2d5682ce4c796a94a29de8 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Mon, 1 Jul 2019 22:33:53 +0800 Subject: Actually send initialization sequence to external devices. Replace hardcoded initial CC values with values from device property API. --- core/qmpmidioutfluid.cpp | 1 + core/qmpmidioutrtmidi.cpp | 23 +++++++++++++++++++++-- core/qmpmidiplay.cpp | 34 +++++++++++----------------------- 3 files changed, 33 insertions(+), 25 deletions(-) (limited to 'core') diff --git a/core/qmpmidioutfluid.cpp b/core/qmpmidioutfluid.cpp index ac6523f..e9bc6b1 100644 --- a/core/qmpmidioutfluid.cpp +++ b/core/qmpmidioutfluid.cpp @@ -100,6 +100,7 @@ void qmpMidiOutFluid::panic(uint8_t ch) } void qmpMidiOutFluid::reset(uint8_t ch) { + if(!~ch){fluid_synth_system_reset(synth);return;} this->panic(ch); for(int i=0;i<128;++i) fluid_synth_cc(synth,ch,i,0); diff --git a/core/qmpmidioutrtmidi.cpp b/core/qmpmidioutrtmidi.cpp index 2cc9d5b..1a18e46 100644 --- a/core/qmpmidioutrtmidi.cpp +++ b/core/qmpmidioutrtmidi.cpp @@ -229,8 +229,26 @@ void qmpMidiOutRtMidi::panic(uint8_t ch) } void qmpMidiOutRtMidi::reset(uint8_t ch) { - basicMessage(0xB0|ch,121,0); - basicMessage(0xB0|ch,123,0); + if(ch==0xFF) + { + if(devinit) + { + for(auto&msg:devinit->initseq.eventList) + { + if((msg.type&0xF0)==0xF0) + extendedMessage(msg.str.length(),msg.str.data()); + else + { + basicMessage(msg.type,msg.p1,msg.p2); + } + } + } + } + else + { + basicMessage(0xB0|ch,121,0); + basicMessage(0xB0|ch,123,0); + } } void qmpMidiOutRtMidi::onMapped(uint8_t,int) { @@ -286,6 +304,7 @@ bool qmpMidiOutRtMidi::getChannelPreset(int ch,uint16_t *bank,uint8_t *preset,st uint8_t qmpMidiOutRtMidi::getInitialCCValue(uint8_t cc) { if(!devinit)return 0;//Nope! + return devinit->initv[cc]; } void qmpMidiOutRtMidi::setInitializerFile(const char* path) { diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index bbf1c3a..6ff465f 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -176,7 +176,7 @@ void CMidiPlayer::prePlayInit() playerPanic(true); for(size_t i=0;ireset(j); + mididev[i].dev->reset(0xFF); } void CMidiPlayer::playEvents() { @@ -241,14 +241,10 @@ void CMidiPlayer::fileTimer2Pass() memset(ccc,0,sizeof(ccc));memset(rpnid,0xFF,sizeof(rpnid));memset(rpnval,0xFF,sizeof(rpnval)); for(int i=0;i<16;++i) { - ccc[i][7]=100;ccc[i][8]=64;ccc[i][10]=64; - ccc[i][11]=127;ccc[i][71]=64;ccc[i][72]=64; - ccc[i][73]=64;ccc[i][74]=64;ccc[i][75]=64; - ccc[i][76]=64;ccc[i][77]=64;ccc[i][78]=64; + memset(ccc[i],0xFF,128*sizeof(uint32_t)); ccc[i][131]=ctempo;ccc[i][132]=0x04021808; ccc[i][133]=0;ccc[i][134]=2; } - ccc[9][0]=127; for(int i=0;i<16;++i)for(int j=0;j<135;++j) ccstamps[0][i][j]=ccc[i][j]; for(uint32_t eptr=0,ct=getEvent(0)->time;eptrbasicMessage(0xB0|i,cc,chstatus[i][cc]); + memset(chstatus[i],0xff,128*sizeof(uint8_t)); } } void CMidiPlayer::playerDeinit() @@ -392,9 +375,12 @@ void CMidiPlayer::setTCeptr(uint32_t ep,uint32_t st) qmpMidiOutDevice* dest=mididev[mappedoutput[i]].dev; for(int j=0;j<120;++j) { - internalFluid->basicMessage(0xB0|i,j,ccstamps[st][i][j]); - dest->basicMessage(0xB0|i,j,ccstamps[st][i][j]); - chstatus[i][j]=ccstamps[st][i][j]; + if(~ccstamps[st][i][j]) + { + internalFluid->basicMessage(0xB0|i,j,ccstamps[st][i][j]); + dest->basicMessage(0xB0|i,j,ccstamps[st][i][j]); + chstatus[i][j]=ccstamps[st][i][j]; + } } internalFluid->basicMessage(0xC0|i,ccstamps[st][i][128],0); dest->basicMessage(0xC0|i,ccstamps[st][i][128],0); @@ -459,6 +445,8 @@ bool CMidiPlayer::getChannelMask(int ch) {return((mute>>ch)&1)||(solo&&!((solo>>ch)&1));} int CMidiPlayer::getCC(int ch,int id) { + if(chstatus[ch][id]==0xff) + return getChannelOutputDevice(ch)->getInitialCCValue(id); return chstatus[ch][id]; } void CMidiPlayer::setCC(int ch,int id,int val) -- cgit v1.2.3