Aman Desai
← Projects

Fluid Music Transitions

Python · TensorFlow · PyGame

title: "Fluid Music Transitions" date: "2023-11-01" description: "ML-driven note prediction and rhythmic transitions in a small game environment." tech: ["Python", "TensorFlow", "PyGame"] status: "archived" links:

  • label: "GitHub" href: "https://github.com/amanpdesai"

Motivation

Most procedural music in games sounds procedural — transitions between states snap rather than flow. The goal here was to learn a smooth interpolation between musical states from data rather than hand-authoring every crossfade.

Approach

A small sequence model predicts the next note given the previous window, conditioned on a "state" embedding. Transitions are produced by interpolating the state embedding and re-running the predictor across the interpolation path. Rendered through PyGame so the latency-vs-quality tradeoff is visible during play.

  • Note tokens with a learned state-conditioning vector
  • Linear interpolation in state space, sampled greedily at each step
  • Audio output through a simple in-engine synth

Results

Transitions feel less abrupt than the obvious crossfade baseline. Was also a useful exercise in how much architectural choice is dwarfed by the dataset you train on.

What's next

  • Replace the linear path in state space with a learned trajectory (e.g. flow matching)
  • Compare against frozen-pretrained music models conditioned at sample time

References

  • Magenta's earlier work on RNN-based music generation, as a prior baseline