Adobe Director Online
 

Shrinidhi

Shrinidhi Karanth
Director Developers

5.1 Audio Panning

 
 

This tutorial showcases the audio panning property in Director 11.5. Audio Panning helps user to achieve the following

  1. Play mono or stereo audio on a 5.1 surround speakers with great quality.
  2. Control the contribution of the audio signal to each of the speaker to give a sense of direction to audio.

To just pan the audio singal to a different number of channels panMatrix property need not be used. Only the toChannels property of soundObject and the channelCount property of Mixer needs to be set as below.

global gMix

 

on startMovie

 

  --Create a new Mixer

  gMix = new(#mixer)

 

  -- Create a sound object from member 1. Set it for infinite loop

  gSO = gMix.createSoundObject("sndObj1", member(1),[#loopcount:0])

 

  -- The output of the panning should be 5.1

  gSO.toChannels = 6

 

  -- The mixer should mix the sound object with 6 channels

  gMix.channelCount = 6

 

  -- Disable the use of pan matrix as we don't want positional panning

  gSO.useMatrix = false

 

  -- Play the mixer

  gMix.play()

end

 

on stopMovie

  -- Erase the mixer

  if not voidp(gMix) then

    erase gMix

  end if

end

Now to achieve positional panning, i.e. panning audio signals only to specific speakers, panMatrix property of soundobject or Mixer needs to be used. For example, when a mono is panned to 5.1 then using panMatrix one can specify the contribution of the source mono channel to various different channels of the 5.1.  If the audio source is towards to the left of the listener in a 3D world, the audio source will have its output only to the left and left surround channels (or speakers) of the 5.1 and contribution of the source audio to the other channels (or speakers) can be set to zero. When the audio source slowly moves from left towards right, the contribution of the audio source to the left and left surround speakers can be gradually decreased and to the right and right surround speakers can be slowly increased.

Let’s consider a scenario where a bird is moving from left to right. Let the audio file with the bird sound be a mono.

Since in our scenario source is a mono and the destination is a 5.1, the panMatrix will be of order 1x6. The ‘toChannels’ property of the soundObject needs to be set to 6.

From the D11.5 document, the ordering of the channels in the 5.1 audio signal are as follows Left (L), Right (R), Center (C), LowFrequencyEffect (LFE), Left Surround (LS), Right Surround (RS).

The panMatrix will be…

         L   R   C   LFE   LS   RS

Mono  [  x   x   x    x    x    x  ]

Where, the values of ‘x’ needs to be filled based on the contribution of the input channels to each of the output. It’s a multiplication factor and hence 1 means full signal from the source channel and 0 means no signal from the source.

Now, let’s suppose that the bird is in max front left and hence audible only at the left speaker at a low volume and silence at other speakers. The panMatrix would look like

          L   R   C   LFE   LS   RS

Mono  [  0.5  0   0    0    0    0  ]

If the bird now moves from front left to front right the value of L will slowly increase till it reaches center where the value of left will be full volume. Hence when the bird is at front then the matrix will be

         L   R   C   LFE   LS   RS

Mono  [  1   1   1    0    0    0  ]

As the bird moves towards right the volume of left will be 0 and the volume of right will slowly decrease. When it reaches the max front right, it will be as below

         L    R   C   LFE   LS   RS

Mono  [  0   0.5  0    0    0    0  ]

Similarly, when the bird is behind the listener the LS and RS values needs to be updated based on the position.

Now let’s consider the same scenario but the audio file being a stereo. i.e. A stereo source ( L, R ) is panned to 5.1 ( L, R, C, LFE, LS, RS )

The ‘toChannels’ of the sound object needs to be set to 6.

The order of the matrix will be 2x6.

The panMatrix will look like

       L   R   C   LFE   LS   RS

L  |   x   x   x    x    x    x    |

R  |   y   y   y    y    y    y    |

Where ‘x’ is the contribution of the input left channel towards different output channels and ‘y’ is the contribution of the input right channel to the different output channels. The output channels will play the sum of the contributions of the input channels.

The Lingo code to create a matrix and set all the output channels to 0 (silence) is as follows

  gMatrix = newmatrix(2, 6)

 

  repeat with i = 1 to 2

    repeat with j = 1 to 6

      gMatrix.setval(i, j, 0)

    end repeat

  end repeat

where ‘i’ is for input and ‘j’ is for output channel and the third parameter specifies the contribution of the i’th input channel to the j’th output channel.

If we want to play the same stereo on 5.1 channels without any signal on C, LFE, LS and RS, the values need to be

        L     R    C   LFE   LS   RS

L  |   0.5   0.5   0    0    0    0    |

R  |   0.5   0.5   0    0    0    0    |


  gMatrix.setval(1, 1, 0.5)

  gMatrix.setval(2, 1, 0.5)

  gMatrix.setval(1, 2, 0.5)

  gMatrix.setval(2, 2, 0.5)

Here the Left of the output channel will play the average of the stereo channels from the source. Similarly the right output channel.

Now let’s consider the same example as below. The bird (which is now a stereo signal) is at far front left of the listener. Then the values need to be

        L     R    C   LFE   LS   RS

L  |   0.25   0   0    0    0    0    |

R  |   0.25   0   0    0    0    0    |


  gMatrix.setval(1, 1, 0.25)

  gMatrix.setval(2, 1, 0.25)

If the bird now moves from front left to front right the value of L will slowly increase till it reaches center where the value of left will be full volume. Hence when the bird is at front then the matrix will be

        L      R     C   LFE   LS   RS

L  |   0.5    0.5   0.5    0    0    0    |

R  |   0.5    0.5   0.5    0    0    0    |


  gMatrix.setval(1, 1, 0.5)

  gMatrix.setval(2, 1, 0.5)

  gMatrix.setval(1, 2, 0.5)

  gMatrix.setval(2, 2, 0.5)

  gMatrix.setval(1, 3, 0.5)

  gMatrix.setval(2, 3, 0.5)

As the bird moves towards right the volume of left will be 0 and the volume of right will slowly decrease. When it reaches the max front right, it will be as below

       L    R    C   LFE   LS   RS

L  |   0   0.5   0    0    0    0    |

R  |   0   0.5   0    0    0    0    |


  gMatrix.setval(1, 2, 0.25)

  gMatrix.setval(2, 2, 0.25)

Similarly, when the bird is behind the listener the LS and RS values needs to be updated based on the position.

Download the sample movie here

Feedback:
If you have any questions or comments concerning this article, please send a message to shrinidhi@gmail.com

 
spacer image
This is not an official site from Adobe. If you need any clarifications, please mail me at info@adobedirectoronline.com