Open ttencate opened 10 years ago
Some UI work definitely would be appreciated!
I have a humble 1.7 GHz dual-core laptop and whenever I have jfxr open, its tab takes up about 40% CPU in Chrome, even when jfxr is sitting idle. UI isn't smooth at all for me, but functionality-wise it seems to work fine. I have a feeling that it could be made much, much more responsive, and a constantly-running timer as mentioned above is probably contributing to the high CPU usage.
You could try disabling the frequency analyser (left of the play button) by clicking it to toggle it off. It's puzzling that idle takes so much CPU -- I've poked at that a bit, but even if I remove all drawing code except the canvas clear, CPU is still high.
Currently, the sound is synthesized all in one go. For long sounds, this leads to UI freeze and bad user experience.
There is already some code to do the work in chunks, and set a 0 millisecond timer to start the next chunk. This worked, but I noticed that this slows down generation of short sounds significantly. Maybe we could use a dynamic chunk size, and run synchronously if that would give acceptable latency, asynchronously otherwise.
I also tried web workers, but there are some problems. You cannot interrupt a web worker unless it's going through its message loop, which means we need to run in chunks inside the web worker as well. Alternatively, we could kill the entire worker and start a new one, but a garbage collection bug on Chrome made the tab crash after some 50 workers had been created. We could also have a pool of workers, and just let old ones run to completion, wasting some CPU.