Petri Nets: The 60-Year-Old Idea That Generates Infinite Music

Petri Nets as a Music Sequencer

Petri Nets: The 60-Year-Old Idea That Generates Infinite Music

beats.bitwrap.io generates full tracks—drums, bass, melody—using only Petri nets and random seeds. Each note is a token moving through a graph, with rings for instruments and control nets for song structure. The system supports 19 genres, polyrhythms, and deterministic replay, all in ~400 lines of vanilla JS. A 22 MB project file shrank to 242 KB using countdown timers, and Auto-DJ transitions are now just more net.

The token state is the only state, so the same seed produces the same track on any machine—no hidden counters, no drift.
  1. Slow_Hand

    I see so many people try to reinvent sequencing as a circular diagram, as opposed to (say) a piano roll that loops, and I see little to no advantage to it. It's a cool novelty, but not the type of thing you'd like to work on.

    Horizontal (left-to-right) sequencer displays like a piano roll or step sequencer are far more compact to display and easier to read. For drums parts, it's one dimensional until you add a second layer, and then the parts stack vertically, nicely on top of each other.

    It's all to say that I don't really see much advantage in this petri nets paradigm. Even the trigger conditions and probabilities have already been incorporated into a large number of DAWs and hardware sequencers. This feels a little like someone who has discovered fire independently from the rest of civilization, but in this day and age I don't think that counts for much when all they had to do was observe the design paradigms that already exist.

    In the end, the proof is in the pudding: How good is the music made with the tool? Does the technique allow us to more easily do something that was previously difficult or tedious? In this case, I'm not yet seeing it.

  2. tleb_

    So this is about visualisation more than different behaviour? There are still N static notes with a cursor moving from start to end, looping over. It's not clear from the blog. Still, I always enjoy experiments in that domain, thanks

  3. jarth9

    Compared to other ways of writing down musical rhythm, I've found this to be a very nice balance of simplicity and expressiveness. Standard notation and drum sequencers have a lot of ambiguity (at least to my non-expert ear) when it comes to swing, microtiming, groove, and the other little things that we think of that make a rhythm attractive. Godfried T. Toussaint has given this idea a full academic exploration. He calls these Petri nets "necklaces", a term borrowed from combinatorics.

More from this day

2026-08-07