magenta / magenta-js

Magenta.js: Music and Art Generation with Machine Learning in the browser
https://magenta.tensorflow.org
Apache License 2.0
1.96k stars 312 forks source link

Unable to use Tone.js OfflineAudioContext with Soundfont Player #686

Closed this-fifo closed 3 months ago

this-fifo commented 6 months ago

Hey Magenta Team!

I've recently encountered an issue where I'm trying to use the Tone.js library for offline audio rendering with Magenta's Soundfont player.

I am using Tone.js for sequencing and playing music, and specifically, I'm using the Tone.js OfflineAudioContext to render the audio offline for downloading the song.

The issue arises in that the Soundfont Player seems to use Tone.js's global context, which is a different instance than the OfflineAudioContext provided by Tone.Offline. This results in an error when trying to connect nodes from these two different AudioContexts.

Uncaught (in promise) DOMException: AudioNode.connect: Can't connect nodes from different AudioContexts

I'd appreciate any guidance or advice on what to do here, I feel like I hit a wall and I'm not sure if I'm approaching this the right way anymore.

this-fifo commented 3 months ago

Sharing my thoughts after a while in case anyone runs into this issue.

It looks like there are ways to support the use of OfflineAudioContext with sample based players as well as support things like looping which Magenta doesn't.

From my point of view, this project sadly feels abandoned and neglected (why?). I have moved on from it to using https://github.com/danigb/smplr which is a great replacement in case anyone is interested in a replacement to mm.SoundFontPlayer

Thanks!