Skip to content

Commit

Permalink
Wavetable Option Plubming
Browse files Browse the repository at this point in the history
This makes the Wavetable Morph option available and sets up
options for future changes too if we want.

Critically it doesn't *do* anything with the deform state it
just versions and edits it appropriately.

Addresses #7784
  • Loading branch information
baconpaul committed Sep 13, 2024
1 parent d94d252 commit 2cc1a18
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ bool Parameter::can_extend_range() const
case ct_percent_oscdrift:
case ct_twist_aux_mix:
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
case ct_dly_fb_clippingmodes:
case ct_bonsai_bass_boost:
case ct_detuning:
Expand Down Expand Up @@ -378,6 +379,7 @@ bool Parameter::has_deformoptions() const
case ct_envtime_deformable:
case ct_filter_feedback:
case ct_osc_feedback_negative:
case ct_countedset_percent_extendable_wtdeform:
return true;
default:
break;
Expand Down Expand Up @@ -527,6 +529,7 @@ void Parameter::set_user_data(ParamUserData *ud)
{
case ct_countedset_percent:
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
if (dynamic_cast<CountedSetUserData *>(ud))
{
user_data = ud;
Expand Down Expand Up @@ -1123,6 +1126,7 @@ void Parameter::set_type(int ctrltype)
break;
case ct_countedset_percent:
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
val_min.f = 0;
val_max.f = 1;
valtype = vt_float;
Expand Down Expand Up @@ -1398,6 +1402,7 @@ void Parameter::set_type(int ctrltype)
case ct_rotarydrive:
case ct_countedset_percent:
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
case ct_lfoamplitude:
case ct_lfophaseshuffle:
case ct_reson_res_extendable:
Expand Down Expand Up @@ -1933,6 +1938,7 @@ void Parameter::bound_value(bool force_integer)
}
case ct_countedset_percent:
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
{
CountedSetUserData *cs = reinterpret_cast<CountedSetUserData *>(user_data);
if (cs)
Expand Down Expand Up @@ -3343,6 +3349,7 @@ void Parameter::get_display_alt(char *txt, bool external, float ef) const
}
case ct_countedset_percent:
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
if (user_data != nullptr)
{
// We check when set so the reinterpret cast is safe and fast
Expand Down Expand Up @@ -4430,6 +4437,7 @@ bool Parameter::can_setvalue_from_string() const
case ct_oscspread_bipolar:
case ct_countedset_percent:
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
case ct_flangerpitch:
case ct_flangervoices:
case ct_flangerspacing:
Expand Down
5 changes: 3 additions & 2 deletions src/common/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ enum ctrltypes
ct_sineoscmode,
ct_ringmod_sineoscmode,
ct_sinefmlegacy,
ct_countedset_percent, // what % through a counted set are we
ct_countedset_percent_extendable, // what % through a counted set are we
ct_countedset_percent, // what % through a counted set are we
ct_countedset_percent_extendable, // what % through a counted set are we
ct_countedset_percent_extendable_wtdeform, // what % through a counted set are we
ct_vocoder_bandcount,
ct_distortion_waveshape,
ct_flangerpitch,
Expand Down
3 changes: 2 additions & 1 deletion src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ const int FIRoffsetI16 = FIRipolI16_N >> 1;
// 23 -> 24 (XT 1.3.3 nightlies) added actually functioning extend mode to FM2 oscillator's M1/2 Offset parameter
// (old patches load with extend disabled even if they had it enabled)
// 24 -> 25 (XT 1.3.4 nightlies) added storing of Wavetable Script Editor window state
// 25 -> 26 (XT 1.4.* nightlies) added WT Deform for new WT features
// clang-format on

const int ff_revision = 25;
const int ff_revision = 26;

const int n_scene_params = 273;
const int n_global_params = 11 + n_fx_slots * (n_fx_params + 1); // each param plus a type
Expand Down
19 changes: 18 additions & 1 deletion src/common/dsp/oscillators/WavetableOscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void WavetableOscillator::init(float pitch, bool is_display, bool nonzero_init_d
void WavetableOscillator::init_ctrltypes()
{
oscdata->p[wt_morph].set_name("Morph");
oscdata->p[wt_morph].set_type(ct_countedset_percent_extendable);
oscdata->p[wt_morph].set_type(ct_countedset_percent_extendable_wtdeform);
oscdata->p[wt_morph].set_user_data(oscdata);
oscdata->p[wt_skewv].set_name("Skew Vertical");
oscdata->p[wt_skewv].set_type(ct_percent_bipolar);
Expand All @@ -150,6 +150,7 @@ void WavetableOscillator::init_default_values()
{
oscdata->p[wt_morph].val.f = 0.0f;
oscdata->p[wt_morph].set_extend_range(true);
oscdata->p[wt_morph].deform_type = FeatureDeform::XT_14;
oscdata->p[wt_skewv].val.f = 0.0f;
oscdata->p[wt_saturate].val.f = 0.f;
oscdata->p[wt_formant].val.f = 0.f;
Expand Down Expand Up @@ -407,6 +408,18 @@ template <bool is_init> void WavetableOscillator::update_lagvals()
void WavetableOscillator::process_block(float pitch0, float drift, bool stereo, bool FM,
float depth)
{
auto fd = (FeatureDeform)oscdata->p[wt_morph].deform_type;
#if 0
if (fd == XT_134_EARLIER)
{
std::cout << "OLD WAY" << std::endl;
}
else
{
std::cout << "NEW WAY" << std::endl;
}
#endif

pitch_last = pitch_t;
pitch_t = min(148.f, pitch0);
pitchmult_inv =
Expand Down Expand Up @@ -564,4 +577,8 @@ void WavetableOscillator::handleStreamingMismatches(int streamingRevision,
{
oscdata->p[wt_morph].set_extend_range(true);
}
if (streamingRevision <= 25)
{
oscdata->p[wt_morph].deform_type = (int)FeatureDeform::XT_134_EARLIER;
}
}
6 changes: 6 additions & 0 deletions src/common/dsp/oscillators/WavetableOscillator.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class WavetableOscillator : public AbstractBlitOscillator
wt_unison_voices,
};

enum FeatureDeform
{
XT_134_EARLIER = 0,
XT_14 = 1 << 0
};

lipol_ps li_hpf, li_DC, li_integratormult;
WavetableOscillator(SurgeStorage *storage, OscillatorStorage *oscdata, pdata *localcopy,
pdata *localcopyUnmod);
Expand Down
25 changes: 25 additions & 0 deletions src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "overlays/ModulationEditor.h"
#include "overlays/PatchStoreDialog.h"
#include "overlays/TypeinParamEditor.h"
#include "WavetableOscillator.h"

std::string decodeControllerID(int id)
{
Expand Down Expand Up @@ -2600,6 +2601,29 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c

break;
}
case ct_countedset_percent_extendable_wtdeform:
{
contextMenu.addSeparator();
auto dt = p->deform_type;
for (const auto &[opt, lab] :
{std::make_pair(WavetableOscillator::FeatureDeform::XT_134_EARLIER,
"Slow Lag and WT Jump Noise (<= 1.3.4 behavior)"),
{WavetableOscillator::FeatureDeform::XT_14,
"No Modulation Lag and No WT Jump Noise (1.4 and later)"}})
{
contextMenu.addItem(Surge::GUI::toOSCase(lab), true, dt == (int)opt,
[this, p, ov = opt]() {
undoManager()->pushParameterChange(p->id, p,
p->val);
update_deform_type(p, (int)ov);
synth->storage.getPatch().isDirty = true;
frame->repaint();
});
}

contextMenu.addSeparator();
}
break;
default:
{
break;
Expand Down Expand Up @@ -2647,6 +2671,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
txt = "Pan Main and Auxiliary Signals";
break;
case ct_countedset_percent_extendable:
case ct_countedset_percent_extendable_wtdeform:
txt = "Continuous Morph";
break;
default:
Expand Down

0 comments on commit 2cc1a18

Please sign in to comment.