feat(modulation): add envelopes, LFOs and modulation matrix

This commit is contained in:
2026-09-08 14:55:21 +02:00
parent fc9d16b302
commit 44960b9acb
6 changed files with 458 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
#pragma once
#include <JuceHeader.h>
#include "Params.h"
namespace serum
{
// ===========================================================================
// A single modulation connection: source -> target with a static depth and a
// bipolar flag. One level of modulation only (no modulation of modulation).
// ===========================================================================
struct ModConnection
{
ModSource source = ModSource::Lfo1;
ModTarget target = ModTarget::None;
float depth = 0.0f;
bool bipolar = false;
};
// ===========================================================================
// Ordered collection of modulation connections. Serialisable to/from a
// juce::ValueTree so that connections survive preset save/load.
// ===========================================================================
class ModulationMatrix
{
public:
static constexpr int kMaxConnections = 32;
std::vector<ModConnection> connections;
bool addConnection (ModSource source, ModTarget target, float depth, bool bipolar);
void removeConnection (int index);
void removeAllWithTarget (ModTarget target);
void clear() { connections.clear(); }
int size() const noexcept { return (int) connections.size(); }
juce::ValueTree toValueTree() const;
void fromValueTree (const juce::ValueTree& tree);
};
} // namespace serum