Stereo2Spatial: Convert Stereo Music Tracks to Spatialized Binaural Mixes [P]
I have released a model that I have been working on for ~6 months off and on. I've been enjoying listening to spatial music, but there is a lot of music out there with no real quality spatial mix. So I decided to make a model to convert stereo to spatial.
I started by making a flow-matching diffusion model that operated in the latent space of a separately trained VAE (EAR-VAE). I used the VAE to encode the stereo input in to 1 latent and then separately on each channel of the 7.1.4 output. This design is similar to a paper I found about another stereo -> spatial project (ImmersiveFlow (they have code links in the paper but they 404 for me so I made the codebase from scratch)). One key addition I made over the ImmersiveFlow paper was a way for the model to carry state (memory tokens) across windows to enable stable long context generations.
Since the VAE was out of distribution with the output (was trained to encode\decode stereo tracks directly, not individual channels and certainly not individual channels of a 7.1.4 mix), the results hit real quality bottlenecks. But it showed that the mapping was possible. Rather than stick to modeling in latent space, I decided to pivot to modeling raw waveforms. This ended up fixing all of the quality issues I was seeing with the latent version, but at the cost of more training compute and instability.
The waveform version of the model would train to around 60K-80K steps with loss going down like normal, validation generations looking good\improving, and then it would quickly become unstable and the loss would shoot up. I tried direct waveforms, scaling the waveforms by a multiplier, aggressive grad clipping, lower learning rates, and all of those experiments failed the same way. Luckily, I came across a recent paper called WavFlow. The authors of this project also had issues with modeling raw waveforms with flow-matching diffusion, and they solved it by using amplitude lifting (scale each audio track to an rms of 0.33 then multiply by 3) (the WavFlow paper used a clip of 1.0 before the scale which leads to a model space of -3 - 3, but I used a clip of 4.0 which leads to a model space of -12 - 12 (from my testing this led to better binaural outputs)). Once I implemented amplitude lifting like the paper, the training stability issues vanished.
The waveform model was trained on 7,669 tracks for ~20 days on 2x A6000 gpus
- 10 days stage one, effective batch of 16, 10- 18- 26- and 34-second training sequences
- 10 days stage two, effective batch of 16, 122-second training sequences
- There is optional mix-style conditioning for controllable outputs (waveform version only)
- Direct binaural output (waveform training is more compute expensive than latent training so binaural proves the idea\theory and the same codebase and data can be used in the future to train a 7.1.4 version (once I have access to the compute))
I also made a Windows desktop app for inferencing with the model and consuming the results.
Everything has been released apache 2.0.
Huggingface link for waveform model: https://huggingface.co/francislabounty/stereo2spatial-v2-binaural
Huggingface link for latent model: https://huggingface.co/francislabounty/stereo2spatial-v1
Github repo for training\inferencing: https://github.com/francislabountyjr/stereo2spatial
Github repo for the Windows app: https://github.com/francislabountyjr/stereo2spatial-app
App Homepage: https://stereo2spatial.francislabounty.com
Case study for the waveform model: https://francislabounty.com/blog/stereo2spatial-v2
Case study for the latent model: https://francislabounty.com/blog/stereo2spatial
Playlist of generations made from the model (will be updated with more tracks over time): https://www.youtube.com/playlist?list=PLQ-HHjPijrAg
If you have any questions\etc. leave a comment and I will do my best to get them answered!
Disclaimer: I know AI written posts are generally frowned upon so this post was 100% written by me (mistakes and all). But the case studies and READMEs from the above links were made with AI assistance.
[link] [comments]
Want to read more?
Check out the full article on the original site