Skip to content

Commit

Permalink
A set of minor beta fixes
Browse files Browse the repository at this point in the history
1. Add a regtest to show FTZ works properly.
2. Don't allow -ve typeins to nan A2bx. Closes surge-synthesizer#5607
3. Deal with command toggle on/off during drag to change states
   even more properly. Closes surge-synthesizer#5606
4. Don't linger hover from Type onto Step Seq Shift.
   Closes surge-synthesizer#5605
5. Formula/Modulator cross-scene tearout works. Closes surge-synthesizer#5590
  • Loading branch information
baconpaul committed Dec 9, 2021
1 parent d4f9c48 commit 04be2a1
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4232,6 +4232,10 @@ bool Parameter::set_value_from_string_onto(const std::string &s, pdata &ontoThis
** log2(v/a) = bx
** log2(v/a)/b = x;
*/
if (nv <= 0 || !std::isfinite(nv))
{
return false;
}
float res = log2f(nv / displayInfo.a) / displayInfo.b;

if (res < val_min.f || res > val_max.f)
Expand Down
25 changes: 25 additions & 0 deletions src/surge-testrunner/UnitTestsDSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <complex>

#include "LanczosResampler.h"
#include "CPUFeatures.h"

using namespace Surge::Test;

Expand Down Expand Up @@ -1054,4 +1055,28 @@ TEST_CASE("Wavehaper LUT", "[dsp]")
}
}
}
}

TEST_CASE("FTZ", "[dsp]")
{
auto g = Surge::CPUFeatures::FPUStateGuard();

unsigned char min_float[4] = {0x00, 0x00, 0x80, 0x00};
float f_min;
memcpy(&f_min, min_float, 4);
REQUIRE(f_min != 0.f);

unsigned char res_float[4];
for (int i = 0; i < 100; ++i)
{
// don't let the compiler optimize me away!
auto r = 1.0 / (fabs(rand() % 10) + 1.1); // a number < 1
float ftz_float = f_min * r;
memcpy(res_float, &ftz_float, 4);
for (int i = 0; i < 4; ++i)
{
REQUIRE(res_float[i] == 0);
}
REQUIRE(ftz_float == 0.f);
}
}
6 changes: 5 additions & 1 deletion src/surge-xt/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener,
}

Surge::Overlays::OverlayWrapper *getOverlayWrapperIfOpen(OverlayTags tag);
void refreshOverlayWithOpenClose(OverlayTags tag);
void refreshOverlayWithOpenClose(OverlayTags tag)
{
refreshAndMorphOverlayWithOpenClose(tag, tag);
}
void refreshAndMorphOverlayWithOpenClose(OverlayTags tag, OverlayTags newTag);

void updateWaveshaperOverlay(); // this is the only overlay which updates from patch values

Expand Down
8 changes: 4 additions & 4 deletions src/surge-xt/gui/SurgeGUIEditorOverlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ void SurgeGUIEditor::rezoomOverlays()
}
}

void SurgeGUIEditor::refreshOverlayWithOpenClose(OverlayTags tag)
void SurgeGUIEditor::refreshAndMorphOverlayWithOpenClose(OverlayTags tag, OverlayTags newTag)
{
if (!isAnyOverlayPresent(tag))
return;
Expand All @@ -590,7 +590,7 @@ void SurgeGUIEditor::refreshOverlayWithOpenClose(OverlayTags tag)
* Some editors can do better than a forced open-clsoe
*/
bool couldRefresh = true;
switch (tag)
switch (newTag)
{
case TUNING_EDITOR:
{
Expand Down Expand Up @@ -624,10 +624,10 @@ void SurgeGUIEditor::refreshOverlayWithOpenClose(OverlayTags tag)
if (!couldRefresh)
{
closeOverlay(tag);
showOverlay(tag);
showOverlay(newTag);
if (to)
{
olw = getOverlayWrapperIfOpen(tag);
olw = getOverlayWrapperIfOpen(newTag);
if (olw)
olw->doTearOut(tol);
}
Expand Down
32 changes: 17 additions & 15 deletions src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,35 +278,37 @@ void SurgeGUIEditor::changeSelectedScene(int value)
synth->release_if_latched[synth->storage.getPatch().scene_active.val.i] = true;
synth->storage.getPatch().scene_active.val.i = current_scene;

if (isAnyOverlayPresent(MSEG_EDITOR))
bool hasMSEG = isAnyOverlayPresent(MSEG_EDITOR);
bool hasForm = isAnyOverlayPresent(FORMULA_EDITOR);

if (hasForm || hasMSEG)
{
auto ld = &(synth->storage.getPatch()
.scene[current_scene]
.lfo[modsource_editor[current_scene] - ms_lfo1]);

if (ld->shape.val.i == lt_mseg)
if (ld->shape.val.i == lt_mseg && hasMSEG)
{
refreshOverlayWithOpenClose(SurgeGUIEditor::MSEG_EDITOR);
}
else
else if (ld->shape.val.i == lt_formula && hasForm)
{
closeOverlay(SurgeGUIEditor::MSEG_EDITOR);
refreshOverlayWithOpenClose(SurgeGUIEditor::FORMULA_EDITOR);
}
}

if (isAnyOverlayPresent(FORMULA_EDITOR))
{
auto ld = &(synth->storage.getPatch()
.scene[current_scene]
.lfo[modsource_editor[current_scene] - ms_lfo1]);

if (ld->shape.val.i == lt_formula)
else if (ld->shape.val.i == lt_mseg && hasForm)
{
refreshOverlayWithOpenClose(SurgeGUIEditor::FORMULA_EDITOR);
refreshAndMorphOverlayWithOpenClose(FORMULA_EDITOR, MSEG_EDITOR);
}
else if (ld->shape.val.i == lt_formula && hasMSEG)
{
refreshAndMorphOverlayWithOpenClose(MSEG_EDITOR, FORMULA_EDITOR);
}
else
{
closeOverlay(SurgeGUIEditor::FORMULA_EDITOR);
if (hasForm)
closeOverlay(SurgeGUIEditor::FORMULA_EDITOR);
if (hasMSEG)
closeOverlay(SurgeGUIEditor::MSEG_EDITOR);
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,8 @@ void LFOAndStepDisplay::mouseMove(const juce::MouseEvent &event)
}
}

// reset for the step hover
nextHover = -1;
if (ss_shift_left.contains(event.position))
{
nextHover = 0;
Expand Down Expand Up @@ -1670,6 +1672,12 @@ void LFOAndStepDisplay::mouseDrag(const juce::MouseEvent &event)
setStepToDefault(event);
return;
}
else
{
dragMode = VALUES;
setStepValue(event);
return;
}
break;
}
case TRIGGERS:
Expand Down Expand Up @@ -1700,6 +1708,7 @@ void LFOAndStepDisplay::mouseDrag(const juce::MouseEvent &event)
{
if (event.mods.isCommandDown())
{
dragMode = RESET_VALUE;
setStepToDefault(event);
}
else
Expand Down

0 comments on commit 04be2a1

Please sign in to comment.