0
$\begingroup$

I am using Web Audio API + extended Karplus-Strong algorithm to generate plucked string sound and play it.
The problem that I face is sometimes there's a weird crackling sound/thump when playing some particular chords, see example here https://demiurg.app/player/MetallicA/Fade-To-Black/?id=117. First 20 or so measures generate such problem.
At first I thought that this is an effect of a DC offset, so I applied a high-pass filter, but nothing really changed.
While searching over the internet I've found some examples that resemble my case, there's a bunch of youtube videos about changing the buffer size (rendering quantum size) for different DAWs to overcome such effect, but there's no way of doing it in Web Audio API atm. The default on all browsers should be 128.
Interestingly enough, when I apply a slight distortion via cubic curve, the crackling effect is mitigated, but it doesn't go away.

Has someone else encountered this issue with generated sound? How can this be solved or mitigated without signal distortion?

$\endgroup$

1 Answer 1

0
$\begingroup$

So, apparently this is the way the web audio works, it cannot handle smooth transitions when playing back sound, which results in such clicks or crackling.
This, this and this links helped me come to a conclusion that a custom ADSR envelope is needed. When I applied such envelope to gradually but very fast increase the amplitude of the sound at the beginning and rapidly decrease it at the end the clicks went away.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.