|
|
|
|
Director in a NutshellBy Bruce A. Epstein1st Edition March 1999 1-56592-382-0, Order Number: 3820 658 pages, $24.95 |
Chapter 15
Sound and Cue PointsDirector is not a sound editing tool. You will usually create your sound files in an external application, and then import them into Director. For testing, you can use the sample sound files on the Director 7 CD in the Macromedia/Support folder.
D7 includes the Beatnik Lite Xtra (see Xtras
Beatnik Lite or http://www.headspace.com/to/?xtra0support ). The D7 Studio for Macintosh includes Bias Peak LE (see http://www.bias-inc.com ) instead of SoundEdit, which was bundled with previous Studio versions. The D7 Studio for Windows includes Sonic Foundry's Sound Forge XP, as did the D6 Studio.
Digital Audio Primer
A brief primer on digital audio is in order. In the real world, sound is continuous. For computer use, sound is digitized by sampling it at many points throughout each second of audio. A sound's sample rate is typically 11.025, 22.050, or 44.100 kHz (kilohertz, or thousands of samples per second), although many variations exist. Higher sampling rates require more storage, but typically sound better (have higher fidelity). The bits per sample or sound bit depth is usually 8 or 16, meaning that each sample requires 1 or 2 bytes of storage (there are 8 bits per byte).
Downsampling refers to lowering a sound's sample rate or bit depth, which can be done in a sound editor, but not in Director. Downsampled audio uses less storage at the expense of quality. Resampling is the process of changing the sampling rate, either up or down. The fidelity of resampled audio can vary measurably between different sound editors.
Sounds typically contain one or two channels: mono (or monaural) or stereo. To fold or flatten a sound is to convert it from stereo to mono, sometimes at the expense of quality.
The size of an uncompressed sound can be determined as:
size in K = (bits per sample)/8 × (sample rate in kHz) ×(number of channels) × (duration in seconds)For example, 22.050 kHz, 16-bit mono sound occupies:
16/8 × 22.050 × 1 = 44.1 K/secAnd 44.100 kHz, 16-bit stereo sound occupies:
16/8 × 44.100 × 2 = 176.4 K/secFor compressed Shockwave audio (SWA), the important factor is the streaming data rate, which is chosen when you compress your SWA, measured in Kbps (thousands of bits per second):
(bit rate in Kbps)/8 = data rate in K/secAudio data is typically measured in K/sec. Memory is typically measured in increments of 1024 bytes (KB). Throughout this chapter, I use K to indicate 1000, and KB to indicate 1024. For example, CD-quality audio (16-bit, 44.1 kHz, stereo) requires 176.4 K/sec, which is technically 172.27 KB/sec. Divide by 1.024 to convert from K to KB, and divide by 8.192 rather than by 8 to convert from Kbps to KB, to account for the 2% discrepancy.
To calculate the disk space required for any type of sound, multiply the rate in KB/sec by the duration in seconds. These calculations exclude the small header associated with each sound. Unless the sound is very short, has a low data rate, and contains numerous cue points, the header size is insignificant relative to the audio data.
Sound Playback in Director
Director uses two Sound channels in the Score that correspond to the first and second system sound channels. But SWA sprites, which are placed in the sprite channels, can also use system sound channels 1 and 2. I use the uppercase Sound channel when referring to the channels in the Score, and the lowercase sound channel when referring to the System sound channels accessible via Lingo.
TIP:
See "Xtras needed to play external sounds in Director 6 and 7" later in this chapter to ensure that you've included the necessary Xtras with your Projector.
Supported Sound Formats
Sound cast members may be imported (embedded) into Director's cast or may be externally linked. Table 15-1 lists the supported audio formats as well as cross-platform differences. Note that the same AIFF, WAVE, and SWA files can be used on both Macintosh and Windows in D6 and D7. QuickTime and AVI files can also contain audio tracks. The Java player supports Sun AU format only.
Director does not export sound files, and sounds may be lost when exporting to QuickTime or AVI formats. To export a sound, cut and paste from the Cast to your sound editing program, set an external sound editor under File
Preferences
Editor, or rely on a third-party Xtra. There should be no need to export sounds in most cases, as you should retain the original source files imported into Director.
Table 15-1: Cross-Platform Audio Comparison Feature
Macintosh
Windows
Formats supported for import into Cast[1]
Same as Mac, except for System 7 sounds
Formats supported for external linking
Same as above (except System 7 sounds), plus QuickTime (AVI imported as QT3 only)
Same as above, plus QuickTime, AVI
Supported sampling rates[4]
5.564, 7.418, 11.025, 11.127, 22.050, 22.255, 32.000, 44.100, and 48.000 MHz
11.025, 22.050, and 44.100 MHz
Multichannel audio
Built-in (zero latency)
Supported via MacroMix, DirectSound, or QT3Mix[5] (non-zero latency)
Maximum number of sound channels
8
Up to 8 (set by MixMaxChannels in DIRECTOR.INI)
Multiple simultaneous audio sources
Yes
Not necessarily5
System audio buffer size[6]
System's audio buffer size is fixed
Settable via DIRECTOR.INI file.
the soundLevel (0 to 7)
Matches settings in Sound or Monitors & Sound Control Panel
Matches SoundLevel settings in DIRECTOR.INI. See also Volume Control in Task Bar[7]
SoundEdit's native SE16 format was supported by D5, but is not supported in D6 or D7. Likewise, sounds compressed with MACE 3:1 and MACE 6:1 are not supported. D6 and D7 support IMA-compressed WAVE files, but not WAVE files compressed with Microsoft's proprietary compression. Sun AU files must have the .au extension (the equivalent Mac file type,
ULAW, was not recognized prior to D7.0.1). See Table 4-4.User Interface Issues
High-quality audio enhances a multimedia experience more than you might realize. When designing your audio, keep the following in mind:
- Director will automatically continue playing sounds at the end of one movie when branching to another movie. This provides an audio "transition."
- Use professional-quality sound effects and voice-overs (sound effects collections and professional voice talent are widely available).
- Avoid loud, annoying sound loops.
- Not all computers have a sound card and speakers, or the volume may be muted (and some users are deaf ).
- Include text prompts for vital operations and allow the user to replay important audio messages.
- Sound cards and speaker quality vary. Not all systems support CD-quality stereo sound. The highest quality sounds may be a waste of bandwidth.
- Provide a volume control with a mute option. It is exceedingly rude to increase the system volume level automatically. If necessary, check the volume level via Lingo and suggest that the user change it.
Comparison of Sound Playback Methods
The various sound playback options are shown in Tables 15-2 and 15-3. The optimal method depends on the playback platform, the format of the sound, the size of the sound, the number of sound channels in use, the presence or absence of simultaneous animation and video, and whether a sound is triggered by an event, used as background music, or played in synchronization with a video or animation.
Table 15-2: Audio Playback Method Comparison Method
Pros
Cons
Score Sound channel
Easy and intuitive. No scripting. Can use Tempo channel to wait for sounds.
Limited control and poor synchronization; only two sound channels.
puppetSound
Control over sound triggering.
Sounds must be explicitly unpuppeted.
sound playFile
Sounds don't require a cast member. Can be played in any sound channel.
Slows loading of video or graphic media.
Sound tracks in digital video cast member
Can start and stop sound at any point, or play sound fast, slow, or backward.
QT and AVI audio may not mix with other audio under Windows
SWA
High quality at low bandwidth (good compression). Accesses up to 8 sound channels.
Processor-intensive. Requires 68K with FPU, or Pentium for playback.
Flash Audio
Compact and integrated with Flash file.
Low quality. Conflicts with Director sounds.
MIDI
Small size with excellent fidelity. Instruments can be changed dynamically.
Not well supported. Requires QT with MIDI extension or third-party Xtra.
MCI
Control over external devices, such as video disks and RedBook CDs.
Windows-only. Not universally reliable.
Third-party Xtras
The free CDPro Xtra (http://www.penworks.com) plays RedBook audio. Beatnik adds many capabilities.
Beatnik Xtra is expensive.
Table 15-3 compares features of the various playback methods. The Macintosh supports up to eight sound channels. The number of channels on the PC is set by the MixMaxChannels option in the DIRECTOR.INI file.
Table 15-3: Audio Playback Method Features Method
Streamed
Loopable[8]
Channels
Cue Points
Score Sound channels
Only if external
Only if internal
2
AIFF, and WAVE (D6.5 or later)
puppetSound
Only if external
Only if internal
Up to 8
Same as above
sound playFile
Always
No
Up to 8
Same as above
Audio track in digital video
Always
No
Uses separate video mixer
Same as above
SWA
Only if external
Only if internal
Up to 8
Yes, for QT and AVI
Flash audio
N/A
No
N/A
No
MIDI
Varies
Yes
N/A
No
Third-party
Usually
Varies
Varies
Xtra-dependent[9]
Sound Cast Members
Sound cast members may be imported (embedded) into Director's Cast or externally linked (see ). Import short and frequently used sounds into the Cast. Leave longer sound files on disk and link to them instead. See Example 4-7, which imports small external sounds into the Cast and warns about large internal sounds.
Standard sound and SWA cast members are indicated by a speaker icon (see Figure 4-3). Find sound cast members under Edit
Find
Cast Member by searching for members of Type: Sound; find SWA members using Type: Xtras in D6 and Type: Shockwave Audio in D7. Find QT2 or AVI members (which often contain audio) using Type:Digital Video. Find QT3 members using Type:Xtra in D6.5 and Type:QuickTime 3 in D7.
External sound files can be changed without altering your Director movie and allow you to easily ship audio in different languages or audio of varying quality. Similar flexibility can be achieved by using an externally linked castLib to hold your internal sound cast members.
During development, either of these techniques prevents your main movie from growing large due to the inclusion of sounds. As sounds don't often change, this allows you to transfer, back up, or distribute only those portions of the project that have been altered.
Internal (embedded) sounds
Embed small sounds (those under approximately 500 KB) in the Cast using the Standard Import mode under File
Import. An internal sound is preloaded in its entirety before it plays (or can be preloaded manually ahead of time), so any disk access occurs before, not during, playback. Internal sounds remain in memory after being played (until being unloaded when Director needs the RAM), and need not be reloaded each time they are played. Thus, internal sounds are convenient for button-click noises and small looping sounds. These same attributes make embedded sounds inappropriate for large sounds; large internal sounds cause long load delays and consume excessive memory.
Externally linked (streaming) sounds
Link to large AIFF and WAVE sounds using the Link to File mode under File
Import. Externally linked sounds are streamed from disk and begin to play as soon as the first data is available. A streamed sound can be of arbitrary length without requiring significant RAM. Linked sounds are most appropriate for long sounds used only once, such as narration.
However, streamed sounds are not kept in RAM, cannot be looped automatically, and must be reloaded to be repeated. Because a CD-ROM can't access data from two places simultaneously, streaming audio will hinder the loading of other data such as digital video or bitmaps. The key factor for external streaming sounds, including SWA, is the bandwidth, not the total file size; as Buzz Kettles puts it, "It's not the size, it's the motion."
When using linked sounds, include the external sound files and sound-related Xtras with your Projector (see "Sound-Related Xtras" later in this chapter).
Sounds played via sound playFile behave similarly to linked sounds, although they need not be imported at all.
The path to external sounds as indicated by the fileName or streamName of member updates automatically for the current platform if the sound was imported via File
Import or inserted via Insert
Media Element
Shockwave Audio in D7. Assuming that the external sound file remains in the same position relative to the movie or castLib and that the fileName or streamName is valid for the current platform, Director 7 will find the external audio file. However, the path to SWA files inserted via Insert
Media Element
Shockwave Audio in D6 (as indicated by the streamName of member) will not update automatically when files are moved, even if the same relative positions are maintained. See for the solution.
Place external sound files close to the appropriate Director movie when burning a CD to reduce the seek time (and latency) for accessing external sounds.
Differentiating between a sound's type and the playback method
In most cases, a sound's format or cast member type dictates whether it will be internal or external, but a standard sound cast member can be either. However, a cast member's or sprite's type (#sound, #SWA, #digitalVideo, or #quickTimeMedia) will determine which commands support it. For example, puppetSound and the Score Sound channels support only #sound cast members (linked or unlinked). See Table 15-4 for a comparison of Lingo commands used with the different sound formats.
So-called "streaming" sounds are not necessarily located on a remote server. All external sound files are streamed, whether from the Internet, CD-ROM, or hard drive. Likewise, although SWA compression is usually associated with streamed Internet audio, SWA sounds can be streamed from a local drive, and internal Director sounds can be SWA-compressed, in which case they are not streamed.
Sound Playback Methods
Your presentation will probably use more than one method to play sounds. They can be combined, subject to these limitations:
- Sound channel conflicts
- Each sound channel can play only one sound at any time. You can't use Sound channel 1 in the Score while simultaneously using sound playFile or puppetSound to also play a sound in channel 1.
- Sound device or sound driver conflicts
- Only one device or driver can access the sound card at any given time. Under Windows, because QuickTime and Director audio often play through different mechanisms, the two types of audio cannot always be combined. See "Sound Mixing Under Windows" later in this chapter. The Macintosh handles multiple sound sources transparently, but even there, Director can not access the data track of a CD while a RedBook audio Xtra is accessing RedBook audio tracks on the same CD.
Sound in the Score
Sound cast members are placed in one of the two Sound channels of the Score. SWA and digital video (DV) cast members, including audio-only QuickTime movies, are placed in sprite channels, not the Sound channels.
Score-based sounds do not play unless the Score's playback head is moving or looping in a frame (avoid the pause command). Because Director's frame rate is not exact, you should use cue points to synchronize sounds with Score animations.
Sound playback is not affected by the Tempo channel's frame rate setting or the puppetTempo command. Standard and SWA sounds always play back in real time, although the speed of a DV sprite, including the audio tracks, can be changed via the movieRate of sprite. (Slower playback lowers the pitch of the audio track; faster playback raises the pitch.)
Sounds in the Score Sound channels
Score Sound channels are best used for fixed sounds that accompany animations, but the triggering and synchronization of Score sounds is insufficient for lip-synching or other time-critical uses.
Sounds in the Score are triggered when a sound is first encountered in a Sound channel or an SWA or DV sprite span is encountered in a sprite channel. Sounds ordinarily terminate after playing once through, even if they are tweened out over additional frames. To re-trigger a sound, you must either use Lingo or create a break of at least one empty frame in the Sound channel. Internal sounds that are looped will play as long as they occupy a sound channel or until the Tempo channel's Wait for Cue Point: End option causes them to "play out."
puppetSound
Use puppetSound to trigger a sound cast member (whether linked or unlinked) at an arbitrary time, such as in response to button-clicks or timeouts. PuppetSounds played in channels 1 and 2 override the corresponding Score Sound channel. Use:
puppetSound channel, "soundMemberName"puppetSound channel, member "whichMember" {of castLib whichCast}where channel is a number from 1 to 8. If channel is specified, the sound will trigger immediately. Otherwise, the default channel is 1, and the puppetSound is not triggered until the playback head advances (or loops) or an updateStage command is issued. Here, the default channel 1 is assumed:
puppetSound "soundMemberName"puppetSound member "whichMember" {of castLib whichCast}Specifying 0 as the "sound" unpuppets a puppetSound. Unpuppetting halts the current puppetSound; unpuppetting channel 1 or 2 also returns control to the corresponding Score Sound channel. These commands unpuppet a sound channel:
puppetSound channel, 0puppetSound 0 -- Unpuppets sounds channel 1 by defaultSound playFile
The sound playFile command streams an external AIFF, AIFC, or WAVE file from disk, similar to a linked sound cast member. The sound need not be imported into the Cast nor appear in the Score, but it must reside on disk. Sound playFile can play a file at a remote URL, but it does not support SWA files, so you should use linked SWA cast members for net-based sounds. If you choose to play a remote AIFF or WAVE, the file should be downloaded first with downloadNetThing.
Using sound playFile with channel 1 or 2 overrides the corresponding Score Sound channel, but control automatically returns to the Score when the sound terminates. Sound playFile even overrides puppeted sound channels. Sound playFile assumes that the external sound file has an .AIF extension, if none is specified. It takes the form:
sound playFile channel, soundFilePath | urlwhere channel is from 1 to 8. If the channel is omitted, channel 1 is assumed:
sound playFile 1, the moviePath & "mysound.aif"sound playFile 3, "http://www.zeusprod.com/examples/sound.wav"The path to the external file specified by sound playFile does not update automatically. You must manually specify the path on each platform, as shown in Example 15-1, or use the
@operator to create a generalized path. Note that we constructed a path relative to the current movie's location.
Example 15-1: Specifying a Path to a Sound if the platform contains "Windows" thensound playFile 1, the moviePath & "audio/mysound.aif"elsesound playFile 1, the moviePath & "audio:mysound.aif"end ifExample 15-2 shows how to construct a central convenience function to play voice-overs from a subfolder named VO, and ambient sounds from a subfolder named AMBIENT, each below the folder containing the current movie.
Example 15-2: Centralized Sound PlayFile Commands on playVoiceOver someSound-- Play voice-overs in channel 1set pathSeparator = the last char of the moviePathsound playFile 1, the moviePath & "VO" & ¬pathSeparator & someSound & ".AIF"end playVoiceOveron playAmbient someSound-- Play ambient sounds in channel 2set pathSeparator = the last char of the moviePathsound playFile 2, the moviePath & "AMBIENT" & ¬pathSeparator & someSound & ".AIF"end playAmbientIn Example 15-2, the sound files are assumed to have an .AIF extension and reside in the VO or AMBIENT subfolder. When using these routines, we can specify sound filenames without the .AIF extension or the folder name, such as:
playVoiceOver ("intro")playAmbient ("mood")As with all external sound playback, sound playFile is appropriate for long sounds. Such sounds won't automatically loop; you must use sound playFile again to retrigger them.
Digital video sounds
Digital video (DV) cast members are played in sprite channels, not the Sound Score channels, and may contain audio tracks (#sound or #midi) even if no #video track is present. DV (QT or AVI) provides better synchronization than other audio playback methods, provided that the audio and video being synchronized are properly interleaved in a single DV file. See Chapter 16, Digital Video, for complete details.
DV sprites, including their audio tracks, are played automatically when a DV sprite is encountered, provided that the pausedAtStart of member is
FALSE. Lingo commands can start, stop, rewind, or fast forward to any point in the DV file. DV files, which are always external, can be played at different speeds or even backward. But DV audio may not be playable simultaneously with other standard Director sounds under Windows. See "Sound Mixing Under Windows" later in this chapter.Shockwave Audio (SWA)
SWA cast members are played in sprite channels, not the Sound Score channels. Shockwave audio offers high quality at low bandwidths, but requires more processing power at runtime and isn't supported on some low-end machines. (SWA compression requires a Pentium or PowerMac.) SWA requires several Xtras (see Table 15-13) that must be distributed with your Projector. If using SWA from Shockwave 6 or 7, the Xtras are included with Shockwave browser plug-in.
Flash audio
Audio can be added to a Flash cast member prior to import into Director, but Flash-based audio is low-fidelity and may conflict with Director. (Flash-based audio and Director-based audio can't play at the same time under Windows.) Instead, trigger Director-based sounds from your Flash sprite, offering Lingo control over volume, better integration with other Director sounds, and optional SWA compression.
Sound Operation Comparison
Table 15-4 compares the inconsistent sound control commands across the different sound-related cast member types. Digital Video includes AVI and QuickTime prior to version 3 (QuickTime 2.5 on Macintosh or QuickTime 2.1.2 under Windows). QuickTime 3 requires the new QT3 Asset Xtra in D6.5 or D7. See also Chapter 16, the digitalVideoType of member, and Table 4-10.
External files played via sound playFile do not support any sprite or member properties. They obey only the SoundBusy( ), sound level, sound stop, and sound close commands.
Table 15-4: Common Sound Operations Operation
Sound
SWA or MP[12]
QuickTime 3 or Digital Video
Type of member
#sound
#SWA
#digitalVideo or #quickTimeMedia
Number of channels in asset
channelCount of member
numChannels of member
trackCount( ), trackType = #sound
Specify sound channel
Place in Score or puppetSound or sound playFile
soundChannel of member (0 assigns highest)
Allocated by OS
Volume[10]
volume of sound
volume of member, volume of sprite
volume of sprite, sound of member, volumeLevel of sprite
Play in Score
Sound channel
sprite channel
sprite channel
Play via Lingo
sound playFile, puppetSound
play ( )
Stop a sound
sound stop, puppetSound 0, sound close
stop( ), pause( )
set movieRate of sprite = 0, or set mRate of sprite = 0
Sound playing
soundBusy( )
state of member = 3
movieRate of sprite, mRate of sprite, pausedAtStart of member
Wait for sound[11]
soundBusy( )
state of member
movieRate, movieTime, mRate, or mTime of sprite[12]
Samples per second
sampleRate of member
sampleRate of member, bitRate of member
Not available
Bits per sample
sampleSize of member
bitsPerSample of member
Not available
Current position
currentTime of sound
percentPlayed,
percentStreamed, and currentTime of spritemovieTime, mTime, or currentTime of sprite
Length in seconds
See Example 15-3
duration of member × 1000
duration of member × the digitalVideoTimeScale
There is no duration of member property for standard sound cast members. Example 15-3 calculates the duration of a sound based on its other attributes. The size of member property is accurate only for internal (embedded) sounds, but can be calculated for external sounds (see Examples and ).
Example 15-3: Calculating the Duration of an Internal Sound on soundDuration whichSound-- Returns the duration in secondsset duration = the size of member whichSound / ¬(the sampleRate of member whichSound * ¬the channelCount of member whichSound * ¬the sampleSize of member whichSound / 8.0)return durationend soundDurationSound Channels and Sound Mixing
Director supports up to eight sound channels, although only two are shown in the Score. The remainder are accessible via puppetSound or sound playFile or are used implicitly by SWA sprites, film loops, and MIAWs (which all share the same sound channels). Digital video and Flash sprites do not use the same sound channel numbers as standard Director sounds.
Director's Score Sound channels do not correspond to the left and right channels of a typical stereo. Monaural sounds are split equally between the left and right speakers regardless of the Director sound channel used. A so-called stereo sound uses only one of Director's sound channels because the left and right audio tracks are interleaved into a single data stream (think of Director's sound channels as data channels, rather than audio channels). The sound card knows how to split a stereo data stream between the right and left speakers, but a sound's left/right balance can not be set in Director without an Xtra (or you change the balance using an external sound editor before importing into Director).
Avoid sound channel number conflicts by simply specifying different channel numbers for puppetSounds or sound playFile commands (both use channel 1 by default, which will override the Score's Sound channel 1). If the soundChannel of member of an SWA member is 0 (the default) it automatically sidesteps conflicts by using the highest available channel number.
Most Macintoshes support eight sound channels, although older Performas may support only four. On the Macintosh, all sound playback is handled seamlessly by the Sound Manager, which is a QuickTime component. You can play almost any type or number of sounds without regard to conflicts at the Mac OS level.
The number of audio channels supported under Windows is generally at least four, but even assuming that you have not used conflicting channel numbers, other audio sources (digital video and Flash) can cause conflicts at the so-called Windows device level.
Sound Mixing Under Windows
Windows PCs have only one hardware sound channel. Multichannel sound is simulated by premixing multiple audio sources before sending the resultant audio stream to the sound card. There are a number of competing and complementary sound drivers, mixers, and devices that ameliorate the latency and conflicts arising from playing multiple sounds under Windows. The best method and achievable results vary with the software configuration, Windows version, and Director version. For an overview of sound mixing under Windows, see Macromedia TechNote #03191, "Windows and Multichannel Sound."
Sound mixing latency
Playing two or more sounds simultaneously under Windows may cause a delay as the sounds are mixed together for output. Sound latency varies with the sound card, but can be up to 500 milliseconds. To reduce latency:
- Play only one sound at a time (zero latency).
- Preload short sounds, if possible.
- Use uncompressed sounds (not SWA or IMA-compressed).
- Use one of the preferred PC sampling rates (11.025, 22.050, or 44.1 kHz) and not the variations that are Macintosh-specific (see Table 15-1).
- Use sounds of the same bit depth and sampling rate. The suggested sound format is 16-bit, 22.050 kHz, mono in most cases.
- Avoid changing the volume or performing sound fades when using multiple sounds.
- Combine the sounds in an external sound editor before importing into Director.
- Use a sound mixer with less latency, such as QT3Mix in D7, the DirectSound mixer (new in D7.0.1), the Beatnik Xtra, or MacroMix with RSX/DirectSound (in D6.x)
Sound output devices
Before we talk about audio sources, understand that there are two mutually exclusive sound output "devices" under Windows 95/98/NT: WaveOut and DirectSound ("device" refers to a virtual device driver, not the physical sound card). Only WaveOut is supported under Windows 3.1. DirectSound (part of the DirectX suite of Microsoft drivers) comes standard with later versions of Windows 98, and has been installed by many users on other Windows 95/98 systems. The latest version can be downloaded from http://www.microsoft.com. Windows NT supports the older DirectSound 3, which behaves as if the sound device is WaveOut.
All Windows audio must pass through one of these two devices, which sends the data onto the sound card driver and eventually the sound card itself. The sound output device can change dynamically at runtime, although only one device can be active at a given time. (Some IBM PCs support two simultaneous sound devices, but you can not rely on this unless all users have identical equipment.)
TIP:
WaveOut supports only one input at a time. DirectSound 5 or later under Windows 95/98 can handle multiple simultaneous inputs. Windows NT with Service Pack 3 uses DirectSound 3, which, like WaveOut, supports a single input only.
Macromedia TechNote #13249, "Director sound playback mixing under Windows" contains detailed information (mainly regarding D6.5) on the differences between sound mixing under Windows 95/98 and Windows NT. It includes a helpful overview and informative diagrams of WaveOut and DirectSound mixing schemes:
http://www.macromedia.com/support/director/ts/documents/d6_sound_mixing01.htmPrior to Director 6, all Director sounds used WaveOut; although there was competition among multiple sources for the WaveOut device, there was not contention between the WaveOut and DirectSound devices (unless another application was using DirectSound).
Director 6 introduced support for RSX/DirectSound in addition to WaveOut. To reduce latency, D6.x Projectors keep the current device loaded even after a sound completes, unless specifically configured to release the device. If your sounds play during authoring but not in a Projector (and it is not caused by a missing Xtra) use the following to "offer-up" the device to WaveOut following playback via DirectSound, or vice versa:
set the soundKeepDevice = FALSEEven if the soundKeepDevice is
FALSE, the device is not released until all previously playing sounds complete. Set it toTRUEto decrease latency if only one output device is being used (see the following sections to determine whether WaveOut, DirectSound, or both are used by your Projector).Potential conflicts from multiple sound input sources
Consider the following sources (classes) of audio used in Director for Windows and the sound mixing mechanism they use:
- Director sounds
- Standard #sound and #SWA sprites in the Score, puppetSounds, and WAVE and AIFF sounds played via sound playFile commands are considered "Director sounds." These are always passed through Director's sound mixer (either MacroMix or QT3Mix) and may be played either via WaveOut or DirectSound as described under "Windows Sound Mixers." D7.0.1 can also use DirectSound via the new DirectSound mixer.
- Flash sounds
- Sounds embedded in #flash members are always played via WaveOut and do not pass through Director's sound mixer.
- VFW and QTW2 audio tracks
- Audio tracks contained in #digitalVideo members imported via File
Import in D6.5 or earlier are known as "Traditional DV sounds." These are always played via WaveOut and do not pass through Director's sound mixer or the QuickTime for Windows Sound Manager.
- QTW3 or later sound tracks
- Sound tracks contained in QTW3 #quickTimeMedia members imported via File
Import (in D7) or inserted via File
Insert Media Element
QuickTime 3 (in D6.5 or D7) are known as "QT3 sounds." These are always played via the QuickTime for Windows Sound Manager, which sends the audio to either DirectSound or WaveOut based on the Sound Out setting in the QuickTime Control Panel.
- Third-party Xtras
- Third-party Xtras may use their own sound mixer, Director's sound mixer, the QuickTime Sound Manager, or some combination of the three. (Beatnik uses MacroMix or its own sound mixer, but not the QTW Sound Manager.)
Playing multiple sounds of a single class is always supported, but may cause latency as they are mixed. Sound conflicts (where the second sound never plays) arise primarily from playing sounds of different classes under the following conditions:
- Playing sound from multiple sources to WaveOut under any Windows version. Director-based sounds in Windows 3.1, Flash-based sounds, and traditional DV audio (#digitalVideo sprites) can never be mixed with each other or with QTW3 (#quickTimeMedia) sprites.
- Playing sound from multiple sources to DirectSound 3 (which is the highest version supported under Windows NT).
- Playing sound to one device (WaveOut or DirectSound) when the other is actively playing a sound or "locked in" because the soundKeepDevice is
TRUE(the default).
- Conflicts with the sound output of other applications. (See Macromedia TechNote #12180, "How does Director's use of sound on Windows affect other applications?")
There are several ways to avoid conflicts:
- Avoid playing sounds from a second source before sounds from the first source have completed. This allows Director to switch the sound device as needed, provided that the soundKeepDevice is FALSE.
- Use DirectSound 5 or later, which handles multiple input streams, as the output device for all sounds. In D6.x this requires that RSX and DirectSound 5 or later be installed and, if using QT3 sounds, that the QuickTime Control Panel specify DirectSound for Sound Out. This scheme will not work in D7.0, because RSX/DirectSound output is not supported for D7.0 sounds, nor will it work in D6.5 if the QuickTime Control Panel uses WaveOut, nor will it work under Windows NT with DirectSound 3 or under Windows 3.1. D7.0.1 with DirectSound 5 or later installed can use Macromedia's new DirectSound mixer without the need for RSX.
- Manually specify that Director should use QT3Mix, which sends sounds to the QuickTime Sound Manager where they can be mixed with QTW3 audio into a single stream before being sent to either the WaveOut or DirectSound device. (This requires a Windows 32 system with QTW3 installed and D6.5 or D7.)
Windows Sound Mixers
Sound mixers are a middle layer that mix multiple sound channels or input sources into a single data stream to be sent to the output device. The mixer for Director sounds is the only one that can be changed--QuickTime 3 sprites always play via the QuickTime Sound Manager, and other non-Director sounds always play directly to the WaveOut device (bypassing Director mixing).
Sound mixing with MacroMix
MacroMix transparently mixes multiple #sound, #SWA cast members, AIF and WAV files under Windows, but doesn't mix audio tracks from #flash, #digitalVideo, or #quickTimeMedia cast members.
MacroMix automatically configures itself based on the current sound card, although the settings in the DIRECTOR.INI file (see Table 15-11) can customize it. In most cases, the default MixMaxFidelity (99) is appropriate. The maximum number of mixable channels is determined by MixMaxChannels (the default is 4 in prior versions, and 8 in D7). See Appendix D in Lingo in a Nutshell. for details on working with the DIRECTOR.INI file.
Windows 3.1 Projectors always uses the 16-bit MacroMix.DLL to play sound. This DLL is bundled into Windows 3.1 Projectors (assuming that it is present when the Projector is built). It is unbundled temporarily into the Windows System folder at runtime and deleted when the Projector terminates.
MacroMix and other mixers for Windows 95/98/NT Projectors are implemented as Xtras in D7 and can be configured via Lingo at runtime. D6.5 and prior versions of Windows 95/NT Projectors used an internal version of MacroMix, which could be overridden using the DLLname option in the DIRECTOR.INI file in D6.5. (Except for the DLLname, all [Sound] settings in DIRECTOR.INI pertain only to MacroMix, and not to QT3Mix.)
In Director 4 through Director 6.0.2, MacroMix was the only sound mixer available under Windows. MacroMix is not a single mixer, it is a Sound API (application programmer's interface). The actual mixer used by MacroMix depends on the Director version and software configuration. D4, D5, 16-bit Projectors in D6, and D7 support only the WaveMix implementation of MacroMix. In D6.0 through D6.5, when using 32-bit Projectors, MacroMix uses its RSXMix implementation if RSX is installed.
- WaveMix
- An implementation of MacroMix that uses WaveOut. It is a lowest common denominator mixer to ensure that multiple sounds can be mixed without requiring RSX, DirectSound, or QTW3, but it is characterized by latency and potential conflicts with other sound sources. To combat latency, refer to the tips under "Sound Mixing Latency." You may choose to initiate the sound early to make it play on time under Windows (in which case it would play early on the Macintosh). The 16-bit version of WaveMix is located in the MacroMix.DLL file. In D7, the 32-bit version is stored in MacroMix.X32.
- RSXMix
- An implementation of MacroMix that uses RSX, available only in Director 6.x. The system-level RSX service will use DirectSound if installed. It will use WaveOut if DirectSound is not installed or if rsxDontUseDirectSound is set to 1 in the DIRECTOR.INI file. RSX with DirectSound offered low latency but was tempermental, especially prior to D6.0.2, and not all users have RSX and DirectSound properly installed. RSXMix is not supported in D7.0 or later, but D7.0.1 includes a separate DirectSound mixer that does not require RSX.
- QMix
- A QT3-based mixer (typically referred to separately as QT3Mix) and described in the next section.
For more details on MacroMix, see Macromedia TechNote #13010, "How does Director play sound on Windows?" (pertains primarily to D6.5).
Sound mixing with QT3Mix
QT3Mix uses the QuickTime Sound Manager to mix Director sounds and requires that QTW3 (or the upcoming QTW4) be installed. QT3Mix is available only in D7 and D6.5 with the Service Pack installed, and is referred to as "QMix" in some Macromedia TechNotes.
The QuickTime Sound Manager will use DirectSound (if it is installed) under Windows 95/98; it uses WaveOut if DirectSound is missing or if running under Windows NT. The user can also set the preferred Sound Out device in the QuickTime Control Panel (and some developers report better results using WaveOut). There is no documented way to detect or switch the QuickTime Control Panel setting, but it is contained in the QuickTime Preferences file (C:\Windows\System\QuickTime.qtp) if you want to hack it.
QT3Mix allows Director and #quickTimeMedia sounds to play simultaneously under Windows 95/98/NT. QT3Mix is contained in the QT3Asset.X32 Xtra in D7, and the QT3Mix.DLL in D6.5 with the Service Pack. QT3Mix is the recommended (but not the default) mixer in D7.0. The D7 version of QT3Mix is much-improved over the D6.5 version, offering near-zero latency on faster computers (and reduced latency on slower Pentiums). See the following sections for complete details on activating QT3Mix under D6.5 and D7. In D7.0.1, if DirectSound 5 or higher is installed under Windows 95/98, the new DirectSound mixer should yield better performance than QT3Mix.
There is no need to change your Lingo when using QT3Mix instead of MacroMix. All sounds are played with the same familiar commands and methods.
QT3Mix is not supported under Windows 3.1 or with 16-bit Projectors under Windows 95/98/NT because they do not support QTW3. QT3Mix ignores the [Sound] settings in the DIRECTOR.INI file (except for the DLLname option).
RSX and DirectSound
RSX is a system-level service for Windows 32 systems from Intel. Obtain the latest version of RSX (http://www.intel.com/ial/rsx/) for best results when using D6.x. To determine whether RSX is installed, look for the C:\Windows\System\RSX.DLL file. If RSX is enabled, a pair of red headphones appears in the Windows Start Menu tray.
DirectSound is a Microsoft sound driver that is part of the DirectX driver suite (which includes Direct3D, DirectDraw, etc.) and is not related to Director, per se. DirectSound version 5 or later is installed under Windows 98 by default, and most Windows 95 users have it too. DirectSound is compatible with Windows NT, but only up to DirectSound 3, which is implemented in software and has the same problems as WaveOut (latency and only one input source allowed). DirectSound is never supported under Windows 3.1.
D6.x required RSX to use DirectSound, and D7.0 never uses it. D7.0.1's new DirectSound mixer will use DirectSound without RSX.
Sound mixing with the Beatnik Xtra
The Beatnik Xtra (http://www.headspace.com) provides near-zero latency mixing with extremely low CPU overhead under both Macintosh and Windows, plus it includes sound effects, sound panning, support for additional sound formats (RMF, MIDI, and MOD in addition to AIF, WAVE, and AU) and much more.
The Beatnik Xtra is "Shockwave-safe" and is appealing for Shockwave delivery because it supports extremely compact sound formats for fast downloading and does not require RSX, QTW3, or DirectSound to be installed.
The major drawback is the licensing fee (which ranges from $495 to $1295 at press time, but may change) as you are not allowed to distribute the Lite version included with D7. Unlike QT3Mix, the Beatnik Xtra requires custom calls to play sounds, although the pro version includes premade Behaviors to play sounds.
Beatnik optionally uses the custom Headspace Audio Engine mixer (up to 32 channels without latency) or MacroMix (up to eight channels), but doesn't currently support QT3Mix or the QuickTime Sound Manager. Its MacroMix compatibility mode enables Beatnik audio to be intermixed with normal Director audio including SWA, sound playFile commands, and puppetSounds.
Sound Mixing Under Director for Windows
Table 15-5 summarizes the preferred sound mixer configurations under Windows for both Director and Shockwave if you are playing multiple sounds. It is a matter of considerable dispute whether the RSX/DirectSound combination available in D6.X is the preferred method of mixing sound. If RSX and DirectSound are installed properly, it works well, but some well-respected developers prefer using QT3Mix in D6.5, and using WaveOut by disabling RSX in D6.0.X.
Table 15-5: Preferred Sound Mixer Configurations Environment
MacroMix and DirectSound
QT3Mix
D4, D5, SW4, SW5
N/A
D6.0.x, SW6.0
N/A
SW6.0.1
WaveOut only (RSX ignores DirectSound)
N/A
D6.5 without Service Pack
Buggy, don't use.
Buggy, don't use.
D6.5 with Service Pack
DLLname = QT3Mix.DLL[15]
D7.0, SW7.0
WaveOut only[16]
the soundDevice = "QT3Mix"1,[15]
D7.0.1, SW7.0.1
WaveOut (the soundDevice = "MacroMix")
DirectSound1 (the soundDevice = "DirectSound")
the soundDevice = "QT3Mix"3
MacroMix is the default mixer for Director-based sounds (#sound, SWA, AIFF, and WAVE files) in all versions of Director for Windows prior to D7.0.1. But its capabilities, whether it is the best method of mixing sounds, and how to override it varies with each version. Even if using a later version of Director, you'll find the following descriptions of sound mixing in earlier versions relevant.
Sound mixing in Director 4 and Director 5 for Windows
Director 4 and 5 always use MacroMix for Director-based audio. MacroMix will mix up to 8 Director sounds (the default is 4 in D4, D5, and D6.x), but exhibits marked latency in D4, D5, and D7. Traditional #digitalVideo sound tracks (QTW2 and AVI files) can not play simultaneously with Director sounds (AIFF, WAVE or sound cast members) in any version of Director for Windows, and are limited to one sound track per video.
In Director 4 and 5, #digitalVideo and Director sounds conflicted because both types use WaveOut. Whichever type took control of the WaveOut device first prevented sounds of the other type from playing. When one component finished playing its sounds, the other component could gain access to the WaveOut device.
Therefore, to allow a new type of audio to play, ensure that all sounds of the other type are stopped (see Table 15-4). Use the puppetSound 0, sound close, or sound stop commands to stop all Director sounds before attempting to play #digitalVideo sound tracks. Stop a video by setting the movieRate of sprite to 0, or disable its sound track using the sound of member property or setTrackEnabled command before attempting to play other Director sounds.
These limitations don't necessarily apply in D6, which can use DirectSound, or in D7 which doesn't typically use #digitalVideo members (#quickTimeMedia members are preferred).
Sound mixing in Director 6.0.x for Windows
Even in D6, Windows 3.1 Projectors always use the WaveMix implementation of MacroMix to play sounds to WaveOut, and therefore exhibit marked latency and conflicts with #digitalVideo audio (which uses WaveOut, as in D4 and D5).
For D6.x Windows 95/NT Projectors, the RSXMix implementation of MacroMix will be used if RSX is installed. RSXMix reduces latency substantially in the typical case where a button triggers a sound while a background track is playing. Absent RSX, the older WaveMix implementation (with the familiar latency and device conflicts) will be used.
Even RSXMix will resort to using WaveOut if DirectSound is not installed, but the RSX/DirectSound combination has the lowest latency (best performance). The performance is maximized by never releasing the DirectSound device (locking out #digitalVideo sounds, which always use WaveOut). To force RSX/DirectSound to release the sound device, you must set the soundKeepDevice to
FALSE.Some conflicts were reported between Director and RSX, especially prior to D6.0.2. If using D6.0 or D6.0.1, obtain the free update to D6.0.2 from Macromedia's site. RSX will use DirectSound by default, but because RSX and DirectSound have been plagued by installation and version issues, you can force RSX to use WaveOut (with reduced performance) by including the following line in the [Sound] section of your DIRECTOR.INI file:
[Sound]rsxDontUseDirectSound = 1Sound mixing in Director 6.5 for Windows
D6.5 was the first version to allow the developer to manually choose the mixer used for Director-based sounds. It allows you to specify QT3Mix using the DIRECTOR.INI file during Projector initialization.
WARNING:
If using D6.5, obtain the D6.5 Service Pack Update from: http://www.macromedia.com/support/director/upndown/updates.html.
The initial release of D6.5 (prior to the Service Pack) included an erroneous version of QT3Mix (a.k.a. "QMix"), mistakenly named "MacroMix.DLL." For Windows 3.1 Projectors, the bogus file overrode the default 16-bit MacroMix.DLL and prevented all sound from playing. Windows 95/NT Projectors ignored the external DLL and continued to use their internal version of MacroMix, but mistakenly set the soundLevel to 0.
The Director 6.5 Service Pack (unrelated to Windows 95/98/NT OS Service Packs) addresses the sound errors caused by the initial release of D6.5. It includes the same 16-bit MacroMix.DLL used in D6.0.2, and a copy of the correct 32-bit QT3Mix.DLL that is recognizable by Windows 95/NT Projectors.
QT3Mix allows Director and QT3 (#quickTimeMedia) sounds to be mixed together via the QuickTime Sound Manager regardless of the Windows 32 version or Sound Out setting in the QuickTime Control Panel. Unfortunately, it requires QTW3, still exhibits some latency, and can not mix #digitalVideo and #flash sounds. (See also Macromedia TechNote #13416, "Director 6.5 sound playback options, by cast member type.")
To use QT3Mix in D6.5+SP, include the following line in the [Sound] section of your DIRECTOR.INI file (or just remove the semicolon that acts to comment it out):
[Sound]DLLname = QT3Mix.DLLInclude the QT3Mix.DLL file, and a copy of DIRECTOR.INI renamed to match your Projector's name, in the same folder as your Windows 95/98/NT Projector. If QTW3 isn't installed, no DLLname is specified, or QT3Mix.DLL does not accompany the Projector, QT3Mix will not load and MacroMix will be used instead.
The RSX/DirectSound combination has lower latency (better performance) than QT3Mix in D6.5. It allows QTW3 and Director sounds to play simultaneously under Windows 95/98 (but not Windows NT) if the QuickTime Control Panel specifies DirectSound as Sound Out (the default if it's installed). In this case, the two input sources are mixed by DirectSound instead of by the QuickTime Sound Manager.
Even if RSX and DirectSound are installed, setting the rsxDontUseDirectSound flag to 1 in the DIRECTOR.INI file, or configuring the QuickTime Control Panel to use WaveOut, would prevent Director sounds from mixing with QTW3 sound tracks if not using QT3Mix.
Sound mixing in Director 7.0 for Windows
Sound mixers are implemented as Xtras in Director 7, but should not be confused with the unrelated MIX Xtras used to import external media. At least one of the sound mixer Xtras must be included in the Xtras folder or bundled into the Projector in order to play sound in D7 under Windows. D7 allows sound mixers to be specified on the fly, whereas D6.5 configured the sound mixer during Projector start up only.
D7.0 includes two initial sound mixers for Windows: an implementation of MacroMix that always uses WaveOut, and QT3Mix (which uses DirectSound or WaveOut depending on the SoundOut setting in the QT3 Control Panel). D7.0.1 includes a third sound mixer, DirectSound, which offers improved mixing if DirectSound 5 or higher is installed. Unlike D6.x, D7.0.1 does not require RSX to access DirectSound; D7.0 and D7.0.1 ignore RSX in all cases.
MacroMix is contained in the Xtras\Drivers\MacroMix.X32 Xtra. QT3Mix is contained in the Xtras\QT3\QT3Asset.X32 Xtra and can be used to mix sounds even if you are not playing any QuickTime videos. The DirectSound mixer is contained in the Xtras\Drivers\DirectSound.X32 Xtra included with D7.0.1.
There are two new properties related to sound mixing in D7--the soundDevice and the soundDeviceList--that affect the sound mixer selection, and thus indirectly affect whether the WaveOut or DirectSound device is used.
The soundDeviceList is a read-only list of the installed sound mixer Xtras:
put the soundDeviceList-- ["MacroMix", "QT3Mix", "DirectSound"]If no sound mixer Xtras are installed, the soundDeviceList returns an empty list. Although they may appear in the soundDeviceList, QT3Mix can not be used unless QTW3 is installed, and the DirectSound mixer cannot be used unless an appropriate version of the DirectSound drivers are installed. MacroMix, which doesn't depend on any system components, is always available if the MacroMix.X32 Xtra is installed.
Use the soundDevice property to identify or set the current sound mixer. The default mixer depends on the installed Xtras and system components. In D7.0, before DirectSound mixing was offered, the default sound mixer was MacroMix, followed by QT3Mix if MacroMix was not installed. In D7.0.1, DirectSound is the default mixer if the DirectSound 5 drivers or higher are installed. If not, MacroMix becomes the default mixer, because older versions of the DirectSound drivers (such as DirectSound 3 under Windows NT) offer no benefit over MacroMix. If none of the necessary Xtras and system components are installed, the soundDevice will be 0, and sounds will not play.
TIP:
When the soundDevice defaults to "DirectSound," it will offer the best available sound mixing. If the soundDevice defaults to "MacroMix" because DirectSound 5 is not installed, switching the soundDevice to "DirectSound" may kill sound playback if the DirectSound drivers are old or improperly installed.
If QTW3 is available, but DirectSound 5 or higher is not, setting the soundDevice to "QT3Mix" may be preferable to the default MacroMix mixer. QT3Mix provides reduced latency and conflict-free mixing of frame sounds, puppetSounds, sound playFiles, SWA, and QT3 sound tracks, regardless of whether RSX or DirectSound is installed. There may be a one-time delay of several seconds when changing the soundDevice to "QT3Mix." Use the following in D7.0.1 to take advantage of QT3Mix in the above scenario:
if the soundDevice = "MacroMix" and the quickTimePresent ¬and string (the soundDeviceList) contains "QT3Mix" thenset the soundDevice = "QT3Mix"end ifThis example will work in both D7 and SW7 on all platforms. It will leave DirectSound as the default mixer if DirectSound 5 or later is installed, or attempt to load QT3Mix otherwise. It has no effect on the Macintosh. The checks in the example for the quickTimePresent and QT3Mix's presence are extraneous; setting the soundDevice to an unavailable mixer leaves its value unchanged (in some cases it may set the soundDevice back to its default). You can verify the soundDevice after attempting to set it.
The Modify
Movies
Xtras dialog box includes the MacroMix.X32 Xtra by default in D7. Although new movies created in D7.0.1 will also include DirectSound.X32 by default, you may need to add it manually to the list of Xtras when upgrading movies from D7.0 to D7.0.1. Although the sound mixer Xtras are for Windows-only you should not remove them from the Xtras list, even on the Macintosh.
On the Macintosh, the only supported sound mixer is the MacSoundManager, which uses the Sound Manager system extension:
put the soundDevice-- "MacSoundManager"put the soundDeviceList-- ["MacSoundManager"]Sound mixing in Shockwave 6 and Shockwave 7
SW6.0 uses RSX with DirectSound to speed sound mixing, if available, and WaveOut otherwise. But very few users have both RSX and DirectSound properly installed, so sound latency and conflicts were common. SW6.0.1 uses RSX (if available) but always uses the WaveOut sound device, even if DirectSound is installed. SW6.x never uses QT3Mix and does not allow the developer to select the sound mixer manually.
SW7.0 and SW7.0.1 never use RSX. SW7.0 includes the MacroMix.X32 sound mixer in the default installation. In SW7.0, you can set the soundDevice to "QT3Mix" to reduce latency, provided that both the QT3Asset.X32 Xtra and QTW3 are installed. But the QT3Asset.X32 Xtra must be downloaded separately, and there is no convenient way to provide a QTW3 installer to Shockwave users (as there is when shipping a CD-ROM).
The DirectSound.X32 Xtra offers improved sound mixing in SW7 if DirectSound 5 or higher is installed (as it is on most Windows 95/98 systems, but not Windows NT). Set the Download if Needed checkbox under Modify
Movie
Xtras to auto-download the DirectSound.X32 Xtra for SW7.0 users (it is downloaded by default with SW7.0.1).
You can also use the Shockwave-safe Beatnik Xtra to mix sounds, as it doesn't require QTW3 or DirectSound, although it does have a licensing fee.
Controlling Sound Position and Playback
Director does not allow random access to any position within most sounds. SWA sounds can be paused and restarted, but AIFF, WAVE, and internal sounds always start from the beginning whenever played. They can be stopped, but not paused or cued. However, audio-only QuickTime or AVI movies allow full control over sound positioning and playback.
Cue points can be used for synchronization, but they are read-only. You can't jump to an arbitrary point in a AIFF or SWA file (although, see the wildly unsupported setSoundTime command in Table 15-14), but you can jump to an arbitrary point in a QuickTime or AVI movie. (MCI calls can be used to set an arbitrary location in a WAVE file under Windows, but it is not universally reliable.)
See Table 15-4 for commands to position sounds.
Sound Tools and Interface Options
Table 15-6 summarizes the interface options related to sounds.
Table 15-6: Sound-Related Interface Options Action
Command
Edit or play the sound cast member in the external editor
File
Preferences
Editor (AIFF, MPEG3, snd, AU, SWA, WAVE) Edit
Launch External Editor
Command-, (Mac) or Ctrl-, (Windows)
View or edit a sound cast member's properties
Modify
Cast Member
Properties
Double-click a sound cast member or sprite.
Import sound
File
Import
Sound (see Table 4-4)
Record a new sound (Mac only)
Insert
Media Element
Sound
Import SWA sound
Insert
Media Element
Shockwave Audio (retains SWA format)
File
Import
Sound (D7; converts to non-SWA format)
Export Sound
Copy to Clipboard, or use Edit
Launch External Editor, then save from your sound editor.
Export sound channels
Under File
Export, use Format: QuickTime Movie, then choose Options and export Sound Channels 1 and 2.
Place a sound in the score
Modify
Frame
Sound
Drag sound cast member to sound channel, or drag SWA or DV member to sprite channel.
Add cue points to a sound
See "Cue Points and Timing" and "Sound Editing Applications and Utilities" later in this chapter.
Create SWA cast member
See "Shockwave Audio (SWA)" later in this chapter.
Wait for sound or cue point
Modify
Frame
Tempo
Wait for Cue Point. (In D5, use Wait for End of Sound or Wait for End of Digital Video options.)
Play sounds in the cast (internal, linked external, and SWA sounds)
Play button under Modify
Cast Member
Properties or Modify
Frame
Sound
Preview external sound files
Play button under File
Import
Find sound cast members in Cast
Edit
Find
Cast Member
Sound
Find SWA cast members in Cast
Edit
Find
Cast Member
Xtra (D6)
Edit
Find
Cast Member
Shockwave Audio (D7)
Find Sound or SWA members in Score
Highlight member in Cast and use Edit
Find
Selection
Volume levels or mute a sound[17]
Control
Volume, or volume button in Control Panel. Mute buttons to left of Score Sound channels.
Sound Cast Member Properties Dialog Box
Some sound cast member's properties can be viewed and set via the Sound Cast Member Properties dialog box (see Figure 15-1) or set via Lingo, but a sound's sampling rate, bit depth, and number of channels are read-only in Director. The original sound must be modified in a separate sound editing program.
Figure 15-1. Sound Cast Member Properties dialog box
![]()
If multiple sound cast members are selected, the cast member properties dialog box will contain summary information, such as the total size of selected cast members.
The Sound Cast Member Properties dialog box can be used to play a sound. It also shows the sample rate (see the sampleRate of member), the number of channels (see the channelCount of member), and the bit depth (see the sampleSize of member). See Example 15-3 to determine the duration of an internal sound.
The size listed for internal sounds is accurate, but the size listed for externally linked files is merely the size of the cast member's header. See Example 4-6 to determine an external sound file's size.
The following sound properties are also shown in the dialog box:
- Name and filename
- If the sound is linked, an external filename is shown. Click on the name to browse to another filename. The fileName of member includes the complete path to the file and updates automatically for the current platform.
- Loop
- Loop controls whether Director obeys the loopback points set in an external sound editor. Absent any loopback points, the sound loops back to its beginning after it has completed. The Tempo Channel's Wait for Cue Point:{End} option causes Director to ignore the loop setting and play the sound until it ends. To wait indefinitely, use Wait for Cue Point:{Next} or the soundBusy( ) function. When creating a looping sound, ensure that the beginning and end of the loop combine seamlessly. External sounds won't loop automatically. See also the equivalent loop of member.
- Unload
- Set Unload to "Next" to keep a small sound in RAM (avoid this for larger sounds). Director often unloads sounds if it is low on memory, regardless of this setting. This setting has no effect on linked (streamed) audio.
Cue Points and Timing
Cue points are timing notations stored within sounds or digital video files. They were introduced in D6 and are used to synchronize audio or video with Score animations. Use sound tracks within QuickTime or Video for Windows when lip-synching or other close synchronization is required.
Director 6.5 and later supports cue points in WAVE files, as well as the AIFF, SWA, and digital video cue points supported in D6.0.x. Third-party Xtras such as the MPEG Xtra also support cue points.
Waiting for Godot's Audio
There are three ways to wait for audio:
- The Score's Tempo channel
- Checking the current playing time or audio state via appropriate Lingo properties, or using a Lingo function such as soundBusy( )
- Waiting for a cuePassed event or checking the isPastCuePoint( ) function or the mostRecentCuePoint property
Tempo channel settings
The Tempo channel's Wait for Cue Point option can be used to wait for a sound to end or to reach a particular cue point. In the Frame Properties: Tempo dialog box (see Figure 15-2), choose the Sound channel or sprite channel to wait for, and choose from the list of available cue points within the sound, or {Next} or {End}.
Figure 15-2. Tempo channel dialog box
![]()
Waiting for sounds via the Tempo channel in D5 (which used separate Wait for End of Sound and Wait for End of Digital Video options) locked out other events, such as mouse clicks. In D6, it locks out events for Custom Buttons, but otherwise allows events to be processed. In D7, Custom Buttons are obsolete, and Director continues to process other events while waiting via the Tempo channel.
Waiting for sound via Lingo
Use Lingo for finer control over waiting for sounds. For example, the Tempo channel cannot be used to wait for sounds played via sound playFile. Use the soundBusy( ) function instead, as shown in Example 15-4.
Example 15-4: Waiting for a Sound by Sound Channel Number on exitFrame-- This waits for a sound in channel 2 to completeif soundBusy(2) thengo the frameend ifendAs a general rule, you should not wait in a repeat loop, as it locks out all interactivity. Avoid this:
repeat while soundBusy(2)-- Waiting for the sound in channel 2 to endend repeatAvoid waiting for a sound to start unless you are sure it will actually start. For example, sound playFile will not give an error if you specify a missing or invalid filename; the sound will simply fail to play. The following will cause an infinite loop if the sound in channel 1 never starts.
puppetSound "someSound"repeat while not soundBusy(1)-- Waiting for the sound to startend repeatTo avoid an infinite loop in the prior example, trigger the puppetSound using an updateStage command before the repeat loop.
You can wait for a specific time in an SWA sprite by using the currentTime property in a script attached to the sprite of interest. Example 15-5 waits for 10 seconds (10,000 milliseconds) of the SWA to play. It will cause an infinite loop if the currentTime never reaches that point.
Example 15-5: Waiting for a Specific Point in an SWA Sound on exitFrame meif the currentTime of sprite the spriteNum of me < 10000 thengo the frameend ifendSynchronizing with Cue Points
You can use cue points to wait in, leave, or jump to a particular frame in the Score. Create your cue points in a sound editing program with your Score layout and frame labels in mind. Create a cue point before the sound segment of interest if you'll be jumping to a new frame when the cue point is reached. Create a cue point after the sound segment of interest if you'll be waiting in a frame until a cue point is reached.
TIP:
To simplify your Lingo code, name your cue points the same as the frame label to which you wish to jump.
The Tempo channel's Wait for Cue Point option waits for a cue point in a Sound channel, digital video sprite, or SWA sprite. If the Cue Point option is {Next }, Director will wait for the next cue point to be reached. Use the {End } setting to wait for the end of a sound, even one without cue points. The {End } setting will not cause an infinite loop if a sound's loop option is set, but the {Next } setting will. The Channel parameter in the Tempo dialog box does not update automatically, so you must update it manually if you move a sound or sprite to a different channel.
Example 15-6 is a frame script that waits for a cue point. It then jumps to a frame whose label matches the cue point name.
Example 15-6: Using Cue Points to Synchronize with Score Animation on exitFramego the frameendon cuePassed me, channelID, cueNumber, cueNamego frame cueNameendCreating Cue Points
Cue points must be added to a sound before it is imported into Director. SoundEdit 16 (Macintosh only) can add cue points to AIFF and QuickTime files. You should use the SoundEdit v2.0.7 update at http://www.macromedia.com/support/soundedit/updates. Earlier versions may not create cue points correctly and will fail under Mac OS 8.
In D6.0.x, QuickTime cue point support was through a custom mechanism. QuickTime cue points appeared in SoundEdit as "markers" as they do for other file formats, but in MoviePlayer the same cue points appeared as a text track. (You must enable the track in MoviePlayer to see the text cue points, but Director reads the cue points even if the text track is disabled.)
Director 6.5 and 7 use the standard QT3 chapter tracks (which can be created and edited in any program that supports them) for cue point support in QuickTime.
AVI and WAVE cast members cannot contain cue points in D6.0.x, but Director 6.5 supports cue points in WAVE files (AVIs support cue points only if played via QT3). For example, cue points created in Sound Designer for Windows are ignored by Director 6.0.x, but recognized by D6.5. WAVE files use markers ("MARK" chunks) to represent cue points. Any sound editor that supports markers can be used to create and edit cue points for D6.5.
To add cue points to a sound using SoundEdit 16 v2.0.7, follow these steps:
- Open the sound file and click the location in the sound track at which you want to create the cue point.
- Choose Insert
Cue Point.
- Enter a cue point name and/or change the cue point time. Director will always read cue points in milliseconds, regardless of the units used in SoundEdit.
- You can move cue points by dragging them along the sound track, or delete them by dragging them off the sound track. Use Windows
Cue to bring up SoundEdit's Cue Points inspector.
- Save the file from SoundEdit in Audio IFF or QuickTime movie format or use the SoundEdit SWA Xtra from SoundEdit's Xtras menu to save an SWA file (requires PowerPC). Cue points added to a QuickTime file appear as text elements in a text track in QT2 and as chapter tracks in QT3.
To add cue points using Sound Forge or Cool Edit under Windows, see the ReadMe Windows Sound Loop-Cue file that comes with D6 and D7. To add cue points in Peak LE and for more tips on cue points, see http://www.zeusprod.com/nutshell/cuepoints.html.
To use cue points:
- Import the asset into Director's Cast or File
Import using Insert
Media Element as appropriate.
- Insert a sound into one of the Score's Sound channels or insert an SWA or QuickTime member into a sprite channel. Sound playFile and puppetSound also work with cue points.
- Use the Tempo channel's Wait for Cue Point option to wait for a cue point or wait in a frame until a cuePassed event is sent to your on cuePassed handler.
Cue point caveats
Cue points trigger off the actual data buffers sent to and returned from the sound card under Windows. If there is no sound card (such as is common under Windows NT), cue points will not work.
A muted Sound channel in the Score will not load the specified sounds and those sounds won't generate cue point events. Similarly SWA or QuickTime sprites in muted sprite channels will not generate cue point events.
Cue point events are sent even if the volume is muted via the Control Panel or via Lingo.
Cue points near the end of a sound may not be recognized. Add silence to the end of the sound if necessary.
Avoid putting cue points beyond the end of an audio track in either a sound file or QuickTime movie. The duration of member reflects the position of the last cue point, not merely the end of audio data.
Cue Point Lingo
The cuePointNames of member property returns a Lingo list of cue point names for any cast member type that supports cue points. Unnamed cue points are shown as "" (EMPTY). If no cue points are present, an empty list (
[]) is returned. The cuePointTimes of member property returns a Lingo list of cue points times (in milliseconds), or an empty list ([]) if no cue points are present:put the cuePointNames of member "mySound"-- ["Intro", "Bridge", "Chorus", "", "Coda"]put the cuePointTimes of member "mySound"-- [4466, 7300, 13000, 17000, 21500]"WARNING:
The cuePointNames and cuePointTimes of an SWA, sound, or QuickTime cast member are returned as empty lists (
[]) until the sound is playing. See the state of member property.The lists of cue point names and times is read-only, but can be manipulated with Lingo's list functions, such as:
set numCues = count (the cuePointNames of member "mySound")set lastCue = getLast (the cuePointTimes of member "mySound")The isPastCuePoint( ) function takes the general form:
isPastCuePoint (sprite n | sound n, cuePointNumber | cuePointName)The first parameter is either a sprite channel or a sound channel. If the second parameter is a cuePointNumber, isPastCuePoint( ) returns a Boolean value indicating whether the current media playback position is beyond the specified cue point (regardless of how many times it may have passed that point). If the second parameter is a cuePointName, isPastCuePoint( ) returns an integer count of the number of times that the cue point with the given name has been passed (including multiple cue points with the same name).
The mostRecentCuePoint takes the form:
the mostRecentCuePoint of {sprite n | sound n}It indicates the number of the last cue point passed for the specified sprite channel or sound channel. It returns 0 if no cue points have been passed.
Table 15-7 summarizes cue point-related operations.
Table 15-7: Cue Point Functions Action
Command
Wait for cue point
Tempo channel, isPastCuePoint( ), or see Examples 15-6 and 15-7
Determine names of cue points
the cuePointNames of member
Determine times of cue points
the cuePointTimes of member
Determine whether a cue point has been reached
isPastCuePoint( )
Check the last cue point passed for a sprite or sound channel
the mostRecentCuePoint of sprite,
the mostRecentCuePoint of soundTrigger an event when a cue point is reached
Identify the sprite triggering a cue point
See the the spriteNum of me or channelID passed to the on cuePassed handler
Forces preloading of list of cue points (highly undocumented and unsupported in D6.5, and removed in D7)
forcePreloadCuePoints (member whichMember)
Cue Point Events
Director generates cuePassed events whenever it passes a media cue point in an appropriate sound or sprite. The beginning and end of the media do not automatically generate cuePassed events, although the Tempo channel's Wait for Cue Point option will wait for the end of a sound without cue points. As shown in Example 15-6, the declaration of an on cuePassed handler takes the form:
on cuePassed {me,} channelID, cuePointNumber, cuePointNameThe on cuePassed handler receives three or four parameters as follows:
- me
- The script instance of the sprite that triggered the event, me, is sent to on cuePassed handlers in sprite scripts and frame scripts, but not to onCuePassed handlers in cast scripts or movie scripts. Use the spriteNum of me to determine the sprite's number.
- channelID
- channelID is the sprite channel or sound channel of the asset that reached a cue point. If the cue point is triggered by an SWA or QuickTime sprite, channelID is an integer from 1 to 120 in D6, or 1 to 1000 in D7. If triggered by a sound in a sound channel, channelID is #sound1 or #sound2 representing the Score's Sound channels; #sound3 through #sound8 represent puppetSound and sound playFile commands played in channels 3 through 8.
- cuePointNumber
- The number of the cue point within the asset triggering this event, starting at 1.
- cuePointName
- The name of the cue point triggering this event, or
EMPTY("") for unnamed cue points.
Example 15-7 can be used to analyze or diagnose cue point problems from any type of script. It automatically adjusts to whether 3 or 4 parameters are passed in (which depends on the script type). Ordinarily, you wouldn't use most of the information available, except perhaps the cue point name. See Example 15-6 for a typical cue point handler.
Example 15-7: Diagnostic Cue Point Event Handler on cuePassed-- Sprite and Frame scripts receive four parameters-- Movie and Cast scripts receive three parametersif the paramCount = 4 thenset me = param(1)put "on cuePassed handler reached for sprite" && ¬the spriteNum of meend ifset channelID = param(the paramCount - 2)set cueNumber = param(the paramCount - 1)set cueName = param(the paramCount)put "Channel ID:" && channelIDput "Cue Number:" && cueNumberput "Cue Name:" && cueName-- Print the cue point timecase(channelID) of#sound1:set thisMember = the frameSound1#sound2:set thisMember = the frameSound2#sound3, #sound4, #sound5, #sound6, #sound7, #sound8:put "Cue point times not available for" && channelIDset thisMember = 0otherwise:set thisMember = the member of sprite channelIDend caseif thisMember <> 0 thenput "This cue time:" && getAt (the cuePointTimes of ¬thisMember, cueNumber)end ifend cuePassedShockwave Audio (SWA)
Shockwave audio (SWA) could be renamed compressed audio, because SWA can be used with a standalone Projector as well as with the Shockwave browser plug-in. For both Projectors and Internet delivery, SWA compression can be used to create external streaming SWA files or to compress internal sound cast members.
Compressing Sounds for SWA
When using SWA compression, you don't select a compression ratio--you select an output bandwidth. The throughput of users' Internet connections varies tremendously. You should pick a data rate that is sustainable over the slowest expected connection. Table 15-8 lists suggested output bit rates for SWA.
Even the highest quality SWA (160 Kbps) requires less than 20 KB/sec. Divide Kbps (1000 bits per second) by 8.192 (that is, 8 × 1024 / 1000) to convert to kilobytes per second.
Converting very large sound files to SWA may crash Director or SoundEdit. Refer to the Shocker-L archives (see the Preface) circa August 19, 1998 for comments about it.
Table 15-8: Shockwave Audio Delivery Rate Comparison Delivery
Bit rate
Quality[18]
T1 or CD-ROM
64-160 Kbps (8-20 K/sec)
Equal to source material
ISDN
48-56 Kbps (6-7 K/sec)
FM stereo to CD-quality audio
28.8-56 Kbps modem[19]
16-32 Kbps (2-4 K/sec)
FM mono or good quality AM
14.4 Kbps modem2
8 Kbps (1 K/sec)
Telephone
If you expect approximately 2 K/sec through a 28.8 Kbps modem, you should use a compression rate of 16 Kbps (equal to 2 K/sec). The goal is gapless delivery, but if the stream cannot keep up, the audio will pause or drop out.
Internal sound cast members can be compressed to rates of 32 to 160 Kbps (4 to 20 K/sec). External SWA sounds can be compressed as low as 8 Kbps (1 K/sec). You might use 8 Kbps or 16 Kbps SWA for uninterrupted streaming of large sounds over a 28.8 Kbps modem and 64 Kbps for high-quality smaller internal sounds.
During streaming or downloading, only the bandwidth (i.e., the bitRate of member) is important. Streaming sound is discarded as it is played, so it doesn't use much RAM.
The disk size of an SWA file is only relevant if calculating the CD-ROM space required when using local SWA files. Its size depends only on the duration of the source audio and the bit rate chosen for SWA compression, regardless of the source material's sample rate and sample size. The size of an SWA file on disk can be calculated in KB as:
(the duration of member) * (the bitRate of member) / 8192Compressing internal sounds
Standard internal sound cast members can be compressed as follows:
- Fully import (unlinked) sounds into Director using File
Import
Standard Import.
- Enable compression under Xtras
Shockwave for Audio Settings and choose 32, 48, 56, 64, 80, 112, 128, or 160 Kbps as the final output rate.
- Compression does not occur until the DCR or CCT file or Projector is created using File
Save As Shockwave Movie, Xtras
Update Movies, File
Create Projector
Options
Compress (Shockwave format).
- If Shockwave compression is not enabled, internal sounds in DCR and CCT files are compressed about 30% using LZW compression. Internal sounds in DIR, D