<-- Previous Change | Next Change -->
| 2007-11-18 23:59:40 by Andrew Plotkin | 2007-11-19 00:10:15 by Andrew Plotkin | ||||
|---|---|---|---|---|---|
| 28 | 28 | ||||
| 29 | The world is a two-dimensional plane. A mono sound | 29 | The 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). | ||
| 30 | 30 | ||||
| 31 | Note that while the panning model is two-dimension | 31 | Note 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. | ||
| 32 | 32 | ||||
| n | 33 | (Someday Boodler will support surround-sound outpu | n | 33 | (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.) | ||||
| 34 | 34 | ||||
| 35 | The default position of a mono sound is (0,0). The | 35 | The 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. | ||
| 36 | 36 | ||||
| 37 | When you schedule a note, you can apply a transfor | 37 | When 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.) | ||
| 38 | 38 | ||||
| 39 | Applying a scale transform to a mono sound has no | 39 | Applying 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.) | ||
| n | n | 40 | |||
| 41 | The 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. | ||||
| 40 | 42 | ||||
| 41 | To generate a sound, we take its starting position | 43 | To 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.) | ||
| 42 | 44 | ||||
| 43 | If both X and Y are in the range -1 to 1, there is | 45 | If 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. | ||
| 44 | 46 | ||||
| 45 | If X or Y is *not* in the -1 to 1 range, we must c | 47 | If 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%.) | ||
| 46 | 48 | ||||
| 47 | The (X,Y) position is normalized by this distance, | 49 | The (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. | ||
| t | t | 50 | |||
| 51 | ## Quirks | ||||
| 52 | |||||
| 53 | If 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 | |||||
| 55 | If 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 | |||||