Closed meszaros-lajos-gyorgy closed 3 years ago
One possible solution is to pre-create N oscillator and gain nodes, wire them up and keep an internal counter, that goes through all the nodes one after another as you press notes. The counter would loop over and start from the first node and skip all notes, which are currently being played. Similarly to synthesizers with fixed number of voices, there would be a limit on how many sounds you can press simultaniously and subsequent notes could either be ignored, or played by force-releasing pressed notes in various order.
Delay also looks cool, as seen in this screenshot
Ok! Think I have enough info to try fixing this. Good investigation!
Fix is now in the develop branch!
When the synth is initialised it will start a limited number of oscillators which are then reused. It's a round-robin style voice allocation which tries to avoid voice stealing. Max polyphony will be 6 by default (less taxing on low powered systems) but users can increase the max polyphony in a setting which will be automatically saved/recalled in browser localStorage.
It's been a long time coming...
Fixed in 1.4.1
Found a nice debug tool for chrome to inspect web audio nodes: https://chrome.google.com/webstore/detail/web-audio-inspector/cmhomipkklckpomafalojobppmmidlgl
This tool shows that Scale Workshop is not re-using oscillator and gain nodes after playing a single note with it and since web audio doesn't do any garbage collection it can pile up and possibly cause all the audio stopping issues that have been reported here.
Please keep in mind, that on the screenshots these notes are pressed and released immediately, yet their nodes won't get cleaned up.
In the screenshots I'm using the percussive long setting: https://sevish.com/scaleworkshop/?name=12%20equal%20divisions%20of%202%2F1&data=100.%0A200.%0A300.%0A400.%0A500.%0A600.%0A700.%0A800.%0A900.%0A1000.%0A1100.%0A1200.&freq=440&midi=69&vert=5&horiz=1&colors=white%20black%20white%20white%20black%20white%20black%20white%20white%20black%20white%20black&waveform=triangle&env=organ