Stereo Panning

<-- Previous Change | Next Change -->


2007-11-18 23:59:40 by Andrew Plotkin
2007-11-19 00:10:15 by Andrew Plotkin
2828
29The world is a two-dimensional plane. A mono sound29The world is a two-dimensional plane. A mono sound
> comes from a position (X,Y). A stereo sound is eq> comes from a position (X,Y). A stereo sound is eq
>uivalent to two mono sounds, coming from positions>uivalent to two mono sounds, coming from positions
> (X0,Y) and (X1,Y).> (X0,Y) and (X1,Y).
3030
31Note that while the panning model is two-dimension31Note that while the panning model is two-dimension
>al, Boodler currently supports only stereo (two-ch>al, Boodler currently supports only stereo (two-ch
>annel) output. So only the X axis affects the appa>annel) output. So only the X axis affects the appa
>rent position of a sound. The Y axis is used only >rent position of a sound. The Y axis is used only 
>for fading-into-the-distance effects.>for fading-into-the-distance effects.
3232
n33(Someday Boodler will support surround-sound outpun33(Someday Boodler will support surround-sound outpu
>t, and then the Y axis will be more interesting. A>t, and then the Y axis will be more interesting. A
>nd maybe then I'll add a vertical Z axis to the co>nd maybe then I'll add a vertical Z axis to the co
>ordinate system. For the moment, most sound design>ordinate system.)
>ers will only care about the X axis.) 
3434
35The default position of a mono sound is (0,0). The35The default position of a mono sound is (0,0). The
> default position of a stereo sound is (-1,0) for > default position of a stereo sound is (-1,0) for 
>the left channel, (1,0) for the right channel.>the left channel, (1,0) for the right channel.
3636
37When you schedule a note, you can apply a transfor37When you schedule a note, you can apply a transfor
>m to it. A Boodler [channel] can apply a transform>m to it. A Boodler [channel] can apply a transform
> to everything in the channel. These transforms ca> to everything in the channel. These transforms ca
>n include translation and scaling in the X and Y a>n include translation and scaling in the X and Y a
>xes. (Boodler does not currently support rotation.>xes. (Boodler does not currently support rotation.
> But if you want to swap left and right, scale the> But if you want to swap left and right, scale the
> X axis by -1.)> X axis by -1.)
3838
39Applying a scale transform to a mono sound has no 39Applying a scale transform to a mono sound has no 
>effect. (Any multiple of (0,0) is still (0,0).) Ap>effect. (Any multiple of (0,0) is still (0,0).) Ap
>plying a scale transform to a stereo sound spreads>plying a scale transform to a stereo sound spreads
> or narrows the two channel positions. (If you app> or narrows the two channel positions. (If you app
>ly scale 2, the channels wind up at (-2,0) and (2,>ly scale 2, the channels wind up at (-2,0) and (2,
>0). Because of the inverse square law, the result >0). Because of the inverse square law, the result 
>will be fainter.)>will be fainter.)
nn40
41The stereo module has constructors to let you defi
 >ne any transform. Most soundscape designers will o
 >nly care about the X axis. If you specify a transf
 >orm as a plain number, this is considered to be an
 > X-shift.
4042
41To generate a sound, we take its starting position43To generate a sound, we take its starting position
> and stack all the transforms applied by the chann> and stack all the transforms applied by the chann
>el it is in. This gives us a final apparent positi>el it is in. This gives us a final apparent positi
>on (X,Y). (A stereo sound, as noted, is equivalent>on (X,Y). (A stereo sound, as noted, is equivalent
> to two mono sounds handled separately.)> to two mono sounds handled separately.)
4244
43If both X and Y are in the range -1 to 1, there is45If both X and Y are in the range -1 to 1, there is
> no distance fading (inverse square) effect. The Y> no distance fading (inverse square) effect. The Y
> value is ignored in this case. If X >= 0, the sou> value is ignored in this case. If X >= 0, the sou
>nd plays at full volume in the right output channe>nd plays at full volume in the right output channe
>l; the left output channel is proportional to (1-X>l; the left output channel is proportional to (1-X
>). If X <= 0, it goes the other way.>). If X <= 0, it goes the other way.
4446
45If X or Y is *not* in the -1 to 1 range, we must c47If X or Y is *not* in the -1 to 1 range, we must c
>ompute the distance of the sound. To avoid a lot o>ompute the distance of the sound. To avoid a lot o
>f square-rooting, we approximate the distance as m>f square-rooting, we approximate the distance as m
>ax(abs(X), abs(Y)). (This is an underestimate, but>ax(abs(X), abs(Y)). (This is an underestimate, but
> not by more than 30%.)> not by more than 30%.)
4648
47The (X,Y) position is normalized by this distance,49The (X,Y) position is normalized by this distance,
> which brings it within the -1 to 1 range. Apply t> which brings it within the -1 to 1 range. Apply t
>he rules above. Then divide the left and right out>he rules above. Then divide the left and right out
>put volumes by the square of the distance.>put volumes by the square of the distance.
tt50
51## Quirks
52
53If you apply scale(0) to a stereo sound, it gets l
 >ouder. Why is this? In its default position, the s
 >tereo sound plays one channel in your left ear and
 > one channel in your right ear. If you scale it do
 >wn to zero, both apparent positions become (0,0), 
 >and therefore both play at full volume in *both* e
 >ars.
54
55If you shift a stereo sound by 1, it doesn't sound
 > very off-center. Why not? Its two channels wind u
 >p at apparent positions (0,0) and (2,0). So the le
 >ft channel plays at full volume in both ears; the 
 >right channel plays at quarter-volume, right ear o
 >nly. The right channel is mostly drowned out, and 
 >so you basically hear the left channel only, cente
 >red.
56
Stereo Panning - last changed 2007-11-19 01:31:14 by Andrew Plotkin (zarf)