Thank you for your interest in tropical geometry for sound design!
git clone https://github.com/SuperInstance/tropical-synth.git
cd tropical-synth
cargo testThe max-plus semiring has deep connections to:
- Piecewise-linear functions β tropical polynomials are convex PL functions
- ReLU neural networks β a tropical polynomial = a single ReLU layer
- Optimal control β tropical algebra models shortest paths
- Algebraic geometry β tropical varieties approximate classical varieties
For synthesis, the key property is that tropical polynomials produce piecewise-linear functions with sharp corners β exactly the kind of parameter curves that produce interesting timbral changes.
Each monomial of a tropical polynomial corresponds to a vertex of the Newton polytope. The vertex's exponent vector encodes which coordinate directions dominate, and the coefficient shifts the evaluation. This naturally maps to:
- Exponent β waveform selection (which harmonic content dominates)
- Coefficient β filter cutoff (how much energy passes through)
- Dimension β envelope shape (temporal evolution)
Tropical line segments in max-plus algebra are piecewise-linear in standard arithmetic. This means morphing between patches is simply lerp(a, b, t) = a + t*(b - a) for each parameter. This produces smooth, predictable transitions β no sudden jumps.
- Add the variant to
OscillatorWaveforminpatch.rs - Update
SynthPatch::from_vertex()to map to the new waveform - Update
OscillatorParams::default()if needed - Write tests
- Add the variant to
EffectKindinpatch.rs - Update the MIDI mapper in
midi.rsto map it to a CC number - Write tests
The semiring currently supports + (max), * (add), and pow (scalar multiply). For more advanced operations:
- Tropical matrix multiplication β for multi-layer tropical networks
- Tropical eigenvalues β for fixed-point analysis of timbre spaces
- Tropical discriminants β for detecting vertex mergers
cargo test # All tests
cargo test test_semiring # Semiring axiom tests
cargo test test_polynomial # Polynomial evaluation tests
cargo test test_patch # Patch generation tests
cargo test test_morph # Morphing tests
cargo test test_midi # MIDI mapping testsKey invariants to test:
- Semiring axioms: associativity, commutativity, distributivity, identities
- Evaluation correctness: verify against hand-computed values
- Active monomial consistency: the active monomial's value should equal the polynomial's value
- Morph endpoints: morph at t=0 should equal
from, t=1 should equalto - MIDI range: all CC values should be 0β127
cargo fmtβ no debatecargo clippyβ warnings are errors in CI- Doc comments on all
pubitems - Builder pattern where appropriate
Follow Conventional Commits:
feat:new featuresfix:bug fixesdocs:documentation changes
By contributing, you agree that your contributions will be licensed under the MIT License.