<HTML> 
<HEAD>
<TITLE>DirectAnimation SDK, VBScript sample</TITLE>
<SCRIPT LANGUAGE="JScript">
<!--
if (window.top.frames.length!=0 && window.top.frames[0].ShowNoButtons!=null)
    window.top.frames[0].ShowNoButtons();
//-->
</SCRIPT>
<!--STRIP_END-->
</HEAD>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->
	 

<BODY BGCOLOR=WHITE TOPMARGIN=15 LEFTMARGIN=20>
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2> 
<CENTER>
<H1>Audio Mixing</H1>
</CENTER>

<DIV STYLE="position:absolute; left:380; top:75;width:50%;">
This template shows how DirectAnimation can be used to mix audio.  The volume
and panning of three sounds are controled by the positions of scrollbars.
</DIV>


<OBJECT ID="DAControl"
   STYLE="position:absolute; left:45; top:75;width:330;height:150" 
   CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>


<OBJECT ID="VolScroll1"   
 STYLE="position:absolute;left:90;top:275;width:10;height:100"
 CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D">
    <PARAM NAME="Min" VALUE="0">
    <PARAM NAME="Max" VALUE="10">
	<PARAM NAME="Position" VALUE="10">
    <PARAM NAME="LargeChange" VALUE="2">
    <PARAM NAME="Orientation" VALUE="0">
</OBJECT>

<DIV STYLE="position:absolute; left:60; top:375;width:50%;">
<B>VOLUME 1</B>
</DIV>


<OBJECT ID="PanScroll1"   
 STYLE="position:absolute;left:45;top:250;width:100;height:10"
 CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D">
    <PARAM NAME="Max" VALUE="10">
	<PARAM NAME="Position" VALUE="5">
    <PARAM NAME="LargeChange" VALUE="2">
    <PARAM NAME="Orientation" VALUE="1">
</OBJECT>

<DIV STYLE="position:absolute; left:80; top:230;width:50%;">
<B>PAN 1</B>
</DIV>

<OBJECT ID="VolScroll2"   
 STYLE="position:absolute;left:200;top:275;width:10;height:100"
 CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D">
    <PARAM NAME="Min" VALUE="0">
    <PARAM NAME="Max" VALUE="10">
	<PARAM NAME="Position" VALUE="10">
    <PARAM NAME="LargeChange" VALUE="2">
    <PARAM NAME="Orientation" VALUE="0">
</OBJECT>

<DIV STYLE="position:absolute; left:170; top:375;width:50%;">
<B>VOLUME 2</B>
</DIV>

<OBJECT ID="PanScroll2"   
 STYLE="position:absolute;left:155;top:250;width:100;height:10"
 CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D">
    <PARAM NAME="Max" VALUE="10">
	<PARAM NAME="Position" VALUE="5">
    <PARAM NAME="LargeChange" VALUE="2">
    <PARAM NAME="Orientation" VALUE="1">
</OBJECT>

<DIV STYLE="position:absolute; left:190; top:230;width:50%;">
<B>PAN 2</B>
</DIV>

<OBJECT ID="VolScroll3"   
 STYLE="position:absolute;left:310;top:275;width:10;height:100"
 CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D">
    <PARAM NAME="Min" VALUE="0">
    <PARAM NAME="Max" VALUE="10">
	<PARAM NAME="Position" VALUE="10">
    <PARAM NAME="LargeChange" VALUE="2">
    <PARAM NAME="Orientation" VALUE="0">
</OBJECT>

<DIV STYLE="position:absolute; left:280; top:375;width:50%;">
<B>VOLUME 3</B>
</DIV>

<OBJECT ID="PanScroll3"   
 STYLE="position:absolute;left:265;top:250;width:100;height:10"
 CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D">
    <PARAM NAME="Min" VALUE="0">
    <PARAM NAME="Max" VALUE="10">
	<PARAM NAME="Position" VALUE="5">
    <PARAM NAME="LargeChange" VALUE="2">
    <PARAM NAME="Orientation" VALUE="1">
</OBJECT>

<DIV STYLE="position:absolute; left:300; top:230;width:50%;">
<B>PAN 3</B>
</DIV>

<!--USE COMMENT TAGS FOR SCRIPTING-->
<SCRIPT LANGUAGE="VBScript">
<!--
  Set m = DAControl.PixelLibrary

  ' Define the volumes and pan positions which will be linked to 
  ' position of scrollbars.
  Set volPos1 = m.ModifiableBehavior(m.DANumber(0))
  Set volPos2 = m.ModifiableBehavior(m.DANumber(0))
  Set volPos3 = m.ModifiableBehavior(m.DANumber(0))
  
  Set panPos1 = m.ModifiableBehavior(m.DANumber(0))
  Set panPos2 = m.ModifiableBehavior(m.DANumber(0))
  Set panPos3 = m.ModifiableBehavior(m.DANumber(0))

  Sub window_onLoad  
    importBase = "../../../../media/"
    sndBase = importBase + "sound/"
    midiBase = importBase + "midi/"

    ' Import the three sounds.
    Set initSnd1 = m.ImportSound(sndBase + "etherial.mp2").Sound.Loop()
    Set initSnd2 = m.ImportSound(midiBase + "island.mid").Sound.Loop()
    Set initSnd3 = m.ImportSound(sndBase + "radiotow.mp2").Sound.Loop()

    ' Contruct the final sound out of the three imported sounds, and
    ' set there volume and panning based on the positions of the scrollbars.
    Set finalSnd = m.Mix(initSnd1.PanAnim(panPos1).GainAnim(volPos1), _
      m.Mix(initSnd2.PanAnim(panPos2).GainAnim(volPos2), _
        initSnd3.PanAnim(panPos3).GainAnim(volPos3)))

    Set txtFont = m.Font("Arial",24,m.White).Bold()
    Set txtImg = m.StringImage("DA AUDIO MIXER", txtFont)

		
    DAControl.Image = m.Overlay(txtImg,m.SolidColorImage(m.Blue))

    DAControl.Sound = finalSnd 
    ' Set the background in case of a non-windowless browser (such as IE3).
    DAControl.BackgroundImage = m.SolidColorImage(m.Blue)

    ' Start the animation.
    DAControl.Start
  End Sub

  Sub VolScroll1_change()
  ' Change volPos1 to the value property of the scrollbar.
    volPos1.SwitchTo(m.DANumber(VolumeVal(VolScroll1.Value)))
  End Sub
  
  Sub VolScroll2_change()
  ' Change volPos2 to the value property of the scrollbar.
    volPos2.SwitchTo(m.DANumber(VolumeVal(VolScroll2.Value)))
  End Sub
  
  Sub VolScroll3_change()
  ' Change volPos3 to the value property of the scrollbar.
    volPos3.SwitchTo(m.DANumber(VolumeVal(VolScroll3.Value)))
  End Sub

  Sub PanScroll1_change()
  ' Change panPos1 to the value property of the scrollbar.
    panPos1.SwitchTo(m.DANumber(PanVal(PanScroll1.Value)))
  End Sub
  
  Sub PanScroll2_change()
  ' Change panPos2 to the value property of the scrollbar.
    panPos2.SwitchTo(m.DANumber(PanVal(PanScroll2.Value)))
  End Sub
  
  Sub PanScroll3_change()
  ' Change panPos3 to the value property of the scrollbar.
    panPos3.SwitchTo(m.DANumber(PanVal(PanScroll3.Value)))
  End Sub

  Function VolumeVal(scrollVal)
    VolumeVal = -scrollVal*0.1 + 1
  End Function

  Function PanVal(scrollVal)
    PanVal = scrollVal*0.2 - 1
  End Function

-->
</SCRIPT>
</FONT>
</BODY>
</HTML>
