Implemented WebWorker to resample output audio according to difference between browser FPS and expected (60) frame rate of VGA output from Verilator.
New audio pipeline:
1) first generated audio samples are low-pass filtered (20 kHz) to approximately simulate Audio PMOD behavior and reduce occasional high-pitch noise especially when browser FPS significantly differs from 60 Hz
2) filtered samples are accumulated in the ring-buffer (approximately 5 frames for data) of audio Web Worker running on a separate thread. Ring-buffer helps to amortise uneven framerate and keeps worker thread from starving or overflowing.
3) finally, audio Web Worker thread is responsible for resampling available audio data so that it is stretched or compressed to match the sampling rate of the audio driver.
Implemented WebWorker to resample output audio according to difference between browser FPS and expected (60) frame rate of VGA output from Verilator.
New audio pipeline: 1) first generated audio samples are low-pass filtered (20 kHz) to approximately simulate Audio PMOD behavior and reduce occasional high-pitch noise especially when browser FPS significantly differs from 60 Hz 2) filtered samples are accumulated in the ring-buffer (approximately 5 frames for data) of audio Web Worker running on a separate thread. Ring-buffer helps to amortise uneven framerate and keeps worker thread from starving or overflowing. 3) finally, audio Web Worker thread is responsible for resampling available audio data so that it is stretched or compressed to match the sampling rate of the audio driver.