Neural Synthesis with Gen~

Introduction

Here is a meander using Gemini to propose Neural Synthesis using MAX MSP Gen~

Initial Prompt

Using dr dobbs article about david tudor neural synthesizer project using the intel Etann chip, suggest modern implementation that could run on apple silicon macos

Response

Here is a modern, ultra-fast implementation of a neural synthesizer node based on the ETANN chip architecture, built specifically for the Max/MSP gen~ environment.

Core Concepts translated to gen~

  • Analog Simulation: It uses a tanh function for smooth, analog-style saturation.
  • Zero-Latency Matrix: Every weight is processed per-sample.
  • Feedback Loops: Outputs connect directly back to inputs for chaotic, Tudor-style self-generation.

The gen~ Code

Paste this code inside a gen~ object. It creates a $3 \times 3$ fully interconnected neural network matrix.

// Inputs: In1, In2, In3 (External Audio/Control)
// Outputs: Out1, Out2, Out3 (Neural Oscillations)

// 1. History operators for single-sample feedback loops
History n1(0);
History n2(0);
History n3(0);

// 2. Programmable Weights (ETANN Simulation)
// Range: -2.0 to 2.0. Connect Max flonums to these params.
Param w11(0.5), w12(-0.8), w13(0.3); // Node 1 weights
Param w21(0.9), w22(0.1),  w23(-0.6); // Node 2 weights
Param w31(-0.4), w32(0.7), w33(0.2);  // Node 3 weights

// Input Gains
Param in_gain(1.0);

// 3. Matrix Multiplication & Summation
// Sum external inputs and previous states multiplied by weights
Data1 = (in1 * in_gain) + (n1 * w11) + (n2 * w12) + (n3 * w13);
Data2 = (in2 * in_gain) + (n1 * w21) + (n2 * w22) + (n3 * w23);
Data3 = (in3 * in_gain) + (n1 * w31) + (n2 * w32) + (n3 * w33);

// 4. Non-Linear Activation Function (Sigmoid/Tanh)
// Simulates the ETANN analog differential amplifier saturation
Out1 = tanh(Data1);
Out2 = tanh(Data2);
Out3 = tanh(Data3);

// 5. Update History for the next sample
n1 = Out1;
n2 = Out2;
n3 = Out3;

// 6. Route to Max MSP DSP chain
out1 = Out1;
out2 = Out2;
out3 = Out3;

Key Implementation Details

          [ External Audio Inputs ]
                     │
                     ▼
  ┌─────────────────────────────────────┐
  │  Matrix Multiplication (w11..w33)  ◄───┐
  └──────────────────┬──────────────────┘   │
                     │                      │
                     ▼                      │ Single-Sample
         ┌───────────────────────┐          │ Feedback Loop
         │ Tanh Saturation Stage │          │ (History)
         └───────────┬───────────┘          │
                     │                      │
                     ├──[ External Out ]    │
                     │                      │
                     └──────────────────────┴───┘
  • No Buffer Delays: Using History in gen~ ensures a feedback loop delay of exactly 1 sample.
  • Chaotic Behavior: To make it self-oscillate like David Tudor’s rig, set external inputs to 0, increase the parameter weights, and cross-modulate the nodes.

To help expand this system, let me know:

  • Do you want to add biases (offsets) to the nodes?
  • Should we implement genetic algorithm controls to automatically find stable patches?
  • Do you need a larger matrix layout (e.g., $8 \times 8$ or $16 \times 16$)?

Code

// Inputs: In1, In2, In3 (External Audio/Control)
// Outputs: Out1, Out2, Out3 (Neural Oscillations)

// 1. History operators for single-sample feedback loops
History n1(0);
History n2(0);
History n3(0);

// 2. Programmable Weights (ETANN Simulation)
// Range: -2.0 to 2.0. Connect Max flonums to these params.
Param w11(0.5), w12(-0.8), w13(0.3); // Node 1 weights
Param w21(0.9), w22(0.1),  w23(-0.6); // Node 2 weights
Param w31(-0.4), w32(0.7), w33(0.2);  // Node 3 weights

// Input Gains
Param in_gain(1.0);

// 3. Matrix Multiplication & Summation
// Sum external inputs and previous states multiplied by weights
Data1 = (in1 * in_gain) + (n1 * w11) + (n2 * w12) + (n3 * w13);
Data2 = (in2 * in_gain) + (n1 * w21) + (n2 * w22) + (n3 * w23);
Data3 = (in3 * in_gain) + (n1 * w31) + (n2 * w32) + (n3 * w33);

// 4. Non-Linear Activation Function (Sigmoid/Tanh)
// Simulates the ETANN analog differential amplifier saturation
Out1 = tanh(Data1);
Out2 = tanh(Data2);
Out3 = tanh(Data3);

// 5. Update History for the next sample
n1 = Out1;
n2 = Out2;
n3 = Out3;

// 6. Route to Max MSP DSP chain
out1 = Out1;
out2 = Out2;
out3 = Out3;