Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OfflineAudioContext this for Tone.JS "offline" (no audio)? #88

Open
anselanza opened this issue Jul 7, 2022 · 1 comment
Open

OfflineAudioContext this for Tone.JS "offline" (no audio)? #88

anselanza opened this issue Jul 7, 2022 · 1 comment

Comments

@anselanza
Copy link

I am writing a NodeJS application which needs to use ToneJS Sequence, Transport and basic MIDI (frequency to MIDI note) utilities. I do not need to record, load or output audio.

However, ToneJS expects to use AudioBuffer and so far it seems difficult to keep anything separate.

I got a little further by installingweb-audio-api and then setting ToneJS to use the audio context provided instead of the Native (browser) one:

const context = new AudioContext();
Tone.setContext(context);

This throws no errors. Next, I tried to use ToneJS in its Offline mode, something like:

 Tone.Offline(() => {
      const sequence = new Tone.Sequence((time, value) => {
        logger.debug({ time, value });
      }, events);
    }, 30);

Next error from ToneJS I get is

Error: Missing the native OfflineAudioContext constructor.

Does web-audio-api provide the offlineAudioContext somewhere?

@chrisguttandin
Copy link
Collaborator

Hi @anselanza, I think the problem is that Tone.js only has a method to set the realtime AudioContext. It will not influence the OfflineAudioContext.

Maybe it's better to turn this into a feature request for Tone.js asking for a method to control the OfflineAudioContext used by Tone.Offline().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants