From 2f5ae8be201d6aaa48187533bbc2228e71d4988e Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 12 May 2015 23:50:32 +0200 Subject: [PATCH] Update zyn code --- .../zynaddsubfx/Misc/MiddleWare.cpp | 32 ++++++++++++++++--- .../native-plugins/zynaddsubfx/Misc/Part.cpp | 20 ++++++++++-- .../zynaddsubfx/UI/Connection.cpp | 11 ++++++- .../UI/Fl_PADnoteOvertonePosition.h | 2 ++ .../zynaddsubfx/UI/PartNameButton.cpp | 1 + .../native-plugins/zynaddsubfx/UI/PartUI.fl | 5 ++- 6 files changed, 61 insertions(+), 10 deletions(-) diff --git a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp index 5564abcff..4f9b8e50c 100644 --- a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp @@ -220,6 +220,7 @@ void bankList(Bank &bank, Fl_Osc_Interface *osc) if(!rtosc_message(response, 2048, "/bank-list", "iss", i++, elm.name.c_str(), elm.dir.c_str())) errx(1, "Failure to handle bank update properly..."); + if (osc) osc->tryLink(response); } } @@ -647,8 +648,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 @@ -826,8 +844,10 @@ MiddleWareImpl::MiddleWareImpl(MiddleWare *mw, SYNTH_T synth_, int prefered_port lo_server_add_method(server, NULL, NULL, handler_function, mw); fprintf(stderr, "lo server running on %d\n", lo_server_get_port(server)); - //clean_up_tmp_nams(); - //create_tmp_file((unsigned)lo_server_get_port(server)); +#ifndef CARLA_VERSION_STRING + clean_up_tmp_nams(); + create_tmp_file((unsigned)lo_server_get_port(server)); +#endif //dummy callback for starters cb = [](void*, const char*){}; @@ -1122,6 +1142,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); @@ -1180,6 +1202,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/source/native-plugins/zynaddsubfx/Misc/Part.cpp b/source/native-plugins/zynaddsubfx/Misc/Part.cpp index b932037da..d22bad3ba 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Part.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Part.cpp @@ -57,6 +57,9 @@ static const Ports partPorts = { #define rChangeCb obj->setPvolume(obj->Pvolume); rParamZyn(Pvolume, "Part Volume"), #undef rChangeCb +#define rChangeCb obj->setPpanning(obj->Ppanning); + rParamZyn(Ppanning, "Set Panning"), +#undef rChangeCb #define rChangeCb obj->setkeylimit(obj->Pkeylimit); rParamI(Pkeylimit, rProp(parameter), rMap(min,0), rMap(max, POLYPHONY), "Key limit per part"), #undef rChangeCb @@ -65,7 +68,6 @@ static const Ports partPorts = { rParamZyn(Pmaxkey, "Max Used Key"), rParamZyn(Pkeyshift, "Part keyshift"), rParamZyn(Prcvchn, "Active MIDI channel"), - rParamZyn(Ppanning, "Set Panning"), rParamZyn(Pvelsns, "Velocity sensing"), rParamZyn(Pveloffs, "Velocity offset"), rToggle(Pnoteon, "If the channel accepts note on events"), @@ -106,6 +108,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) { @@ -615,7 +631,7 @@ void Part::NoteOn(unsigned char note, // Spawn another note (but silent) if legatomodevalid==true if(legatomodevalid) { - auto ¬e2 = partnote[pos].kititem[ci]; + auto ¬e2 = partnote[posb].kititem[ci]; note2.sendtoparteffect = limit((int)kit[item].Psendtoparteffect, 0, NUM_PART_EFX); pars.quiet = true; diff --git a/source/native-plugins/zynaddsubfx/UI/Connection.cpp b/source/native-plugins/zynaddsubfx/UI/Connection.cpp index 9f6bb5cba..393c4bbbe 100644 --- a/source/native-plugins/zynaddsubfx/UI/Connection.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Connection.cpp @@ -186,8 +186,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/source/native-plugins/zynaddsubfx/UI/Fl_PADnoteOvertonePosition.h b/source/native-plugins/zynaddsubfx/UI/Fl_PADnoteOvertonePosition.h index b00fd5206..eb5c8926d 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_PADnoteOvertonePosition.h +++ b/source/native-plugins/zynaddsubfx/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", diff --git a/source/native-plugins/zynaddsubfx/UI/PartNameButton.cpp b/source/native-plugins/zynaddsubfx/UI/PartNameButton.cpp index 3db9db15a..ecc094779 100644 --- a/source/native-plugins/zynaddsubfx/UI/PartNameButton.cpp +++ b/source/native-plugins/zynaddsubfx/UI/PartNameButton.cpp @@ -9,4 +9,5 @@ void PartNameButton::OSC_value(const char *label_) { the_string = label_; label(the_string.c_str()); + redraw(); } diff --git a/source/native-plugins/zynaddsubfx/UI/PartUI.fl b/source/native-plugins/zynaddsubfx/UI/PartUI.fl index a20cd1685..1f4613f2c 100644 --- a/source/native-plugins/zynaddsubfx/UI/PartUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/PartUI.fl @@ -279,10 +279,9 @@ class PartUI {open : {public Fl_Osc_Group} label {Grand Piano} callback {int event=Fl::event_button(); if (event==FL_RIGHT_MOUSE){ - fprintf(stderr, "Unimplemented...\\n"); const char *tmp=fl_input("Instrument name:",o->label()); - o->oscWrite("Pname", "s", tmp); - /*if (tmp!=NULL) snprintf((char *)part->Pname,PART_MAX_NAME_LEN,"%s",tmp);*/ + if (tmp!=NULL) + o->oscWrite("Pname", "s", tmp); } else { if (event==FL_LEFT_MOUSE) bankui->show(); else instrumenteditwindow->show();