feat(modulation): add envelopes, LFOs and modulation matrix
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user