From d605a7a9166dce74aa17d33da92e11ca9b467e55 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 24 Apr 2021 20:31:53 +0200 Subject: added voice limit cli parameters --- drumgizmo/drumgizmoc.cc | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ man/drumgizmo.1 | 17 ++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index cec96f7..8eba4c9 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -142,6 +142,12 @@ static std::string arguments() " diverse: The importance given to choosing samples\n" " which haven't been played recently. [0,1]\n" " random: The amount of randomness added. [0,1]\n" + "\n" + "Voice limit parameters:\n" + " max: Maximum number of voices for each instrument before\n" + " old samples are ramped down. [1,30]\n" + " rampdown: Time it takes for an old sample to completely fall\n" + " silent. [0.01,2.0]\n" "\n"; return output.str(); } @@ -545,6 +551,54 @@ int main(int argc, char* argv[]) return 0; }); + // Default is to disable voice limit + settings.enable_voice_limit.store(false); + + opt.add("voice-limit", no_argument, 'l', + "Enable voice limit.", + [&]() + { + settings.enable_voice_limit.store(true); + return 0; + }); + + opt.add("voice-limitparms", required_argument, 'L', + "Voice limit options.", + [&]() + { + std::string parms = optarg; + auto tokens = parseParameters(parms); + for(auto& token : tokens) + { + if(token.key == "max") + { + auto val = atof_nol(token.value.data()); + if(val < 1.0 || val > 30.0) + { + std::cerr << "max range is [1, 30].\n"; + return 1; + } + settings.voice_limit_max.store(val); + } + else if(token.key == "rampdown") + { + auto val = atof_nol(token.value.data()); + if(val < 0.01 || val > 2.0) + { + std::cerr << "rampdown range is [0.01, 2.0].\n"; + return 1; + } + settings.voice_limit_rampdown.store(val); + } + else + { + std::cerr << "Unknown voice limitparms argument " << token.key << std::endl; + return 1; + } + } + return 0; + }); + opt.add("parameters", required_argument, 'p', "Parameters for sample selection algorithm.", [&]() diff --git a/man/drumgizmo.1 b/man/drumgizmo.1 index ac8628e..43b0a29 100644 --- a/man/drumgizmo.1 +++ b/man/drumgizmo.1 @@ -175,6 +175,23 @@ when there are spaces between the notes. Lower values result in faster regain. [ Higher value makes it more likely that a sample further away from the input velocity will be played. [0,4.5]) +.RE +\fB-l, --voice-limit\fR +.RS 7 +Enable voice limit. + +.RE +\fB-L, --voice-limitparms parmlist\fR +.RS 7 +Voice limit options. + +.P +\fBmax\fR= (Maximum number of voices for each instrument before +old samples are ramped down. [1,30]) +.P +\fBrampdown\fR= (Time it takes for an old sample to completely fall +silent. [0.01,2.0]) + .RE \fB-p, --parameters parmlist\fR .RS 7 -- cgit v1.2.3