|
|||
| week 12a - director audio, globals/properties, duplicate sprites, collision detection | |||
audio in director : |
control the sound Sample director movie: view sound.dcr, download sound.dir Director can control the playback of multiple sounds at the same time. Each sound plays in a different channel, and only one sound can play per channel. The sounds themselves are stored in the cast, and are played on command using the play() method. Simple method: If a sound stored in the cast was called "mySound", the following code would play the sound from start to finish for one time:
This code will play the sound in channel 3. It is traditional to play sound starting at channel 3 because any audio in the score normally plays in channels 1 & 2. To play two sounds at the same time, you might use the following code:
Advanced method: For more advanced applications of sound, Director offers more control over the sound. This control includes the number of times to loop the sound and the ability to change the pitch of the sound. Other features include playing and/or looping only a portion of the sound that's in the original sound file. The following code starts the sound and loops the last part of the sound (from 2 seconds in from the beginning to 4 seconds from the beginning) 5 times. In addition, it changes the pitch of the sound up by 5 semitones. Note that the "\" symbol means that the code is continued on the next line. The properties used are indicated with the "#" symbol, where each property and value is separated by a comma. The properties can be specified in any order, and only the #member property is required.
Queuing sounds: Director offers the ability to queue up one or more sounds before they are played (preloading 1.5 seconds of the sound by default). This allows the programmer to make sure the sound plays immediately when the play command is given. If queuing is not used, some delay is incurred while the sound is loaded. Queuing also allows for setting up the playback of several different sound in sequence from one channel. The following code queues two sounds, and then plays them both with one play command:
Sound properties: This table shows all of the properties that can be used by the play() and queue():
|
|||||||||||||||||||||||||||||||||||
| other sound methods : | a selection of useful methods See the lists at the bottom of this page for a complete list all of the sound related methods. Descriptions can be found in the Lingo Dictionary under the Director HELP pull-down.
|
|||||||||||||||||||||||||||||||||||
| stop() : | stop the sound in a channel stop() immediately stops any sound playing in the specified channel. Example:
|
|||||||||||||||||||||||||||||||||||
| pause() : | pause the sound in a channel pause() pauses the currently playing sound in the specified channel. Example:
|
|||||||||||||||||||||||||||||||||||
| isBusy() : | check to see if a sound is playing in a channel isBusy() returns TRUE or FALSE to indicate if a sound is currently playing in the specified channel. See also the status property. Example:
|
|||||||||||||||||||||||||||||||||||
| volume : | the volume of a channel volume gets or sets the current volume of a channel. Values can range from 0 (mute) to 255 (maximum). These values are scaled to the full volume set for the computer by the user or the soundLevel property. Example 1:
Example 2:
|
|||||||||||||||||||||||||||||||||||
| pan : | the pan position of a channel pan gets or sets the position of the sound in the specified channel relative to the left and right speakers. The range is from -100 (all left channel) to 0 (center: equal amounts in both channels) to 100 (all right channel). Example:
|
|||||||||||||||||||||||||||||||||||
| soundLevel : | the computer's system volume soundLevel gets or sets the computer's overall system volume that controls the level of audio coming out of the speakers. Values can set from 0 to 7. Example:
|
|||||||||||||||||||||||||||||||||||
| all sound methods : | from the Director help system Table of Contents > Using Lingo > Lingo by Feature > Sound > Sound information
|
| all materials on this web site © copyright 2003, Philip van Allen |
top |