News for hackers. Stuff that matters.
Re:Variable duty cycle square waves with the Web Audio API by iamdan on Monday April 07, 2025 @04:04PM (#43615358)
I think long term I will be moving in that direction. For this initial exploration and experimentation I've been doing with the Web Audio API, the sawtooth oscillator + step function waveshaper node have been sufficient for my use case but I will need investigate whether I can produce a more authentic sound with an AudioWorkletProcessor approach
Re:Variable duty cycle square waves with the Web Audio API by tashian on Monday April 07, 2025 @04:58PM (#43615872)
I did a little synth project recently that uses an AudioWorklet processor to morph between single-cycle waveforms, and it worked super well. When I tried to do this with the Web Audio API, the audio would stutter when I moved the controls. Switching to an AudioWorklet thread eliminated the stuttering issue. So, if you need real-time sound shaping controls, you may find that AudioWorklet is a better fit.

https://waves.tashian.com

Re:Variable duty cycle square waves with the Web Audio API by tomduncalf on Monday April 07, 2025 @05:28PM (#43616151)
I’ve got a very simple project demonstrating how to use the newish pure C++ Emscripten Audio Worklet API if you’re interested. It’s a bit neater than the old way you’ll usually come across which also involves writing JS code, but there aren’t many docs online! https://github.com/tomduncalf/emscripten-audio-worklet-examp...