Towards Real-Time Human-AI Musical Co-Performance: Accompaniment Generation with Latent Diffusion Models and MAX/MSP
Organizations: University of California San Diego
Abstract
We present a framework for real-time human-AI musical co-performance, in which a latent diffusion model generates instrumental accompaniment in response to a live stream of context audio. The system combines a MAX/MSP front-end-handling real-time audio input, buffering, and playback-with a Python inference server running the generative model, communicating via OSC/UDP messages. This allows musicians to perform in MAX/MSP - a well-established, real-time capable environment - while interacting with a large-scale Python-based generative model, overcoming the fundamental disconnect between real-time music tools and state-of-the-art AI models. We formulate accompaniment generation as a sliding-window look-ahead protocol, training the model to predict future audio from partial context, where system latency is a critical constraint. To reduce latency, we apply consistency distillation to our diffusion model, achieving a 5.4x reduction in sampling time, with both models achieving real-time operation. Evaluated on musical coherence, beat alignment, and audio quality, both models achieve strong performance in the Retrospective regime and degrade gracefully as look-ahead increases. These results demonstrate the feasibility of diffusion-based real-time accompaniment and expose the fundamental trade-off between model latency, look-ahead depth, and generation quality that any such system must navigate.
Figures & tables
| Config (1) | Config (2) | Config (3) | Config (4) | |||||
| Client | Win 10, SD | Win 10, SD | Mac M2, local | Win 10, SD | ||||
| Server | Win 10, RTX 2070, local | Linux, RTX A6000, Paris | Mac M2, MPS, local | Mac M2, MPS, SD, remote | ||||
| Model | Diff. | CD | Diff. | CD | Diff. | CD | Diff. | CD |
| MAX/MSP server | 17 | 17 | 188 | 188 | 20 | 20 | 107 | 107 |
| CAE encode | 40 | 40 | 52 | 52 | 55 | 55 | 55 | 56 |
| Sampling ( fwd. passes) | 1175 (10) | 130 (2) | 480 (10) | 88 (2) | 1072 (10) | 146 (2) | 1072 (10) | 146 (2) |
| Model | MAX server | enc. sample | dec. | server MAX | Total | RT | ||
|---|---|---|---|---|---|---|---|---|
| Diff. | 0.250 | 1500 | 188 | 532 | 72 | 189 | 981 | |
| 0.125 | 750 | 145 | 532 | 67 | 145 | 889 | ||
| 0.0625 | 375 | 145 | 532 | 64 | 145 | 886 | ||
| 94 | 145 | 532 | 64 | 145 | 886 | |||
| CD | 0.250 | 1500 | 188 | 140 | 72 | 189 | 589 | |
| 0.125 | 750 | 145 | 140 | 67 | 145 | 497 |