zynaddsubfx

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

commit b966fc25418f052218e418376a24e501e325683f
parent f91471407929047561ac510b99fc8d9445732e35
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sat,  9 May 2015 11:54:14 -0400

Add Instrument Clear Support

Diffstat:
Msrc/Misc/MiddleWare.cpp | 28+++++++++++++++++++++++++---
Msrc/Misc/Part.cpp | 14++++++++++++++
Msrc/UI/Connection.cpp | 11++++++++++-
Msrc/UI/Fl_PADnoteOvertonePosition.h | 2++
4 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp @@ -242,7 +242,8 @@ void bankPos(Bank &bank, Fl_Osc_Interface *osc) if(!rtosc_message(response, 2048, "/loadbank", "i", bank.bankpos)) errx(1, "Failure to handle bank update properly..."); - osc->tryLink(response); + if(osc) + osc->tryLink(response); } /***************************************************************************** @@ -642,8 +643,25 @@ public: //Give it to the backend and wait for the old part to return for //deallocation uToB->write("/load-part", "ib", npart, sizeof(Part*), &p); - if(osc) - osc->damage(("/part"+to_s(npart)+"/").c_str()); + GUI::raiseUi(ui, "/damage", "s", ("/part"+to_s(npart)+"/").c_str()); + } + + //Load a new cleared Part instance + void loadClearPart(int npart) + { + if(npart == -1) + return; + Part *p = new Part(*master->memory, synth, &master->microtonal, master->fft); + p->applyparameters(); + obj_store.extractPart(p, npart); + kits.extractPart(p, npart); + + //Give it to the backend and wait for the old part to return for + //deallocation + uToB->write("/load-part", "ib", npart, sizeof(Part*), &p); + GUI::raiseUi(ui, "/damage", "s", ("/part"+to_s(npart)+"/").c_str()); + //if(osc) + // osc->damage(("/part"+to_s(npart)+"/").c_str()); } //Well, you don't get much crazier than changing out all of your RT @@ -1117,6 +1135,8 @@ void MiddleWareImpl::handleMsg(const char *msg) //printf("watching '%s' go by\n", msg); //Get the object resource locator string obj_rl(msg, last_path+1); + int npart = -1; + char testchr = 0; if(!strcmp(msg, "/refresh_bank") && !strcmp(rtosc_argument_string(msg), "i")) { refreshBankView(master->bank, rtosc_argument(msg,0).i, osc); @@ -1175,6 +1195,8 @@ void MiddleWareImpl::handleMsg(const char *msg) } else if(strstr(msg, "Padenabled") || strstr(msg, "Ppadenabled") || strstr(msg, "Psubenabled")) { kitEnable(msg); uToB->raw_write(msg); + } else if(sscanf(msg, "/part%d/clea%c", &npart, &testchr) == 2 && testchr == 'r') { + loadClearPart(npart); } else if(!strcmp(msg, "/undo")) { undo.seekHistory(-1); } else if(!strcmp(msg, "/redo")) { diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp @@ -106,6 +106,20 @@ static const Ports partPorts = { p->Ppolymode = 0; p->Plegatomode = 1; }}}, + {"clear:", rProp(internal) rDoc("Reset Part To Defaults"), 0, [](const char *, RtData &d) + { + //XXX todo forward this event for middleware to handle + //Part *p = (Part*)d.obj; + //p->defaults(); + //char part_loc[128]; + //strcpy(part_loc, d.loc); + //char *end = strrchr(part_loc, '/'); + //if(end) + // end[1] = 0; + + //d.broadcast("/damage", "s", part_loc); + }}, + //{"kit#16::T:F", "::Enables or disables kit item", 0, // [](const char *m, RtData &d) { diff --git a/src/UI/Connection.cpp b/src/UI/Connection.cpp @@ -171,8 +171,17 @@ void GUI::raiseUi(ui_handle_t gui, const char *message) if(!gui) return; MasterUI *mui = (MasterUI*)gui; - if(string("/damage") == message && rtosc_type(message, 0) == 's') + if(string("/damage") == message && rtosc_type(message, 0) == 's') { + string damage_str = rtosc_argument(message,0).s; + int npart = -1; + if(sscanf(damage_str.c_str(), "/part%d", &npart) == 1 && damage_str.size() < 10) { + if(mui->npartcounter->value()-1 == npart) { + mui->partui->showparameters(0,-1); + mui->npartcounter->do_callback(); + } + } mui->osc->damage(rtosc_argument(message,0).s); + } mui->osc->tryLink(message); //printf("got message for UI '%s'\n", message); char buffer[1024]; diff --git a/src/UI/Fl_PADnoteOvertonePosition.h b/src/UI/Fl_PADnoteOvertonePosition.h @@ -21,6 +21,8 @@ class PADnoteOvertonePosition: public Fl_Box, Fl_Osc_Widget ~PADnoteOvertonePosition(void) { + osc->removeLink("/oscilsize", + (Fl_Osc_Widget*) this); osc->removeLink(base_path + "oscilgen/spectrum", (Fl_Osc_Widget*) this); osc->removeLink(base_path + "nhr",