zynaddsubfx

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

commit 9c5951d7903a6cd44e2b8e427c358f5a8d47211d
parent fe19b2eaaf566034ec2e3b2d92aca4a994cc40f9
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Tue,  9 Aug 2016 12:26:56 -0400

Merge branch 'master' of https://github.com/zynaddsubfx/zynaddsubfx

Diffstat:
Msrc/Misc/Bank.cpp | 4+++-
Msrc/Misc/BankDb.cpp | 5+++--
Msrc/Misc/MiddleWare.cpp | 5++++-
Msrc/Params/ADnoteParameters.cpp | 19++++++++++++-------
Msrc/Params/EnvelopeParams.cpp | 54+++++++++++++++++++++++++++++++++++++++---------------
Msrc/Params/EnvelopeParams.h | 1+
Msrc/Params/PADnoteParameters.cpp | 6++++--
Msrc/Params/SUBnoteParameters.cpp | 6++++--
Msrc/main.cpp | 31+++++++++++++++++--------------
9 files changed, 87 insertions(+), 44 deletions(-)

diff --git a/src/Misc/Bank.cpp b/src/Misc/Bank.cpp @@ -364,9 +364,11 @@ void Bank::rescanforbanks() //sort the banks sort(banks.begin(), banks.end()); + for(int i = 0; i < (int) banks.size(); ++i) + db->addBankDir(banks[i].dir); + //remove duplicate bank names for(int j = 0; j < (int) banks.size() - 1; ++j) { - db->addBankDir(banks[j].dir); int dupl = 0; for(int i = j + 1; i < (int) banks.size(); ++i) { if(banks[i].name == banks[j].name) { diff --git a/src/Misc/BankDb.cpp b/src/Misc/BankDb.cpp @@ -23,8 +23,8 @@ bool platform_strcasestr(const char *hay, const char *needle) for(int j=0; j<m; ++j) { if(toupper(hay[i+j]) != toupper(needle[j])) { good = 0; -break; -} + break; + } } if(good) @@ -235,6 +235,7 @@ BankEntry BankDb::processXiz(std::string filename, std::string bank) const //printf("Bank Entry:\n"); //printf("\tname - %s\n", entry.name.c_str()); //printf("\tauthor - %s\n", line(entry.author).c_str()); + //printf("\tbank - %s\n", entry.bank.c_str()); //printf("\tadd/pad/sub - %d/%d/%d\n", entry.add, entry.pad, entry.sub); return entry; diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp @@ -1300,6 +1300,7 @@ static rtosc::Ports middwareSnoopPorts = { {"reset_master:", 0, 0, rBegin; impl.loadMaster(NULL); + d.reply("/damage", "s", "/"); rEnd}, {"load_xiz:is", 0, 0, rBegin; @@ -1337,7 +1338,9 @@ static rtosc::Ports middwareSnoopPorts = { rEnd}, {"part#16/clear:", 0, 0, rBegin; - impl.loadClearPart(extractInt(msg)); + int id = extractInt(msg); + impl.loadClearPart(id); + d.reply("/damage", "s", ("/part"+to_s(id)).c_str()); rEnd}, {"undo:", 0, 0, rBegin; diff --git a/src/Params/ADnoteParameters.cpp b/src/Params/ADnoteParameters.cpp @@ -122,7 +122,7 @@ static const Ports voicePorts = { //Modulator Stuff rOption(PFMEnabled, rShort("mode"), rOptions(none, morph, ring, phase, - frequency, pitch), "Modulator mode"), + frequency, pulse), "Modulator mode"), rParamI(PFMVoice, rShort("voice"), "Modulator Oscillator Selection"), rParamZyn(PFMVolume, rShort("vol."), "Modulator Magnitude"), rParamZyn(PFMVolumeDamp, rShort("damp."), "Modulator HF dampening"), @@ -149,7 +149,8 @@ static const Ports voicePorts = { //TODO do the same for the other engines d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PDetune)); }}, - {"octave::c:i", rProp(parameter) rDoc("Octave note offset"), NULL, + {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8, 7) rDoc("Octave note offset"), + NULL, [](const char *msg, RtData &d) { rObject *obj = (rObject *)d.obj; @@ -163,7 +164,8 @@ static const Ports voicePorts = { obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024; } }}, - {"coarsedetune::c:i", rProp(parameter) rDoc("Coarse note detune"), NULL, + {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63) + rDoc("Coarse note detune"), NULL, [](const char *msg, RtData &d) { rObject *obj = (rObject *)d.obj; @@ -189,7 +191,7 @@ static const Ports voicePorts = { //TODO do the same for the other engines d.reply(d.loc, "f", getdetune(detuneType, 0, obj->PFMDetune)); }}, - {"FMoctave::c:i", rProp(parameter) rShort("octave") rDoc("Octave note offset for modulator"), NULL, + {"FMoctave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) rDoc("Octave note offset for modulator"), NULL, [](const char *msg, RtData &d) { rObject *obj = (rObject *)d.obj; @@ -203,7 +205,8 @@ static const Ports voicePorts = { obj->PFMCoarseDetune = k*1024 + obj->PFMCoarseDetune%1024; } }}, - {"FMcoarsedetune::c:i", rProp(parameter) rDoc("Coarse note detune for modulator"), + {"FMcoarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64,63) + rDoc("Coarse note detune for modulator"), NULL, [](const char *msg, RtData &d) { rObject *obj = (rObject *)d.obj; @@ -280,7 +283,8 @@ static const Ports globalPorts = { rObject *obj = (rObject *)d.obj; d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune)); }}, - {"octave::c:i", rProp(parameter) rDoc("Octave note offset"), NULL, + {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) + rDoc("Octave note offset"), NULL, [](const char *msg, RtData &d) { rObject *obj = (rObject *)d.obj; @@ -294,7 +298,8 @@ static const Ports globalPorts = { obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024; } }}, - {"coarsedetune::c:i", rProp(parameter) rDoc("Coarse note detune"), NULL, + {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63) + rDoc("Coarse note detune"), NULL, [](const char *msg, RtData &d) { rObject *obj = (rObject *)d.obj; diff --git a/src/Params/EnvelopeParams.cpp b/src/Params/EnvelopeParams.cpp @@ -55,28 +55,46 @@ static const rtosc::Ports localPorts = { rParamZyn(PS_val, rShort("s.val"), "Sustain Value"), rParamZyn(PR_dt, rShort("r.dt"), "Release Time"), rParamZyn(PR_val, rShort("r.val"), "Release Value"), - - {"envdt:", rDoc("Envelope Delay Times"), NULL, + + {"Envmode:", rDoc("Envelope variant type"), NULL, + rBegin; + d.reply(d.loc, "i", env->Envmode); + rEnd}, + + {"envdt", rDoc("Envelope Delay Times"), NULL, rBegin; const int N = MAX_ENVELOPE_POINTS; - rtosc_arg_t args[N]; - char arg_types[N+1] = {0}; - for(int i=0; i<N; ++i) { - args[i].f = env->getdt(i); - arg_types[i] = 'f'; + const int M = rtosc_narguments(msg); + if(M == 0) { + rtosc_arg_t args[N]; + char arg_types[N+1] = {0}; + for(int i=0; i<N; ++i) { + args[i].f = env->getdt(i); + arg_types[i] = 'f'; + } + d.replyArray(d.loc, arg_types, args); + } else { + for(int i=0; i<N && i<M; ++i) + env->Penvdt[i] = env->inv_dt(rtosc_argument(msg, i).f); } - d.replyArray(d.loc, arg_types, args); rEnd}, - {"envval:", rDoc("Envelope Delay Times"), NULL, + {"envval", rDoc("Envelope Delay Times"), NULL, rBegin; const int N = MAX_ENVELOPE_POINTS; - rtosc_arg_t args[N]; - char arg_types[N+1] = {0}; - for(int i=0; i<N; ++i) { - args[i].f = env->Penvval[i]/127.0f; - arg_types[i] = 'f'; + const int M = rtosc_narguments(msg); + if(M == 0) { + rtosc_arg_t args[N]; + char arg_types[N+1] = {0}; + for(int i=0; i<N; ++i) { + args[i].f = env->Penvval[i]/127.0f; + arg_types[i] = 'f'; + } + d.replyArray(d.loc, arg_types, args); + } else { + for(int i=0; i<N && i<M; ++i) { + env->Penvval[i] = limit(roundf(rtosc_argument(msg,i).f*127.0f), 0.0f, 127.0f); + } } - d.replyArray(d.loc, arg_types, args); rEnd}, {"addPoint:i", rProp(internal) rDoc("Add point to envelope"), NULL, @@ -191,6 +209,12 @@ float EnvelopeParams::dt(char val) return (powf(2.0f, val / 127.0f * 12.0f) - 1.0f) * 10.0f; //miliseconds } +char EnvelopeParams::inv_dt(float val) +{ + int ival = roundf(logf(val/10.0f + 1.0f)/logf(2.0f) * 127.0f/12.0f); + return limit(ival, 0, 127); +} + /* * ADSR/ASR... initialisations diff --git a/src/Params/EnvelopeParams.h b/src/Params/EnvelopeParams.h @@ -44,6 +44,7 @@ class EnvelopeParams:public Presets float getdt(char i) const; static float dt(char val); + static char inv_dt(float val); /* MIDI Parameters */ unsigned char Pfreemode; //1 for free mode, 0 otherwise diff --git a/src/Params/PADnoteParameters.cpp b/src/Params/PADnoteParameters.cpp @@ -88,7 +88,8 @@ static const rtosc::Ports realtime_ports = PADnoteParameters *obj = (PADnoteParameters *)d.obj; d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune)); }}, - {"octave::c:i", rProp(parameter) rShort("octave") rDoc("Octave note offset"), NULL, + {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) + rDoc("Octave note offset"), NULL, [](const char *msg, RtData &d) { PADnoteParameters *obj = (PADnoteParameters *)d.obj; @@ -102,7 +103,8 @@ static const rtosc::Ports realtime_ports = obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024; } }}, - {"coarsedetune::c:i", rProp(parameter) rDoc("Coarse note detune"), NULL, + {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63) + rDoc("Coarse note detune"), NULL, [](const char *msg, RtData &d) { PADnoteParameters *obj = (PADnoteParameters *)d.obj; diff --git a/src/Params/SUBnoteParameters.cpp b/src/Params/SUBnoteParameters.cpp @@ -95,7 +95,8 @@ static const rtosc::Ports SUBnotePorts = { d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune)); rEnd}, //weird stuff for PCoarseDetune - {"octave::c:i", rProp(parameter) rDoc("Note octave shift"), NULL, + {"octave::c:i", rProp(parameter) rShort("octave") rLinear(-8,7) + rDoc("Note octave shift"), NULL, rBegin; if(!rtosc_narguments(msg)) { int k=obj->PCoarseDetune/1024; @@ -107,7 +108,8 @@ static const rtosc::Ports SUBnotePorts = { obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024; } rEnd}, - {"coarsedetune::c:i", rProp(parameter) rDoc("Note coarse detune"), NULL, + {"coarsedetune::c:i", rProp(parameter) rShort("coarse") rLinear(-64, 63) + rDoc("Note coarse detune"), NULL, rBegin; if(!rtosc_narguments(msg)) { int k=obj->PCoarseDetune%1024; diff --git a/src/main.cpp b/src/main.cpp @@ -26,6 +26,7 @@ #include <getopt.h> +#include <rtosc/rtosc.h> #include <rtosc/ports.h> #include <rtosc/thread-link.h> #include "Params/PADnoteParameters.h" @@ -236,6 +237,9 @@ int main(int argc, char *argv[]) "load-instrument", 2, NULL, 'L' }, { + "midi-learn", 2, NULL, 'M' + }, + { "sample-rate", 2, NULL, 'r' }, { @@ -290,9 +294,6 @@ int main(int argc, char *argv[]) "dump-json-schema", 2, NULL, 'D' }, { - "ui-title", 1, NULL, 'u' - }, - { 0, 0, 0, 0 } }; @@ -302,7 +303,7 @@ int main(int argc, char *argv[]) int auto_save_interval = 60; int wmidi = -1; - string loadfile, loadinstrument, execAfterInit, ui_title; + string loadfile, loadinstrument, execAfterInit, loadmidilearn; while(1) { int tmp = 0; @@ -310,7 +311,7 @@ int wmidi = -1; /**\todo check this process for a small memory leak*/ opt = getopt_long(argc, argv, - "l:L:r:b:o:I:O:N:e:P:A:u:D:hvapSDUYZ", + "l:L:M:r:b:o:I:O:N:e:P:A:D:hvapSDUYZ", opts, &option_index); char *optarguments = optarg; @@ -347,6 +348,9 @@ int wmidi = -1; case 'L': GETOP(loadinstrument); break; + case 'M': + GETOP(loadmidilearn); + break; case 'r': GETOPNUM(synth.samplerate); if(synth.samplerate < 4000) { @@ -435,10 +439,6 @@ int wmidi = -1; if(optarguments) wmidi = atoi(optarguments); break; - case 'u': - if(optarguments) - ui_title = optarguments; - break; case '?': cerr << "ERROR:Bad option or parameter.\n" << endl; exitwithhelp = 1; @@ -458,6 +458,7 @@ int wmidi = -1; << " -v , --version \t\t\t Display version and exit\n" << " -l file, --load=FILE\t\t\t Loads a .xmz file\n" << " -L file, --load-instrument=FILE\t Loads a .xiz file\n" + << " -M file, --midi-learn=FILE\t\t Loads a .xlz file\n" << " -r SR, --sample-rate=SR\t\t Set the sample rate SR\n" << " -b BS, --buffer-size=SR\t\t Set the buffer size (granularity)\n" @@ -475,7 +476,6 @@ int wmidi = -1; << " -I , --input\t\t\t\t Set Input Engine\n" << " -e , --exec-after-init\t\t Run post-initialization script\n" << " -d , --dump-oscdoc=FILE\t\t Dump oscdoc xml to file\n" - << " -u , --ui-title=TITLE\t\t Extend UI Window Titles\n" << endl; return 0; @@ -525,6 +525,13 @@ int wmidi = -1; } } + if(!loadmidilearn.empty()) { + char msg[1024]; + rtosc_message(msg, sizeof(msg), "/load_xlz", + "s", loadmidilearn.c_str()); + middleware->transmitMsg(msg); + } + if(altered_master) middleware->updateResources(master); @@ -569,10 +576,6 @@ int wmidi = -1; delete [] msg; } - //set titles - if(!ui_title.empty()) - GUI::raiseUi(gui, "/ui/title", "s", ui_title.c_str()); - if(!noui) { GUI::raiseUi(gui, "/show", "i", config.cfg.UserInterfaceMode);