zynaddsubfx

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

commit b9fe8db5901a9c17042936689d0093046f0bef92
parent 6d404799125e5aaab82638005a24866c8fe3e8cc
Author: Johannes Lorenz <johannes89@ist-einmalig.de>
Date:   Wed, 13 Dec 2017 19:13:00 +0100

Merge branch 'default_values' of ssh://git.code.sf.net/p/zynaddsubfx/code into default_values

Diffstat:
MTODO-default-values.txt | 3+++
Msrc/Misc/Master.cpp | 6+++++-
Msrc/Misc/MiddleWare.cpp | 19++++++++++++-------
Msrc/Params/FilterParams.cpp | 9++++++---
Msrc/Params/FilterParams.h | 9++++++---
Msrc/Tests/SaveOSC.cpp | 4+++-
6 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/TODO-default-values.txt b/TODO-default-values.txt @@ -3,6 +3,9 @@ TODOs for default values: * 1 ... 7 => 1 2 ... 7 * also after scanning? +* rEnabled vs rExists: + * clarify/rename + * make a clean function? move code: * ports.cpp => default_values.cpp * rtosc.cpp => ...cmp.cpp? diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp @@ -1718,8 +1718,12 @@ int Master::saveOSC(const char *filename, master_dispatcher_t* dispatcher, std::ofstream ofs(filename); ofs << savefile; } - else + else { + std::cout << "The savefile content follows" << std::endl; + std::cout << "---->8----" << std::endl; std::cout << savefile << std::endl; + std::cout << "---->8----" << std::endl; + } } else { diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp @@ -560,26 +560,27 @@ public: } //Well, you don't get much crazier than changing out all of your RT - //structures at once... TODO error handling - void loadMaster(const char *filename, bool osc_format = false) + //structures at once... + int loadMaster(const char *filename, bool osc_format = false) { Master *m = new Master(synth, config); m->uToB = uToB; m->bToU = bToU; + if(filename) { if(osc_format) { mw_dispatcher_t dispatcher(parent); if( m->loadOSC(filename, &dispatcher) < 0 ) { delete m; - return; + return -1; } } else { if ( m->loadXML(filename) ) { delete m; - return; + return -1; } } m->applyparameters(); @@ -593,6 +594,7 @@ public: //Give it to the backend and wait for the old part to return for //deallocation parent->transmitMsg("/load-master", "b", sizeof(Master*), &m); + return 0; } int saveMaster(const char *filename, bool osc_format = false) @@ -1198,9 +1200,12 @@ void load_cb(const char *msg, RtData &d) if(rtosc_narguments(msg) > 1) request_time = rtosc_argument(msg, 1).t; - impl.loadMaster(file, osc_format); - d.broadcast("/damage", "s", "/"); - d.broadcast(d.loc, "stT", file, request_time); + if(!impl.loadMaster(file, osc_format)) { // return-value 0 <=> OK + d.broadcast("/damage", "s", "/"); + d.broadcast(d.loc, "stT", file, request_time); + } + else + d.broadcast(d.loc, "stF", file, request_time); } template<bool osc_format> diff --git a/src/Params/FilterParams.cpp b/src/Params/FilterParams.cpp @@ -139,7 +139,10 @@ const rtosc::Ports FilterParams::ports = { d.reply(d.loc, "b", sizeof_pvowels, obj->Pvowels); }}, - {"Pvowels#" STRINGIFY(FF_MAX_VOWELS) "/", NULL, &subports, + rEnabledCondition(is_formant_filter, obj->Pcategory == 1), + {"Pvowels#" STRINGIFY(FF_MAX_VOWELS) "/", + rEnabledByCondition(is_formant_filter), + &subports, [](const char *msg, RtData &d) { const char *mm = msg; \ while(*mm && !isdigit(*mm)) ++mm; \ @@ -414,8 +417,8 @@ void FilterParams::defaults(int n) /* * Get the parameters from other FilterParams */ - -void FilterParams::getfromFilterParams(FilterParams *pars) +// WARNING! Function unused since 2004, see declaration in header +void FilterParams::getfromFilterParams(const FilterParams *pars) { defaults(); diff --git a/src/Params/FilterParams.h b/src/Params/FilterParams.h @@ -41,8 +41,11 @@ class FilterParams:public PresetsArray void paste(FilterParams &); void pasteArray(FilterParams &, int section); - - void getfromFilterParams(FilterParams *pars); + //! assignment operator-like function + //! @warning function has been unused since 2004 + //! (84ddf9c0132b6be8d685f01c6444edd8bc49bb0f). If you use it, make + //! sure it's still up-to-date and make tests + void getfromFilterParams(const FilterParams *pars); float getfreq() const ; float getq() const ; @@ -90,7 +93,7 @@ class FilterParams:public PresetsArray float getformantamp(unsigned char amp) const ; float getformantq(unsigned char q) const ; - void defaults(int n); + void defaults(int n); //!< set default for formant @p n int loc; //!< consumer location bool changed; diff --git a/src/Tests/SaveOSC.cpp b/src/Tests/SaveOSC.cpp @@ -106,7 +106,7 @@ class SaveOSCTest osc_path, elapsed_secs, attempt+1, attempt == tries ? "timeout" - : ok ? "ok" : "failure"); + : ok ? "success" : "failure"); return ok && (attempt != tries); } @@ -217,5 +217,7 @@ int main(int argc, char** argv) test.start_realtime(); int res = test.run(argc, argv); test.stop_realtime(); + std::cerr << "Summary: " << ((res == EXIT_SUCCESS) ? "SUCCESS" : "FAILURE") + << std::endl; return res; }