A Julia spike for the SuperInstance Flux algebra system, demonstrating why Julia's multiple dispatch is a natural fit for encoding musical traditions as first-class algebraic types.
Musical traditions aren't just different data — they're different algebras. Jazz uses 12-tone equal temperament with chord-scale theory. Gamelan uses pelog and slendro tuning with cyclic time. Hindustani music uses just intonation raga with a tala framework. Each tradition has its own:
- Ring structure (pitch arithmetic)
- Field operations (tuning systems)
- Group actions (voice leading, PLR transformations)
- Geometric spaces (dial positions, voice-leading lattices)
Julia's multiple dispatch lets us encode each tradition as a type and write tradition-specific methods that the compiler resolves to native code — zero runtime overhead, zero vtable indirection, zero trait boilerplate.
| Feature | Musical Analogue | File |
|---|---|---|
| Multiple dispatch | Tradition-specific behavior | src/dispatch.jl |
| Parametric types | Tuning-system-generic pitch | src/rings.jl, src/fields.jl |
| Metaprogramming | Conservation law enforcement | src/conservation.jl |
| Distributed computing | Fleet-wide tradition analysis | src/distributed.jl |
| Abstract type hierarchy | Tradition taxonomy | src/dispatch.jl |
| SIMD/vectorization | Batch pitch operations | src/combinatorics.jl |
| Module system | Algebraic layering | src/FluxAlgebra.jl |
FluxAlgebra.jl
├── rings.jl — HarmonicRing, IntervalRing, ChordIdeal
├── fields.jl — TuningField, AlgebraicTone, ET12, Just, Meantone
├── groups.jl — PLRGroup, TranspositionInversion, PermutationVoiceLeading
├── geometry.jl — DialPoint, TraditionRegion, VoiceLeadingGeodesic
├── tropical.jl — TropicalHarmony, tropical semiring operations
├── combinatorics.jl — Voice leading computation and optimization
├── dispatch.jl — Tradition-specific methods via multiple dispatch
├── conservation.jl — Conservation law as type constraint / macro
├── distributed.jl — Fleet-wide distributed analysis
└── oscar_bridge.jl — Bridge to Oscar.jl algebraic types
# In Julia REPL
] add https://github.com/SuperInstance/flux-juliaOr clone and develop:
git clone https://github.com/SuperInstance/flux-julia
cd flux-julia
julia --project# In Julia REPL
] instantiateusing FluxAlgebra
# Multiple dispatch picks the right tension function automatically
jazz_seq = [60, 64, 67, 70] # Cmaj7
gamelan_seq = [0, 1, 5, 7]
t1 = tension(jazz_seq, Jazz()) # Blues-based tension
t2 = tension(gamelan_seq, Gamelan()) # Pelog/slendro tension
# Parametric pitch — tuning system is part of the type
p1 = Pitch{ET12}(60, 261.63)
p2 = Pitch{ET12}(64, 329.63)
interval(p1, p2) # => 4 semitones
p3 = Pitch{Just}(60, 261.63)
p4 = Pitch{Just}(64, 327.03)
interval(p3, p4) # => 5//4 (just major third)
# Conservation law — enforced at macro expansion
@conserved analyze_progression([60, 64, 67], Jazz())Both Julia and Rust compile to LLVM IR. This means:
- Shared optimization passes — SIMD, loop unrolling, inlining
- FFI at zero cost — Julia's
@ccallcan call Rust functions compiled ascdylib - Shared numerics — Both use LLVM's
fptoui,fptosi, vector ops
# Call a Rust function from Julia
function rust_voice_leading(a::Vector{Int}, b::Vector{Int})
@ccall libflux_voice_leading.voice_leading_distance(
a::Ptr{Cint}, b::Ptr{Cint}, length(a)::Csize_t
)::Cdouble
endusing PythonCall
# Use the Python flux-algebra from Julia
py_flux = pyimport("flux_algebra")
result = py_flux.tension([60, 64, 67]) # Python objects auto-convertedOr go the other direction — call Julia from Python via juliacall:
from juliacall import Main as jl
jl.seval("using FluxAlgebra")
result = jl.tension([60, 64, 67], jl.Jazz())See the examples/ directory:
plr_walk.jl— Neo-Riemannian chord progression walkconservation_check.jl— Verify conservation across traditionstradition_classification.jl— Classify traditions by dial positiondistributed_analysis.jl— Fleet-wide distributed analysis
julia --project -e 'using Pkg; Pkg.test()'MIT