Skip to content

Commit

Permalink
Minor UX tweaks (#7958)
Browse files Browse the repository at this point in the history
* Add disabled entries to MSEG Segment context menu - These show the segment's duration, value and control point info
* Adjust name of step seq value edit menu entries
* Small code cleanup for MSEGEditor
* Add getValueDispPrecision() to SurgeStorage
* Update all cases of checking HighPrecisionReadouts option consequently
  • Loading branch information
mkruselj authored Jan 10, 2025
1 parent 94cb2fa commit 95ef2bb
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 135 deletions.
21 changes: 4 additions & 17 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2439,13 +2439,7 @@ void Parameter::get_display_of_modulation_depth(char *txt, float modulationDepth
{
#define ITXT_SIZE 1024

int detailedMode = false;

if (storage)
{
detailedMode =
Surge::Storage::getUserDefaultValue(storage, Surge::Storage::HighPrecisionReadouts, 0);
}
const bool detailedMode = Surge::Storage::getValueDispPrecision(storage);

if (basicBlocksParamMetaData.has_value() && basicBlocksParamMetaData->supportsStringConversion)
{
Expand Down Expand Up @@ -3286,8 +3280,7 @@ void Parameter::get_display_alt(char *txt, bool external, float ef) const
}
}

int detailedMode =
Surge::Storage::getUserDefaultValue(storage, Surge::Storage::HighPrecisionReadouts, 0);
const bool detailedMode = Surge::Storage::getValueDispPrecision(storage);

txt[0] = 0;
switch (ctrltype)
Expand Down Expand Up @@ -3454,13 +3447,7 @@ std::string Parameter::get_display(bool external, float ef) const
float f;
bool b;

int detailedMode = 0;

if (storage)
{
detailedMode =
Surge::Storage::getUserDefaultValue(storage, Surge::Storage::HighPrecisionReadouts, 0);
}
const bool detailedMode = Surge::Storage::getValueDispPrecision(storage);

if (basicBlocksParamMetaData.has_value() && basicBlocksParamMetaData->supportsStringConversion)
{
Expand Down Expand Up @@ -3591,7 +3578,7 @@ std::string Parameter::get_display(bool external, float ef) const
{
dval *= 1000.f;
u = "ms";
dec = detailedMode ? 2 : 1;
dec = detailedMode ? 3 : 1;
}
}

Expand Down
66 changes: 38 additions & 28 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3243,6 +3243,39 @@ float SurgeStorage::remapKeyInMidiOnlyMode(float res)
return res;
}

Surge::Storage::ScenesOutputData::ScenesOutputData()
{
for (int i = 0; i < n_scenes; i++)
{
for (int j = 0; j < N_OUTPUTS; j++)
{
std::shared_ptr<float> block(new float[BLOCK_SIZE], [](float *p) { delete[] p; });
memset(block.get(), 0, BLOCK_SIZE * sizeof(float));
sceneData[i][j] = block;
}
}
}
const std::shared_ptr<float> &Surge::Storage::ScenesOutputData::getSceneData(int scene,
int channel) const
{
assert(scene < n_scenes && scene >= 0);
assert(channel < N_OUTPUTS && channel >= 0);
return sceneData[scene][channel];
}
bool Surge::Storage::ScenesOutputData::thereAreClients(int scene) const
{
return std::any_of(std::begin(sceneData[scene]), std::end(sceneData[scene]),
[](const auto &channel) { return channel.use_count() > 1; });
}
void Surge::Storage::ScenesOutputData::provideSceneData(int scene, int channel, float *data)
{
if (scene < n_scenes && scene >= 0 && channel < N_OUTPUTS && channel >= 0 &&
sceneData[scene][channel].use_count() > 1) // we don't provide data if there are no clients
{
memcpy(sceneData[scene][channel].get(), data, BLOCK_SIZE * sizeof(float));
}
}

namespace Surge
{
namespace Storage
Expand Down Expand Up @@ -3465,37 +3498,14 @@ std::string base64_decode(std::string const &encoded_string)
return ret;
}

Surge::Storage::ScenesOutputData::ScenesOutputData()
bool getValueDispPrecision(SurgeStorage *storage)
{
for (int i = 0; i < n_scenes; i++)
if (storage)
{
for (int j = 0; j < N_OUTPUTS; j++)
{
std::shared_ptr<float> block(new float[BLOCK_SIZE], [](float *p) { delete[] p; });
memset(block.get(), 0, BLOCK_SIZE * sizeof(float));
sceneData[i][j] = block;
}
}
}
const std::shared_ptr<float> &Surge::Storage::ScenesOutputData::getSceneData(int scene,
int channel) const
{
assert(scene < n_scenes && scene >= 0);
assert(channel < N_OUTPUTS && channel >= 0);
return sceneData[scene][channel];
}
bool Surge::Storage::ScenesOutputData::thereAreClients(int scene) const
{
return std::any_of(std::begin(sceneData[scene]), std::end(sceneData[scene]),
[](const auto &channel) { return channel.use_count() > 1; });
}
void Surge::Storage::ScenesOutputData::provideSceneData(int scene, int channel, float *data)
{
if (scene < n_scenes && scene >= 0 && channel < N_OUTPUTS && channel >= 0 &&
sceneData[scene][channel].use_count() > 1) // we don't provide data if there are no clients
{
memcpy(sceneData[scene][channel].get(), data, BLOCK_SIZE * sizeof(float));
return getUserDefaultValue(storage, HighPrecisionReadouts, false);
}

return false;
}

} // namespace Storage
Expand Down
2 changes: 2 additions & 0 deletions src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,8 @@ bool is_base64(unsigned char c);
std::string base64_encode(unsigned char const *bytes_to_encode, unsigned int in_len);
std::string base64_decode(std::string const &encoded_string);

bool getValueDispPrecision(SurgeStorage *storage);

} // namespace Storage
} // namespace Surge

Expand Down
9 changes: 2 additions & 7 deletions src/common/dsp/effects/airwindows/AirWindowsEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,8 @@ void AirWindowsEffect::process(float *dataL, float *dataR)
void AirWindowsEffect::setupSubFX(int sfx, bool useStreamedValues)
{
const auto &r = fxreg[sfx];

bool detailedMode = false;
if (storage)
detailedMode =
Surge::Storage::getUserDefaultValue(storage, Surge::Storage::HighPrecisionReadouts, 0);

int dp = (detailedMode ? 6 : 2);
const bool detailedMode = Surge::Storage::getValueDispPrecision(storage);
int dp = detailedMode ? 6 : 2;

airwin = r.create(r.id, storage->dsamplerate, dp); // FIXME
airwin->storage = storage;
Expand Down
10 changes: 2 additions & 8 deletions src/common/dsp/effects/airwindows/AirWindowsEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,8 @@ class alignas(16) AirWindowsEffect : public Effect
fx->airwin->setParameter(idx, value);
}

if (fx->storage)
{
auto detailedMode = Surge::Storage::getUserDefaultValue(
fx->storage, Surge::Storage::HighPrecisionReadouts, 0);

fx->airwin->displayPrecision = (detailedMode ? 6 : 2);
}

fx->airwin->displayPrecision =
Surge::Storage::getValueDispPrecision(fx->storage) ? 6 : 2;
fx->airwin->getParameterLabel(idx, lab);
fx->airwin->getParameterDisplay(idx, dis, value, true);
}
Expand Down
3 changes: 1 addition & 2 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3435,8 +3435,7 @@ void SurgeGUIEditor::promptForUserValueEntry(Parameter *p, juce::Component *c, i
}
else
{
int detailedMode = Surge::Storage::getUserDefaultValue(
&(this->synth->storage), Surge::Storage::HighPrecisionReadouts, 0);
const bool detailedMode = Surge::Storage::getValueDispPrecision(&(this->synth->storage));
auto cms = ((ControllerModulationSource *)synth->storage.getPatch()
.scene[current_scene]
.modsources[ms]);
Expand Down
9 changes: 4 additions & 5 deletions src/surge-xt/gui/SurgeGUIEditorMenuStructures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,14 +1140,13 @@ juce::PopupMenu SurgeGUIEditor::makeValueDisplaysMenu(const juce::Point<int> &wh
{
auto dispDefMenu = juce::PopupMenu();

bool precReadout = Surge::Storage::getUserDefaultValue(
&(this->synth->storage), Surge::Storage::HighPrecisionReadouts, false);
const bool detailedMode = Surge::Storage::getValueDispPrecision(&(this->synth->storage));

dispDefMenu.addItem(Surge::GUI::toOSCase("High Precision Value Readouts"), true, precReadout,
[this, precReadout]() {
dispDefMenu.addItem(Surge::GUI::toOSCase("High Precision Value Readouts"), true, detailedMode,
[this, detailedMode]() {
Surge::Storage::updateUserDefaultValue(
&(this->synth->storage), Surge::Storage::HighPrecisionReadouts,
!precReadout);
!detailedMode);
});

// modulation value readout shows bounds
Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,8 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c

bool cancellearn = false;
int ccid = 0;
int detailedMode = Surge::Storage::getUserDefaultValue(
&(this->synth->storage), Surge::Storage::HighPrecisionReadouts, 0);
const bool detailedMode =
Surge::Storage::getValueDispPrecision(&(this->synth->storage));

// should start at 0, but it started at 1 before
// there might be a reason but I don't remember why
Expand Down
Loading

0 comments on commit 95ef2bb

Please sign in to comment.