jet2jet / js-synthesizer

Synthesizer library for web-based JS program, using with Web Audio or etc.
BSD 3-Clause "New" or "Revised" License
58 stars 8 forks source link

Number of opened output audio streams error #26

Closed cwiggins999 closed 1 year ago

cwiggins999 commented 1 year ago

We ran across this error in our app, apparently coming from WebAudio. I've worked around it in one place by just creating one JSSynthesizer and sharing it in a preview mode. But there's a potential that we could run into it elsewhere where sharing that resource isn't practical.

[42662:0925/173643.875148:ERROR:audio_manager_base.cc(195)] Number of opened output audio streams 50 exceed the max allowed number 50

Any advice on this issue? We're not using the worklet mode of JSSynthesizer, and here's my code for creating the synth instance: function createMIDISynth() { console.log("Creating JS Synth for MIDI object"); let context = new AudioContext(); synth = new JSSynth.Synthesizer(); synth.init(context.sampleRate); let node = synth.createAudioNode(context, 8192); // 8192 is the frame count of buffer synth.setReverbOn(true); synth.setReverbDamp(0.9); synth.setReverbLevel(0.9); synth.setReverbRoomsize(0.8); synth.setReverbWidth(98); node.connect(context.destination); synth.loadSFont(synthSoundFont).then(result => console.log("soundfont loaded")); return synth; }

jet2jet commented 1 year ago

I did not know this error message, but according to the following thread, AudioContext should be created only once.
https://stackoverflow.com/questions/65689984/chrome-produces-no-audio-after-reaching-50-audio-output-streams
(JSSynth.Synthesizer can be created more than once, but when it is no longer necessary, close() should be called.)

cwiggins999 commented 1 year ago

Thanks! I created a single AudioContext to reference, and all is working well.