Skip to content

Commit

Permalink
A URNG for the synth
Browse files Browse the repository at this point in the history
rather than a seeded RNG per LFO allows independent noise envelopes
  • Loading branch information
baconpaul committed Dec 28, 2024
1 parent 4c22d1b commit 9639910
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/dsp/matrix_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct MatrixNodeFrom : public EnvelopeSupport<Patch::MatrixNode>,
const MonoValues &monoValues;
const VoiceValues &voiceValues;
const float &level, &activeV, &pmrmV, &lfoToDepth, &mulLfoV;
MatrixNodeFrom(const Patch::MatrixNode &mn, OpSource &on, OpSource &fr, const MonoValues &mv,
MatrixNodeFrom(const Patch::MatrixNode &mn, OpSource &on, OpSource &fr, MonoValues &mv,
const VoiceValues &vv)
: monoValues(mv), voiceValues(vv), onto(on), from(fr), level(mn.level), pmrmV(mn.pmOrRM),
activeV(mn.active), EnvelopeSupport(mn, mv, vv), LFOSupport(mn, mv),
Expand Down Expand Up @@ -113,8 +113,7 @@ struct MatrixNodeSelf : EnvelopeSupport<Patch::SelfNode>, LFOSupport<Patch::Self
const VoiceValues &voiceValues;

const float &fbBase, &lfoToFB, &activeV, &lfoMulV;
MatrixNodeSelf(const Patch::SelfNode &sn, OpSource &on, const MonoValues &mv,
const VoiceValues &vv)
MatrixNodeSelf(const Patch::SelfNode &sn, OpSource &on, MonoValues &mv, const VoiceValues &vv)
: monoValues(mv), voiceValues(vv), sr(mv), onto(on), fbBase(sn.fbLevel),
lfoToFB(sn.lfoToFB), activeV(sn.active), lfoMulV(sn.envLfoSum),
EnvelopeSupport(sn, mv, vv), LFOSupport(sn, mv){};
Expand Down Expand Up @@ -170,7 +169,7 @@ struct MixerNode : EnvelopeSupport<Patch::MixerNode>, LFOSupport<Patch::MixerNod
const float &level, &activeF, &pan, &lfoToLevel, &lfoToPan, &lfoMulV;
bool active{false}, lfoMul{false};

MixerNode(const Patch::MixerNode &mn, OpSource &f, const MonoValues &mv, const VoiceValues &vv)
MixerNode(const Patch::MixerNode &mn, OpSource &f, MonoValues &mv, const VoiceValues &vv)
: monoValues(mv), voiceValues(vv), sr(mv), from(f), pan(mn.pan), level(mn.level),
activeF(mn.active), lfoToLevel(mn.lfoToLevel), lfoToPan(mn.lfoToPan),
EnvelopeSupport(mn, mv, vv), LFOSupport(mn, mv), lfoMulV(mn.envLfoSum)
Expand Down Expand Up @@ -249,7 +248,7 @@ struct OutputNode : EnvelopeSupport<Patch::OutputNode>
const float &defTrigV;
TriggerMode defaultTrigger;

OutputNode(const Patch::OutputNode &on, std::array<MixerNode, numOps> &f, const MonoValues &mv,
OutputNode(const Patch::OutputNode &on, std::array<MixerNode, numOps> &f, MonoValues &mv,
const VoiceValues &vv)
: monoValues(mv), voiceValues(vv), sr(mv), fromArr(f), level(on.level), bendUp(on.bendUp),
bendDown(on.bendDown), velSen(on.velSensitivity), EnvelopeSupport(on, mv, vv),
Expand Down
4 changes: 2 additions & 2 deletions src/dsp/node_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ template <typename T, bool needsSmoothing = true> struct LFOSupport
lfo_t lfo;
sst::basic_blocks::dsp::OnePoleLag<float, false> lag;

LFOSupport(const T &mn, const MonoValues &mv)
: sr(mv), paramBundle(mn), lfo(&sr), lfoRate(mn.lfoRate), lfoDeform(mn.lfoDeform),
LFOSupport(const T &mn, MonoValues &mv)
: sr(mv), paramBundle(mn), lfo(&sr, mv.rng), lfoRate(mn.lfoRate), lfoDeform(mn.lfoDeform),
lfoShape(mn.lfoShape), lfoActiveV(mn.lfoActive), tempoSyncV(mn.tempoSync), monoValues(mv)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/dsp/op_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct alignas(16) OpSource : public EnvelopeSupport<Patch::SourceNode>,
uint32_t phase;
uint32_t dPhase;

OpSource(const Patch::SourceNode &sn, const MonoValues &mv, const VoiceValues &vv)
OpSource(const Patch::SourceNode &sn, MonoValues &mv, const VoiceValues &vv)
: monoValues(mv), voiceValues(vv), EnvelopeSupport(sn, mv, vv), LFOSupport(sn, mv),
ModulationSupport(sn, mv, vv), ratio(sn.ratio), activeV(sn.active),
envToRatio(sn.envToRatio), lfoToRatio(sn.lfoToRatio), lfoByEnv(sn.envLfoSum),
Expand Down
3 changes: 3 additions & 0 deletions src/synth/mono_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <sst/basic-blocks/tables/EqualTuningProvider.h>
#include <sst/basic-blocks/tables/TwoToTheXProvider.h>
#include <sst/basic-blocks/dsp/RNG.h>

struct MTSClient;

Expand All @@ -39,6 +40,8 @@ struct MonoValues

sst::basic_blocks::tables::EqualTuningProvider tuningProvider;
sst::basic_blocks::tables::TwoToTheXProvider twoToTheX;

sst::basic_blocks::dsp::RNG rng;
};
}; // namespace baconpaul::six_sines
#endif // MONO_VALUES_H
2 changes: 1 addition & 1 deletion src/synth/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace baconpaul::six_sines

namespace scpu = sst::cpputils;

Voice::Voice(const Patch &p, const MonoValues &mv)
Voice::Voice(const Patch &p, MonoValues &mv)
: monoValues(mv), out(p.output, mixerNode, mv, voiceValues),
output{out.output[0], out.output[1]},
src(scpu::make_array_lambda<OpSource, numOps>(
Expand Down
2 changes: 1 addition & 1 deletion src/synth/voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct Voice
const MonoValues &monoValues;
VoiceValues voiceValues;

Voice(const Patch &, const MonoValues &);
Voice(const Patch &, MonoValues &);
~Voice() = default;

void attack();
Expand Down

0 comments on commit 9639910

Please sign in to comment.