Skip to content

Commit

Permalink
Deactivate misleading tuning typeins in Tune-After mode (#7178)
Browse files Browse the repository at this point in the history
In Tune-After mode the typein "9/8" didn't uniformly give you
a 9/8 pitch shift; it gave you that many keys shift. This was
rather confusing. Some even called it "borked". So just make
a clear error that this typein style is only availabel in
tune-at-midi mode

Closes #6977
  • Loading branch information
baconpaul authored Aug 12, 2023
1 parent 7367738 commit 41942bf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4497,6 +4497,9 @@ bool Parameter::set_value_from_string_onto(const std::string &s, pdata &ontoThis
{
if (extend_range && s.find("/") != std::string::npos)
{
if (!supports_tuning_value_from_string(s, errMsg))
return false;

try
{
auto a = Tunings::toneFromString(s);
Expand Down Expand Up @@ -4627,6 +4630,9 @@ bool Parameter::set_value_from_string_onto(const std::string &s, pdata &ontoThis
// Check for a fraction
if (s.find("/") != std::string::npos)
{
if (!supports_tuning_value_from_string(s, errMsg))
return false;

try
{
auto a = Tunings::toneFromString(s);
Expand Down Expand Up @@ -4919,6 +4925,9 @@ float Parameter::calculate_modulation_value_from_string(const std::string &s, st
// Check for a fraction
if (s.find("/") != std::string::npos)
{
if (!supports_tuning_value_from_string(s, errMsg))
return false;

try
{
auto a = Tunings::toneFromString(s);
Expand Down Expand Up @@ -5022,6 +5031,9 @@ float Parameter::calculate_modulation_value_from_string(const std::string &s, st

if (s[0] == 'T' || s[0] == 't')
{
if (!supports_tuning_value_from_string(s, errMsg))
return false;

try
{
auto a = Tunings::toneFromString(s.c_str() + 1);
Expand Down Expand Up @@ -5299,4 +5311,20 @@ float Parameter::calculate_modulation_value_from_string(const std::string &s, st
return 0.0;
}

bool Parameter::supports_tuning_value_from_string(const std::string &s, std::string &errMsg)
{
if (!storage)
{
// Well that's odd! But let it go.
return true;
}
if (storage->tuningApplicationMode == SurgeStorage::TuningApplicationMode::RETUNE_ALL)
{
errMsg = "No ratio type-ins in tune-after mode";
return false;
}

return true;
}

std::atomic<bool> parameterNameUpdated(false);
1 change: 1 addition & 0 deletions src/common/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ class Parameter
void set_value_f01(float v, bool force_integer = false);
bool set_value_from_string(const std::string &s, std::string &errMsg);
bool set_value_from_string_onto(const std::string &s, pdata &ontoThis, std::string &errMsg);
bool supports_tuning_value_from_string(const std::string &s, std::string &errMsg);
void set_error_message(std::string &errMsg, const std::string value, const std::string unit,
const ErrorMessageMode mode);
void set_extend_range(bool er);
Expand Down

0 comments on commit 41942bf

Please sign in to comment.