Skip to content

Commit

Permalink
WT minor tweaks (#7807)
Browse files Browse the repository at this point in the history
Background frames are less opaque
Force WT refresh when muting the osc
Rename WT fixes option to Legacy Mode
  • Loading branch information
mkruselj committed Sep 28, 2024
1 parent e09d122 commit e63fa3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
auto dt = p->deform_type;

contextMenu.addItem(
Surge::GUI::toOSCase("Legacy Lag, Smooth and Table Interp"), true,
Surge::GUI::toOSCase("Legacy Mode"), true,
dt == (int)WavetableOscillator::FeatureDeform::XT_134_EARLIER,
[this, p, dt]() {
undoManager()->pushParameterChange(p->id, p, p->val);
Expand Down
53 changes: 17 additions & 36 deletions src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,7 @@ void OscillatorWaveformDisplay::paint(juce::Graphics &g)

if (usesWT)
{
// It's a bit unsatisfactory to put this here but we don't really get notified
// once the wavetable change is done other than through repaint
if (oscdata->wt.current_id != lastWavetableId || forceWTRepaint) // more unsatisfactory!)
if (oscdata->wt.current_id != lastWavetableId || forceWTRepaint)
{
if (forceWTRepaint)
{
Expand Down Expand Up @@ -525,6 +523,7 @@ void OscillatorWaveformDisplay::repaintBasedOnOscMuteState()

if (oscInvalid)
{
forceWTRepaint = true;
repaint();
}
}
Expand Down Expand Up @@ -1441,14 +1440,10 @@ struct WaveTable3DEditor : public juce::Component,
auto osc = parent->setupOscillator();
osc->init(0, true, false);

float opacity = 1;

float opacity = 0.666;
float opacityMultiplier = parent->isMuted ? 0.5f : 1.f;

/*
Draw the base layer
*/

// draw the base layer
if (paramsHaveChanged() || hasResized)
{
hasResized = false;
Expand All @@ -1461,58 +1456,44 @@ struct WaveTable3DEditor : public juce::Component,

for (int i = 0; i < rendered_frames; i++)
{
// on lower frames lower the opacity, as we will add the actual frames on top of the
// base shape for emphasis

if (wt_nframes <= 10 && wt_nframes > 1)
{
opacity = 0.5;
}

float proc = (float)i / (float)rendered_frames;

drawWaveform(g, i, rendered_frames,
skin->getColor(Colors::Osc::Display::WaveCurrent3D),
(0.9 - 0.7 * proc) * opacityMultiplier * 0.5, 1, osc, 1.f, true);
drawWaveform(
g, i, rendered_frames, skin->getColor(Colors::Osc::Display::WaveCurrent3D),
(0.9 - 0.7 * proc) * opacity * opacityMultiplier * 0.5, 1, osc, 1.f, true);
}

// On lower frames, draw the actual frames on top of the base shape

// on lower frames, draw the actual frames on top of the base shape
if (wt_nframes <= 10 && wt_nframes > 1)
{
opacity = 0.7;
opacity = 0.5;

for (int i = 0; i < wt_nframes; i++)
{
float proc = (float)i / (float)rendered_frames;
int fr = (float)i / ((float)wt_nframes - 1) * ((float)rendered_frames - 1.f);

drawWaveform(g, fr, rendered_frames,
skin->getColor(Colors::Osc::Display::WaveCurrent3D),
(0.9 - 0.7 * proc) * opacityMultiplier * 0.6, 1.0, osc, 1.f, true);
(0.9 - 0.7 * proc) * opacity * opacityMultiplier * 0.5, 1.0, osc,
1.f, true);
}
}

/*
Draw the wavetable position (morph)
Do not use cache for a smoother motion
*/

// draw the wavetable position (morph)
// do not use cache for a smoother motion
float pos = morphValue;
int position = pos * (128 - 1);

drawWaveform(g, position, 128, skin->getColor(Colors::Osc::Display::WaveCurrent3D),
0.9 * opacityMultiplier, 1.5, osc, 1.f, false);
}

// draw backingimage to graphics context
// draw backing image to graphics context
g.drawImage(*backingImage, getLocalBounds().toFloat(),
juce::RectanglePlacement::fillDestination);

// osc->~Oscillator();
// osc = nullptr;
}

/*
draws the waveform
*/
void drawWaveform(juce::Graphics &g, int i, int renderedFrames, juce::Colour color,
float opacity, float thick, ::Oscillator *osc, float scale, bool useCache)
{
Expand Down

0 comments on commit e63fa3f

Please sign in to comment.