What's that effect called? Is that one of the reasons for having attack and release parameters when implementing synths? And is there a generic method to avoid such sound artifacts?

Example: I have implemented a simple synth that uses a midi control channel to adjust loudness by applying the 128 discrete MIDI values directly to the generated audio signal. Whenever one touches the MIDI controller wheel, pretty nasty, scratch-like sounds get produced.


You are changing the volume in discrete steps, applied at random points in the audio signal.

If the signal happens to be close to zero, you won't hear much of anything.

If the signal is close to a peak, then you will get a "step" change in the signal. This audible.

When you roll the volume up and down that way, you get a kind of "zipper" sounding noise.

What you want to do is to apply volume changes only when the signal is close to zero. The "zippers" still occur, but are much less annoying - and may be completely inaudible if you change volume only at times when the signal is at zero.

Looking at the code you referred to in a comment, it appears you aren't changing volume when the amplitude is close to zero.

You are changing volume when the signal is less than zero. What you want to do is to change volume when the absolute value of the signal is less than some small value.

Start with like 0.1, then try 0.01. You should notice far less "zipper noise" that way.

Sort of like this:

if (abs(amplitude) < 0.1d) {
   currentVolume = targetVolume;
  • $\begingroup$ Well, that's what I thought at first, too. But it's more complicated. Having a discontinuous waveform is not the (only?) problem. Here is an example where there is a popping effect even though volume is adjusted suddenly only on 0 amplitude traversal: github.com/jjYBdx4IL/java-evaluation/blob/master/src/test/java/… $\endgroup$ – user1050755 Aug 24 '19 at 17:31
  • $\begingroup$ @user1050755: Added to the answer in response to comment. $\endgroup$ – JRE Aug 24 '19 at 18:35
  • $\begingroup$ what I do is to detect 0-crossings, ie. when the sign of the amplitude changes. $\endgroup$ – user1050755 Aug 24 '19 at 18:56

Changing the volume abruptly always causes a click in the audio. Most DAC chips change volume on next zero crossing (or after a timeout if it takes too long). In this situation it would be best to use the MIDI volume as the target volume, and slide from current volume to target volume over many samples, either with linear or exponential ramp.

  • $\begingroup$ Adjusting the volume over a few samples isn't enough, it seems that it has to be changed over mulitple signal oscillations. $\endgroup$ – user1050755 Aug 24 '19 at 18:58

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.