DX7 capability

This commit is contained in:
Dejvino
2026-02-28 19:41:35 +01:00
parent 7ff85048df
commit 0cecb05044
3 changed files with 207 additions and 55 deletions
+11 -11
View File
@@ -33,7 +33,7 @@ SynthEngine::SynthEngine(uint32_t sampleRate)
setFrequency(440.0f);
// Initialize SINK
grid[2][3].type = GridCell::SINK;
grid[GRID_W / 2][GRID_H - 1].type = GridCell::SINK;
}
SynthEngine::~SynthEngine() {
@@ -82,14 +82,14 @@ float SynthEngine::_random() {
float SynthEngine::processGridStep() {
// Double buffer for values to handle feedback loops gracefully (1-sample delay)
float next_values[5][8];
float next_values[GRID_W][GRID_H];
auto isConnected = [&](int tx, int ty, int from_x, int from_y) -> bool {
if (from_x < 0 || from_x >= 5 || from_y < 0 || from_y >= 8) return false;
if (from_x < 0 || from_x >= GRID_W || from_y < 0 || from_y >= GRID_H) return false;
GridCell& n = grid[from_x][from_y];
bool connects = false;
if (n.type == GridCell::WIRE || n.type == GridCell::FIXED_OSCILLATOR || n.type == GridCell::INPUT_OSCILLATOR || n.type == GridCell::WAVETABLE || n.type == GridCell::NOISE || n.type == GridCell::LFO || n.type == GridCell::GATE || n.type == GridCell::GATE_INPUT || n.type == GridCell::ADSR_ATTACK || n.type == GridCell::ADSR_DECAY || n.type == GridCell::ADSR_SUSTAIN || n.type == GridCell::ADSR_RELEASE || n.type == GridCell::LPF || n.type == GridCell::HPF || n.type == GridCell::VCA || n.type == GridCell::BITCRUSHER || n.type == GridCell::DISTORTION || n.type == GridCell::RECTIFIER || n.type == GridCell::PITCH_SHIFTER || n.type == GridCell::GLITCH || n.type == GridCell::OPERATOR || n.type == GridCell::DELAY || n.type == GridCell::REVERB) {
if (n.type == GridCell::WIRE || n.type == GridCell::FIXED_OSCILLATOR || n.type == GridCell::INPUT_OSCILLATOR || n.type == GridCell::WAVETABLE || n.type == GridCell::NOISE || n.type == GridCell::LFO || n.type == GridCell::GATE_INPUT || n.type == GridCell::ADSR_ATTACK || n.type == GridCell::ADSR_DECAY || n.type == GridCell::ADSR_SUSTAIN || n.type == GridCell::ADSR_RELEASE || n.type == GridCell::LPF || n.type == GridCell::HPF || n.type == GridCell::VCA || n.type == GridCell::BITCRUSHER || n.type == GridCell::DISTORTION || n.type == GridCell::RECTIFIER || n.type == GridCell::PITCH_SHIFTER || n.type == GridCell::GLITCH || n.type == GridCell::OPERATOR || n.type == GridCell::DELAY || n.type == GridCell::REVERB) {
// Check rotation
// 0:N (y-1), 1:E (x+1), 2:S (y+1), 3:W (x-1)
if (n.rotation == 0 && from_y - 1 == ty && from_x == tx) connects = true;
@@ -171,8 +171,8 @@ float SynthEngine::processGridStep() {
return hasSide ? gain : 1.0f;
};
for (int x = 0; x < 5; ++x) {
for (int y = 0; y < 8; ++y) {
for (int x = 0; x < GRID_W; ++x) {
for (int y = 0; y < GRID_H; ++y) {
GridCell& c = grid[x][y];
float val = 0.0f;
@@ -279,7 +279,7 @@ float SynthEngine::processGridStep() {
} else if (c.type == GridCell::FORK) {
// Sum inputs from "Back" (Input direction)
val = getInputFromTheBack(x, y, c);
} else if (c.type == GridCell::GATE || c.type == GridCell::GATE_INPUT) {
} else if (c.type == GridCell::GATE_INPUT) {
// Outputs 1.0 when gate is open (key pressed), 0.0 otherwise
val = _isGateOpen ? 1.0f : 0.0f;
} else if (c.type == GridCell::ADSR_ATTACK) {
@@ -311,7 +311,7 @@ float SynthEngine::processGridStep() {
} else if (c.type == GridCell::WIRE) {
// Sum inputs from all neighbors that point to me
float sum = getSummedInput(x, y, c);
val = sum * c.param; // Fading
val = sum;
} else if (c.type == GridCell::LPF) {
// Input from Back
float in = getInputFromTheBack(x, y, c);
@@ -514,13 +514,13 @@ float SynthEngine::processGridStep() {
}
// Update state
for(int x=0; x<5; ++x) {
for(int y=0; y<8; ++y) {
for(int x=0; x < GRID_W; ++x) {
for(int y=0; y < GRID_H; ++y) {
grid[x][y].value = next_values[x][y];
}
}
return grid[2][3].value;
return grid[GRID_W / 2][GRID_H - 1].value;
}
void SynthEngine::process(int16_t* buffer, uint32_t numFrames) {