Adding Music and Sounds
Top  Previous  Next


This is a step-by-step tutorial for adding music and sounds to your Movie. This tutorial illustrates some of the features seen in the "first.swi" file in the File | Samples | Tutorials Menu.

With SWiSH you can import both .wav and .mp3 formats. You can control the overall volume of sounds and apply simple fade Effects. A sound can be played when a Movie reaches a selected Frame or in response to a Mouse Event. For a more detailed explanation on using sounds in your Movie please read Play Sound
. This tutorial will be limited to adding sounds to the Timeline in response to a Frame Event; adding sounds in response to Mouse Events will be discussed in the Creating Buttons tutorial.

As sound files can significantly increase the overall file size of the Movie, it is best to select short tunes that can be looped as background music for a Movie that will be playing over the Web.

Note: If you are having problems importing .wav files, try downloading and installing the latest Windows Media Player from http://www.microsoft.com/windows/mediaplayer/en/default.asp



Adding Background Music

1.Open "myfirst.swi" saved from the previous tutorial. Right-click on Frame 1 of the Scene row. From the context Menu select Sound | Play Sound. A scriptmarker Script Action marker will appear at that Frame on the Timeline  

   Tute31
   
2.From the Actions Panel you should see the Play Sound Event highlighted in the 'Add Script' window. Note that the Action playSound is in red. This is because the statement is currently incomplete (it does not contain a sound to play). Press the 'Import' button to view the 'Import Sound' dialog box. From the Samples folder, select "88A.mp3" and press Open  

Note: The "Files of Type input box" should be set to show MP3 or All Files. If not set to one of these settings, you will not be able to see the "88A.mp3" file

3.Left-click on the sound "88A.mp3" to select that as the sound to be played. The selected sound is now shown as the parameter to the playSound() Action. Note that the script marker changes to sound_marker in the Scene Timeline and the Action script turns black as it is now syntactically correct  
 
Tute32  

4.Select the 'Layout' Panel and Press the playmovie Play Movie button on the 'Control' Toolbar. The tune will play once and then stop. Press the stopmovie 'Stop' button  
5.From the Script Panel, below the 'Import' Button, press the soundpropertiesbutton 'Properties...' button to display the 'Properties for Sound' dialog box. This dialog box, displays the file's sample rate and the length of 1x loop in seconds and Frames. Note that the quoted length (41.5 Frames) is not long enough to allow sound to be played through the entire Movie. Close this window by either pressing "Ok", "Cancel", or the [X] button at the top-right.  

SoundEffectProperties  


6.   From the Script Panel
, below the 'Import' Button, press the soundeffectbutton 'Sound Effect...' button to display the 'Sound Effect Settings' dialog box

SoundEffectSettings  

7.In the 'Loop sound' edit box, enter 15 (this will ensure that the music will continue throughout the introduction). You can leave the Volume setting at 100%, and select the option 'Don't play sound if it is already playing' feature checked. Press OK to accept the changes. This will change the parameters of the playSound() Action to: "playSound("88A.mp3",True,100,15);"  
8.Select the 'Layout' Panel and Press the playmovie 'Play Movie' button on the Toolbar. The tune will start as your Movie starts and will continue to play long after your animation has stopped  


Sound Effects

You can add a Sound Effect in synchrony with the appearance of the logo.

1.Right-click on Frame 110 of the Scene row. From the context Menu select Sound | Play Sound. From the Script Panel press the 'Import' button and from the Samples folder, select "FX1001.wav" and press Open  

Note: The "Files of Type input box" should be set to show Wave Sounds or All Files. If not set to one of these settings, you will not be able to see the "FX1001.wav" file

2. Press the soundpropertiesbutton button to display the 'Properties' dialog box. By default, the Compression for .wav files is set to MP3; leave this setting, as this will produce the smallest file size, compressing your .wav files up to 1/10 of their original size. Leave the Preload sound set to Object or Scene default, press OK

3.Click on the soundeffectbutton button, as you do not want this sound to loop, leave the 'Loop sound' edit box value set to 1. Leave the Volume value set to 100%. Select Sound effect | Pan left to right. Press OK to accept these changes. The playSound action should change to: "playSound("FX1001.WAV",False,100,1,False,False,'Pan Left to Right');"  
 
4. Select the 'Layout' Panel and Press the playmovie 'Play Movie' button on the Toolbar. The sound will begin playing when your logo appears. It will begin playing in the left speaker and end playing in the right speaker. Press the stopmovie 'Stop' button  
 
 
Stopping Sounds  
 
1.Right-click on Frame 111 and select Sound | Stop Sound from the context Menu. Select "88A.mp3" and press Enter on your keyboard  
 
Note:  
·If you need or want to stop your background music in the middle of a loop, rather than having it stop abruptly, it may be helpful to the flow of the Movie if you stop the music while another sound is playing, as you have done in this example  
·There may be times when you will want to stop all sounds playing. This can be done within the Timeline by right-clicking on the Frame where you would like the sounds to stop and selecting Stop All Sounds from the context Menu  

2. Select the 'Layout' Panel and Press the playmovie 'Play Movie' button on the Toolbar. Your background music will end just as "FX1001.wav" begins. Press the stopmovie 'Stop' button

3.    Your introduction is complete. You may view it in your browser by pressing the testbrowser 'Test in Browser' button

4.    Save your Movie

You are ready to continue with the Creating Buttons tutorial.