← @bgSponge

Petri Nets as a Music Sequencer

Summary

stackdump builds a music sequencer using Petri nets where every note, rhythm, and song structure is represented by tokens moving through places and transitions.

  1. Rhythms emerge from net topology.

    Token rings create Euclidean rhythms; varying ring lengths produces polyrhythms like those found in West African music without manual synchronization.

    Make the rings different lengths and they drift in and out of sync, giving you polyrhythm for free.

  2. Control nets manage song structure.

    Non-auditory rings act as stage directors, firing commands to mute or introduce instruments during transitions.

    rings that don't make sound but fire commands like "mute the hihat" or "bring in the bass."

  3. Countdown timers optimize file size.

    Replacing long chains of single-step circles with single circles containing many tokens reduced file size from 22 MB to 242 KB.

    Instead of 384 empty steps before a section change, we put 384 tokens in a single circle

  4. Transitions become part of the graph.

    Injecting Auto-DJ transitions as one-transition control nets prevents race conditions and ensures tick-synchronization via the executor.

    Each Auto-DJ transition is now injected as a one-transition control net

  5. Token state ensures determinism.

    Because the token state is the only state, the same seed produces identical nets and notes on any machine without drift.

    the same seed produces the same nets and the same notes on any machine

Read the original ↗Save to your Sponge

Summarized with Sponge. Quotes are the author’s own words.

More from @bg

All readings →