Skip to content

Commit

Permalink
Adjust ChowTape and Ensemble for MSVC AMR64EC crash
Browse files Browse the repository at this point in the history
compiler crash that is
  • Loading branch information
Paul Walker (Baconpaul) committed Oct 31, 2024
1 parent faf754f commit 1e31afa
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,11 +1178,18 @@ void Parameter::set_type(int ctrltype)
break;
case ct_ensemble_stages:
{
#if defined(_M_ARM64EC)
valtype = vt_int;
val_min.i = 0;
val_max.i = 1;
val_default.i = 0;
#else
extern int ensemble_stage_count();
valtype = vt_int;
val_min.i = 0;
val_max.i = ensemble_stage_count() - 1;
val_default.i = 0;
#endif
break;
}
case ct_stringosc_excitation_model:
Expand Down Expand Up @@ -4064,8 +4071,12 @@ std::string Parameter::get_display(bool external, float ef) const
break;
case ct_ensemble_stages:
{
#if defined(_M_ARM64EC)
txt = "name";
#else
extern std::string ensemble_stage_name(int);
txt = ensemble_stage_name(i);
#endif
}
break;
case ct_reson_mode:
Expand Down
8 changes: 8 additions & 0 deletions src/common/dsp/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
* All source for Surge XT is available at
* https://github.com/surge-synthesizer/surge
*/

#if !defined(_M_ARM64EC)
#include "BBDEnsembleEffect.h"
#endif

#include "BonsaiEffect.h"
#include "ChorusEffectImpl.h"
#include "CombulatorEffect.h"
Expand Down Expand Up @@ -104,7 +108,11 @@ Effect *spawn_effect(int id, SurgeStorage *storage, FxStorage *fxdata, pdata *pd
case fxt_tape:
return new chowdsp::TapeEffect(storage, fxdata, pd);
case fxt_ensemble:
#if defined(_M_ARM64EC)
return nullptr;
#else
return new BBDEnsembleEffect(storage, fxdata, pd);
#endif
case fxt_treemonster:
return new TreemonsterEffect(storage, fxdata, pd);
case fxt_waveshaper:
Expand Down
6 changes: 5 additions & 1 deletion src/common/dsp/effects/BBDEnsembleEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* https://github.com/surge-synthesizer/surge
*/

#if !defined(_M_ARM64EC)

#include "BBDEnsembleEffect.h"

#include "sst/basic-blocks/mechanics/block-ops.h"
Expand Down Expand Up @@ -568,4 +570,6 @@ void BBDEnsembleEffect::handleStreamingMismatches(int streamingRevision,
fxdata->p[ens_output_filter].val.f = defaultFilterCut;
fxdata->p[ens_output_filter].deactivated = true;
}
}
}

#endif
5 changes: 5 additions & 0 deletions src/common/dsp/effects/BBDEnsembleEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#ifndef SURGE_SRC_COMMON_DSP_EFFECTS_BBDENSEMBLEEFFECT_H
#define SURGE_SRC_COMMON_DSP_EFFECTS_BBDENSEMBLEEFFECT_H

#if !defined(_M_ARM64EC)

#include "Effect.h"
#include "BiquadFilter.h"
#include "DSPUtils.h"
Expand Down Expand Up @@ -108,4 +111,6 @@ class BBDEnsembleEffect : public Effect
BiquadFilter sincInputFilter;
};

#endif

#endif // SURGE_SRC_COMMON_DSP_EFFECTS_BBDENSEMBLEEFFECT_H
9 changes: 7 additions & 2 deletions src/common/dsp/effects/chowdsp/bbd_utils/BBDNonlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class BBDNonlin

void setDrive(float newDrive) { drive = newDrive; }

inline __m128 processSample(__m128 Vg) noexcept
inline __m128 processSample(__m128 Vg) noexcept
{
Vin->setVoltage(Vg);
Is->setCurrent(getCurrent(Vg, Vp));
Expand All @@ -205,7 +205,12 @@ class BBDNonlin
S2.incident(D1.reflected());
Vp = Cpk->voltage();

return vAdd(vMul(Vp, vLoad1(drive)), vMul(Vg, vLoad1(1.0f - drive)));
auto vd = vLoad1(drive);
auto vdm = vLoad1(1.0f - drive);
auto a1 = vMul(Vp, vd);
auto a2 = vMul(Vg,vdm);
auto res = vAdd(a1, a2);
return res;
}

private:
Expand Down
4 changes: 4 additions & 0 deletions src/common/dsp/effects/chowdsp/tape/HysteresisOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
#include "globals.h"
#include "sst/basic-blocks/dsp/FastMath.h"

#if defined(_M_ARM64EC)
#define CHOWTAPE_HYSTERESIS_USE_SIMD 0
#else
#define CHOWTAPE_HYSTERESIS_USE_SIMD 1
#endif

namespace HysteresisOps
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/effects/chowdsp/tape/HysteresisProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class HysteresisProcessing
M = _mm_set1_pd(0.0);
#else
M = 0.0;
#endif
};

// check for instability
Expand All @@ -97,6 +96,7 @@ class HysteresisProcessing
H_d_n1 = H_d;

return M;
#endif
}

private:
Expand Down

0 comments on commit 1e31afa

Please sign in to comment.