User Tools

Site Tools


Minimizing sound clicks

by Richard Russell, January 2010

When generating music using the SOUND statement, clicks may sometimes be audible at the start and/or end of notes. These clicks are likely to be more noticeable when listening in high-quality, such as on headphones or when feeding the PC's sound output to a hi-fi system.

There are four main causes of such clicks; these are listed below along with methods for minimizing the effect.


Never use SOUND OFF to terminate a playing note; this shuts down the entire BB4W sound system and is likely to result in a large output transient. To terminate a note before its duration has been completed (or when the duration has been set to 'infinite') use the flush bit.

Instead of:

        SOUND OFF


        SOUND &10, 0, 0, 0
        SOUND &11, 0, 0, 0
        SOUND &12, 0, 0, 0
        SOUND &13, 0, 0, 0

Sudden amplitude changes

If you are using the 'constant amplitude' form of the SOUND statement (where the second parameter is negative) then, when you need to change the amplitude, do so gradually.

Instead of doing this:

        SOUND 1,-15,148,20
        SOUND 1,-10,148,20

Do this:

        SOUND 1,-15,148,18
        SOUND 1,-14,148,1
        SOUND 1,-13,148,1
        SOUND 1,-12,148,1
        SOUND 1,-11,148,1
        SOUND 1,-10,148,18

Or consider using envelopes to achieve a similar effect:

        ENVELOPE 1,1,0,0,0,0,0,0,20,0,0,-20,120,0
        ENVELOPE 2,1,0,0,0,0,0,0,-20,0,0,-20,80,0
        SOUND 1,1,148,20
        SOUND 1,2,148,20

Excessive attack or release rates

If you are using an amplitude envelope (where the second parameter of the SOUND statement is positive) don't make the attack and release rates too great.

For example, instead of using:

        ENVELOPE 1,1,0,0,0,0,0,0,127,0,0,-127,126,0


        ENVELOPE 1,1,0,0,0,0,0,0,20,0,0,-20,126,0

(where the attack and release rates have been reduced from 127 to 20).

Rests (silent notes)

If you need a period of silence on a particular channel (a rest) use one or other of the following techniques, depending on whether you are using a constant amplitude or an envelope:

Constant amplitude

Set the pitch to zero, not the amplitude.

Instead of:

        SOUND 1,-15,148,10
        SOUND 1,0,148,10 : REM rest
        SOUND 1,-15,100,10


        SOUND 1,-15,148,10
        SOUND 1,-15,0,10 : REM rest
        SOUND 1,-15,100,10

Amplitude envelope

Use the hold bit to allow the sound to decay rather than stop suddenly:

Instead of:

        ENVELOPE 1,1,0,0,0,0,0,0,20,0,0,-20,126,0
        SOUND 1,1,148,10
        SOUND 1,1,0,10 : REM rest
        SOUND 1,1,100,10


        ENVELOPE 1,1,0,0,0,0,0,0,20,0,0,-20,126,0
        SOUND 1,1,148,10
        SOUND &1001,1,0,10 : REM rest
        SOUND 1,1,100,10
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
minimizing_20sound_20clicks.txt · Last modified: 2018/04/15 13:47 by richardrussell