Grid synth engine
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define SYNTH_ENGINE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <mutex>
|
||||
|
||||
/**
|
||||
* @class SynthEngine
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
* @brief Constructs the synthesizer engine.
|
||||
* @param sampleRate The audio sample rate in Hz (e.g., 44100).
|
||||
*/
|
||||
~SynthEngine();
|
||||
SynthEngine(uint32_t sampleRate);
|
||||
|
||||
/**
|
||||
@@ -82,6 +84,27 @@ public:
|
||||
*/
|
||||
void setFilter(float lpCutoff, float hpCutoff);
|
||||
|
||||
// --- Grid Synth ---
|
||||
struct GridCell {
|
||||
enum Type { EMPTY, FIXED_OSCILLATOR, INPUT_OSCILLATOR, NOISE, FORK, WIRE, OPERATOR, DELAY, SINK };
|
||||
enum Op { OP_ADD, OP_MUL, OP_SUB, OP_DIV, OP_MIN, OP_MAX };
|
||||
|
||||
Type type = EMPTY;
|
||||
float param = 0.5f; // 0.0 to 1.0
|
||||
int rotation = 0; // 0:N, 1:E, 2:S, 3:W (Output direction)
|
||||
float value = 0.0f; // Current output sample
|
||||
float phase = 0.0f; // For Oscillator, Noise state
|
||||
float* buffer = nullptr; // For Delay
|
||||
uint32_t buffer_size = 0; // For Delay
|
||||
uint32_t write_idx = 0; // For Delay
|
||||
};
|
||||
|
||||
GridCell grid[5][8];
|
||||
std::mutex gridMutex;
|
||||
|
||||
// Helper to process one sample step of the grid
|
||||
float processGridStep();
|
||||
|
||||
private:
|
||||
uint32_t _sampleRate;
|
||||
uint32_t _phase; // Phase accumulator for the oscillator.
|
||||
|
||||
Reference in New Issue
Block a user