zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 95e4254ab84440055925e5d216a072bcfdff4f54
parent 299a4e2dde8dce06fc95fe905c059110608d6310
Author: fundamental <[email protected]>
Date:   Tue, 22 Sep 2015 19:16:37 -0400

DSSI: Restore Bank Changing Broken By 2.5.x

Diffstat:
Msrc/Misc/MiddleWare.cpp | 14++++++++++++++
Msrc/Misc/MiddleWare.h | 2++
Msrc/Output/DSSIaudiooutput.cpp | 39++++++++++++---------------------------
Msrc/Output/DSSIaudiooutput.h | 3---
4 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp @@ -557,6 +557,13 @@ public: /*printf("results: '%s' '%d'\n",fname.c_str(), res);*/}); } + void loadPendingBank(int par, Bank &bank) + { + if(((unsigned int)par < bank.banks.size()) + && (bank.banks[par].dir != bank.bankfiletitle)) + bank.loadbank(bank.banks[par].dir); + } + void loadPart(int npart, const char *filename, Master *master, Fl_Osc_Interface *osc) { actual_load[npart]++; @@ -969,6 +976,9 @@ void MiddleWareImpl::bToUhandle(const char *rtmsg, bool dummy) } else if(!strcmp(rtmsg, "/setprogram") && !strcmp(rtosc_argument_string(rtmsg),"cc")) { loadPart(rtosc_argument(rtmsg,0).i, master->bank.ins[rtosc_argument(rtmsg,1).i].filename.c_str(), master, osc); + } else if(!strcmp(rtmsg, "/setbank") + && !strcmp(rtosc_argument_string(rtmsg), "c")) { + loadPendingBank(rtosc_argument(rtmsg,0).i, master->bank); } else if(!strcmp("/undo_pause", rtmsg)) { recording_undo = false; } else if(!strcmp("/undo_resume", rtmsg)) { @@ -1318,6 +1328,10 @@ void MiddleWare::transmitMsg(const char *path, const char *args, va_list va) fprintf(stderr, "Error in transmitMsg(va)n"); } +void MiddleWare::pendingSetBank(int bank) +{ + impl->bToU->write("/setbank", "c", bank); +} void MiddleWare::pendingSetProgram(int part, int program) { impl->pending_load[part]++; diff --git a/src/Misc/MiddleWare.h b/src/Misc/MiddleWare.h @@ -33,6 +33,8 @@ class MiddleWare void transmitMsg(const char *, const char *args, ...); //Handle a rtosc Message uToB void transmitMsg(const char *, const char *args, va_list va); + //Indicate that a bank will be loaded + void pendingSetBank(int bank); //Indicate that a program will be loaded on a known part void pendingSetProgram(int part, int program); //Get/Set the active bToU url diff --git a/src/Output/DSSIaudiooutput.cpp b/src/Output/DSSIaudiooutput.cpp @@ -370,6 +370,7 @@ const DSSI_Program_Descriptor *DSSIaudiooutput::getProgram(unsigned long index) */ void DSSIaudiooutput::selectProgram(unsigned long bank, unsigned long program) { + middleware->pendingSetBank(bank); middleware->pendingSetProgram(0, program); } @@ -646,20 +647,6 @@ void DSSIaudiooutput::initBanks(void) } /** - * constructor for the internally used ProgramDescriptor class - * - * @param _bank [in] bank number - * @param _program [in] program number - * @param _name [in] instrument / sample name - * @return - */ -DSSIaudiooutput::ProgramDescriptor::ProgramDescriptor(unsigned long _bank, - unsigned long _program, - char *_name) - :bank(_bank), program(_program), name(_name) -{} - -/** * The map of programs available; held as a single shared statically allocated object. */ vector<DSSIaudiooutput::ProgramDescriptor> DSSIaudiooutput::programMap = @@ -679,23 +666,21 @@ long DSSIaudiooutput::bankNoToMap = 1; */ bool DSSIaudiooutput::mapNextBank() { - Bank &bank = middleware->spawnMaster()->bank; - bool retval; - if((bankNoToMap >= (int)bank.banks.size()) - || bank.banks[bankNoToMap].dir.empty()) - retval = false; + Bank &bank = middleware->spawnMaster()->bank; + auto &banks = bank.banks; + if(bankNoToMap >= (int)banks.size() || banks[bankNoToMap].dir.empty()) + return false; else { bank.loadbank(bank.banks[bankNoToMap].dir); - for(unsigned long instrument = 0; instrument < BANK_SIZE; - ++instrument) { + for(int instrument = 0; instrument < BANK_SIZE; ++instrument) { string insName = bank.getname(instrument); - if(!insName.empty() && (insName[0] != '\0') && (insName[0] != ' ')) - programMap.push_back(ProgramDescriptor(bankNoToMap, instrument, - const_cast<char *>( - insName.c_str()))); + ProgramDescriptor prog{(unsigned long)bankNoToMap, + (unsigned long)instrument, insName}; + + if(!insName.empty() && insName[0] != '\0' && insName[0] != ' ') + programMap.push_back(prog); } bankNoToMap++; - retval = true; + return true; } - return retval; } diff --git a/src/Output/DSSIaudiooutput.h b/src/Output/DSSIaudiooutput.h @@ -89,9 +89,6 @@ class DSSIaudiooutput unsigned long bank; unsigned long program; std::string name; - ProgramDescriptor(unsigned long _bank, - unsigned long _program, - char *_name); }; private: