Turn files on and off

This example shows how you can turn on and off audio files with a single toggle –– as in swapping between one and the other. Since 1 is on and 0 is off, you can use a == 0 object to produce the opposite (to turn one thing off when you turn the other on and vice versa). This can be seen in action in the example on the left. But because a click will occur when you turn a sound off abruptly, you probably want to fade it out before you stop it, and fade the other sound in over the same amount of time, as in the example on the right.

Chapter: