diff --git a/main.cpp b/main.cpp index 6c644a5..c2ea2c0 100644 --- a/main.cpp +++ b/main.cpp @@ -909,11 +909,11 @@ void loadPreset(int preset) { auto placeOp = [&](int x, int y, float ratio, float att, float rel) { // Layout: // (x, y) : G-IN (South) - // (x, y+1) : WIRE (East) - // (x+1, y+1): ATT (East) + // (x, y+1) : WIRE (East) -> Feeds envelope chain + // (x+1, y+1): ATT (East) -> // (x+2, y+1): REL (East) - // (x+3, y+1): VCA (South) - // (x+3, y) : OSC (South) + // (x+3, y+1): VCA (South) -> Output is here. Gets audio from OSC, gain from envelope. + // (x+3, y) : OSC (South) -> Audio source. Gets FM from its back (x+3, y-1). engine.grid[x][y].type = SynthEngine::GridCell::GATE_INPUT; engine.grid[x][y].rotation = 2; // S engine.grid[x][y+1].type = SynthEngine::GridCell::WIRE; engine.grid[x][y+1].rotation = 1; // E @@ -932,8 +932,10 @@ void loadPreset(int preset) { }; int sinkY = SynthEngine::GRID_H - 1; + int sinkX = SynthEngine::GRID_W / 2; - if (preset == 1) { + // Preset 0 is blank + if (preset == 1) { // Based on DX7 Algorithm 32 // Algo 32: Parallel Operators // 6 Ops in parallel feeding the sink // We'll place 3, and wire them @@ -966,7 +968,7 @@ void loadPreset(int preset) { engine.grid[6][y].type = SynthEngine::GridCell::WIRE; engine.grid[6][y].rotation = 2; } - } else if (preset == 2) { + } else if (preset == 2) { // Based on DX7 Algorithm 1 // Algo 1: Stack (FM) // Op 2 Modulates Op 1 // Op 1 is Carrier @@ -989,6 +991,78 @@ void loadPreset(int preset) { for(int y=5; y Op 1 (Carrier) + // Op 3 (Carrier) + + // Carrier 1 stack (output at 7,3) + placeOp(4, 2, 1.0f, 0.01f, 0.8f); + placeOp(4, 0, 2.0f, 0.01f, 0.2f); + + // Carrier 2 (output at 3,1) + placeOp(0, 0, 1.0f, 0.01f, 0.5f); + + // --- Wiring to Sink --- + // Path for Carrier 1 (from 7,3) + engine.grid[7][4].type = SynthEngine::GridCell::WIRE; engine.grid[7][4].rotation = 3; // W, to (6,4) + + // Path for Carrier 2 (from 3,1) + engine.grid[3][2].type = SynthEngine::GridCell::WIRE; engine.grid[3][2].rotation = 1; // E, to (4,2) + engine.grid[4][2].type = SynthEngine::GridCell::WIRE; engine.grid[4][2].rotation = 1; // E, to (5,2) + engine.grid[5][2].type = SynthEngine::GridCell::WIRE; engine.grid[5][2].rotation = 1; // E, to (6,2) + engine.grid[sinkX][2].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][2].rotation = 2; // S, to (6,3) + engine.grid[sinkX][3].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][3].rotation = 2; // S, to (6,4) + + // Mix point at (6,4) - WIREs sum inputs automatically + engine.grid[sinkX][4].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][4].rotation = 2; // S + + // Funnel from mix point down to sink + for(int y=5; y Op 2 -> Op 1 (Carrier) + placeOp(4, 4, 1.0f, 0.01f, 0.8f); // Carrier Op1, out at (7,5) + placeOp(4, 2, 2.0f, 0.01f, 0.2f); // Modulator Op2, out at (7,3) + placeOp(4, 0, 4.0f, 0.01f, 0.1f); // Modulator Op3, out at (7,1) + + // Wire Carrier output to sink + engine.grid[7][6].type = SynthEngine::GridCell::WIRE; engine.grid[7][6].rotation = 3; // W + engine.grid[sinkX][6].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][6].rotation = 2; // S + + // Funnel down to sink + for(int y=7; y Op 3 -> Op 2 (Carrier) + // Op 1 (Carrier) + + // Carrier stack (output at 7,5) + placeOp(4, 4, 1.0f, 0.01f, 0.8f); + placeOp(4, 2, 2.0f, 0.01f, 0.2f); + placeOp(4, 0, 4.0f, 0.01f, 0.1f); + + // Parallel carrier (output at 3,1) + placeOp(0, 0, 0.5f, 0.01f, 0.5f); + + // --- Wiring to Sink --- + engine.grid[7][6].type = SynthEngine::GridCell::WIRE; engine.grid[7][6].rotation = 3; // W, to (6,6) + engine.grid[3][2].type = SynthEngine::GridCell::WIRE; engine.grid[3][2].rotation = 2; // S to (3,3) + engine.grid[3][3].type = SynthEngine::GridCell::WIRE; engine.grid[3][3].rotation = 1; // E to (4,3) + engine.grid[4][3].type = SynthEngine::GridCell::WIRE; engine.grid[4][3].rotation = 1; // E to (5,3) + engine.grid[5][3].type = SynthEngine::GridCell::WIRE; engine.grid[5][3].rotation = 1; // E to (6,3) + engine.grid[sinkX][3].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][3].rotation = 2; // S to (6,4) + engine.grid[sinkX][4].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][4].rotation = 2; // S to (6,5) + engine.grid[sinkX][5].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][5].rotation = 2; // S to (6,6) + + // Mix point at (6,6) + engine.grid[sinkX][6].type = SynthEngine::GridCell::WIRE; engine.grid[sinkX][6].rotation = 2; // S + + // Funnel from mix point down to sink + for(int y=7; y