|
|
|
|
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, DXR, CST, and CXT files are never compressed.
Internal non-streaming sounds that are SWA-compressed using Xtras
Shockwave for Audio Settings are blown up fully into RAM when needed. They use the standard properties for #sound cast members, not those for #SWA members, as shown in Tables 15-4 and 4-10. Likewise in D7, SWA cast members imported via File
Import are converted to Director's internal sound format. Insert SWA via Insert
Media Element
Shockwave Audio to retain the SWA format.
Compressing external sounds
External SWA sounds can be compressed to 8, 16, or 24 Kbps (which are designed for very low bandwidth), in addition to the higher quality rates (32-160 Kbps) available for internal sounds.
Director for Macintosh compresses internal sounds only. Use SoundEdit 16 or Peak LE to compress external sounds on the Macintosh.
The steps for SWA compression of external sounds in SoundEdit 16 (PowerMac-only) are:
- Import or create sound files within SoundEdit v2.07.
- Within SoundEdit, choose Xtras
Shockwave for Audio settings.
- Compression occurs when using File
Export (sound format Shockwave Audio).
- Import sounds as linked SWA cast members into Director using Insert
Media Element
Shockwave Audio.
For an SWA Tutorial, examples, and SWA players, click the "Working With Shockwave" option and then the "Download the example movies" option at http://www.macromedia.com/support/soundedit/. The following two links include the SWA Xtras for SoundEdit 16 (also included with the D6 Studio).
SWAtomator--batch processes files to SWA:
http://www.macromedia.com/support/soundedit/SE16SWA.hqxSoundEdit 16 updater to version 2.0.7 (supports Mac OS 8.x):
http://www.macromedia.com/support/soundedit/SE16v207.hqxTo export SWA from Peak LE:
- Install Peak LE from the Peak LE 2.0 folder included on the Director 7 Shockwave Internet Studio CD.
- Copy the SWA Export Xtra from that same folder to the Peak LE Plugins folder (where Peak LE is installed).
- Choose Shockwave .swa format under File
Save As.
SWA compression of external sounds in Director (Windows only) requires a Pentium and operates on WAVE files. Choose Xtras
Shockwave for Audio settings and then Xtras
Convert WAV to SWA.
SWA compression hints
SWA uses MPEG3 compression (SWA files can be previewed in MacAmp or WinAmp) and is optimized to deliver high quality audio at reasonable bandwidths, but it also delivers fair quality audio at minuscule bandwidths. Whether compressing internal or external sounds, use at least 16-bit, 22.050 kHz source audio. Do not downsample the audio to 8-bit first. After SWA compression, 8-bit, 11 kHz monaural audio occupies the same space as 16-bit, 22 kHz monaural audio (or even 16-bit, 44 kHz).
There is no benefit to reducing either the bit depth or the sample rate before compression. Quite the contrary, higher fidelity source audio results in higher quality SWA without any additional bandwidth. All SWA-compressed sounds reconstruct (decompress) into 16-bit audio regardless of the source material's bit depth (which is why the bitsPerSample of member property always returns 16).
The numChannels of member is 1 (monaural) if the bitRate of member is 32000 bps or less. SWA properties can be checked only after the SWA begins playing, as indicated by the state of member property (see Table 15-9).
Use the highest output rate that your Internet connection will tolerate (see Table 15-8). Output rates below 32 Kbps are intended only for compatibility with slower modems. As compression increases, the absolute savings are only marginally better.
For example, a CD-quality (16-bit, 44 kHz, stereo) source file requires 176 K/sec (1400 Kbps). Compressing it to 160 Kbps reduces the size by 89% with no detectable loss of quality. Compressing it to 32 Kbps (4 K/sec) saves a whopping 172 K/sec and it can still play over a fast modem. But compressing it to 8 Kbps (1 K/sec) saves only an additional 3 K/sec, and the loss in quality to achieve the marginal savings is immense (according to Macromedia).
SWA Decompression
SWA decompression is processor-intensive, so SWA is most appropriate over the Internet, where download time is at a premium. For local content, SWA may simply hinder performance, especially on slower machines.
Decompression time is not significantly different at different data rates (as with most compression schemes, decompression is much faster than compression). The propensity to drop sounds seems independent of the bit rate. On 68K Macs (which require an FPI to play SWA), SWA decompression ignores some of the data when using 8 Kbps and 16 Kbps bit rates. This provides adequate performance at the expense of lesser quality than on PowerMacs.
All SWA is decompressed as 16-bit audio (which is why you shouldn't downsample to 8-bit). Internal sounds that were compressed with SWA are reconstructed in their entirety in RAM before playback; they are blown up to their original size, so a 44 kHz source will occupy twice the memory of a comparable 22 kHz source once decompressed. Regardless, streaming external sounds don't remain in memory--they use only a small temporary buffer--so the size is only relevant for internal sounds.
SWA Lingo
Table 15-9 lists the commands and properties pertaining to SWA cast members. All the properties are read-only and apply to externally linked #SWA cast members, not to internal cast members compressed when the Director movie or castLib is compressed as a whole. All SWA commands are new as of D6; although some were supported in Shockwave for D5, none were supported during authoring in D5.
Table 15-9: Shockwave Audio Lingo Property
Usage
the bitRate of member[20]
0 (not ready) | 8000 | 16000 | 24000 | 32000 | 48000 | 56000 | 64000 | 80000 | 112000 | 128000 | 160000
the bitsPerSample of member1,[21]
Bit depth of expanded media, not the bit depth of the original file that has been SWA encoded. It always returns 0 (not ready) or 16.
the copyrightInfo of member1,2
Copyright text for sound file.
the cuePointNames of member1,2
List of names of cue points.
the cuePointTimes of member1,2
List of cue point times in milliseconds.
the currentTime of sprite1,2
Current point in playback in milliseconds.
the duration of member1
Duration of SWA file in seconds (different units than property of the same name for #digitalVideo, #quickTimeMedia, and #transition members).
getError (member swaMember)
Error status for SWA cast members. The integer value returned by getError( ) corresponds to the string returned by getErrorString( ):
0: returns EMPTY string ""[22]
1: "memory"
2: "network" (or "Network software error")
3: "playback device"
99: "other"
getErrorString (member swaMember)3
See getError( ).
isPastCuePoint(member, cueID )2
Returns a positive integer if the cue point has been passed.
the mediaReady of member
Indicates whether media has been completely downloaded. Appropriate only for internal nonstreaming SWA-compressed sounds.
the mostRecentCuePoint of member2
Returns number of most recent cue point passed.
the numChannels of member1,2
Number of channels (usually 1 or 2). Returns 1 when the bitRate of member is <= 32000.
pause (member)
Pauses SWA stream, but not instantly.
the percentPlayed of member
Percentage of bytes played (0 to 100). Should be less than or equal to percentStreamed.
the percentStreamed of member
Percentage of bytes streamed from server (0 to 100).
play (member)
Begins playing SWA (initiates preload, too).
preLoadBuffer (member swaMember)
Begins preloading amount of data specified by the preLoadTime of member. Use stop( ) to "rewind" the media after preloading before using play( ).
the preLoadTime of member
Duration of SWA audio (not download time) in seconds to be downloaded before playback begins (prevents skipping).
the sampleRate of member 1,2
Sample rate of original sound source (in Hz) before compression, such as 11025, 22050, or 44100.
the soundChannel of member1,2
System sound channel in which to play SWA (0 uses highest available channel). Avoid using 1 and 2, the Score Sound channels.
the state of member
The state of member must be 2, 3, 4, or 5 before checking other SWA properties accurately:
0: Stopped
1: Preloading
2: Preloading completed
3: Playing
4: Paused
5: Done
9: Error
10: Insufficient CPU
stop (member)
Stops SWA stream, but not instantly. Also rewinds SWA.
the streamName of member1,2
URL of SWA file. Can be local. (Same as URL of member.)
the url of member1
URL of SWA file. Can be local. (Same as streamName of member.)
the volume of member
Volume of SWA, from 0 to 255.
Pausing an SWA and playback gaps
When you use pause( ) or stop( ) to halt an SWA, a certain amount of audio data is still in the SWA buffer and continues to "play out." Therefore, the sound does not pause immediately. To stop the sound from being heard, you must set the volume of member to 0. When you use play( ) to start the sound again (don't forget to reset the volume), the sound will have skipped the portion that was played out of the buffer after the last pause( ) command. No ideal solution exists.
If an SWA sprite is streaming, there may be times when the Internet connection does not provide data fast enough and gaps in the audio occur. Even though the audio is momentarily interrupted, the state of member still returns 3 (playing).
Likewise, the soundBusy( ) function indicates whether a sound channel has been allocated and is presently "in use," not whether sound is currently audible.
There is no random access to an arbitrary point in an SWA stream, which is incompatible with streaming playback. The data would have to be either stored to disk or preloaded to allow such access, as is done by various MP3 players. However, see the highly unsupported Din Xtra commands in Table 15-14.
Streaming live audio sources via Shockwave
According to John "jd" Dowdell of Macromedia, there are two alternatives to encode and broadcast SWA in realtime:
- Use the Telos AudioActive (http://www.audioactive.com) real-time encoding and multicasting equipment. It works under Windows and with the SW6.0 on the Mac. (It doesn't work with SW6.0.1 and Netscape 3 and 4 on the Macintosh; the audio stream downloads but never plays.)
- Use RealAudio's real-time compression and multicasting hardware. The Real-Audio Xtra requires installation in the browser plug-in folder. You can instead use a RealPlayer element in a web page and use LiveConnect and ActiveX scripting from Shockwave to control it. (Some have reported poor results with this solution.)
Details on these solutions using Shockwave 7 were not available at press time. The RealAudio Xtra won't work in SW7 unless a Shockwave-safe version is made available by Real Networks, and no such plans appear likely.
Other Sound-Related Lingo
Table 15-10 lists system-level sound-related Lingo properties and commands.
Table 15-10: System-Level Sound-Related Lingo Command
Usage
beep {n}
Beeps n times (alert also causes a beep). If the soundEnabled is FALSE, beep flashes the Macintosh menubar. n defaults to 1, and multiple beeps don't usually work under Windows.
the beepOn
If TRUE, Director beeps when the user clicks on an inactive sprite (one without a mouse script attached). Useful for debugging.
sound close channel
Closes the specified sound channel. This requires the sound buffer to be reallocated for the next sound.
sound stop
Stops the sound playing in the specified channel.
the soundEnabled
If FALSE, all sounds are muted.
the soundLevel
System volume from 0 (mute) to 7 (loudest).
the multiSound
If TRUE, the computer supports stereo sound.
The DIRECTOR.INI file has numerous settings that affect the audio buffers and sound-mixing under Windows. Ordinarily, you shouldn't change any except the DLLname and rsxDontUseDirectSound, which are both obsolete in D7, anyway. Refer to Appendix D in Lingo in a Nutshell for additional details on setting the items listed in Table 15-11.
Table 15-11: DIRECTOR.INI File Sound-Related Settings Command
Usage
DLLname (D6.5 only)
Default is MacroMix.DLL. Change to QT3Mix.DLL to use QT3 Sound Mixing (requires D6.5 with Service Pack).
rsxDontUseDirectSound (D6.x only)
If set to 1, RSX will output to WaveOut instead of DirectSound. Default is 0. SW6.0 treats this as 0; SW6.0.1 treats it as 1.
MixMaxChannels
Maximum number of sound channels allowed to be mixed. Default is 8 in D7 and 4 in previous versions; max is 8.
MixMaxFidelity
Maximum sound fidelity that MacroMix will need to mix. The default, 99, determines max on the fly:
0: 22.050 kHz, 8-bit, mono
1: 22.050 kHz, 8-bit, stereo
2: 44.100 kHz, 16-bit, stereo
99: Switch formats on the fly (default)
MixServiceMode
0: Interrupt Mixer based on MixIntPeriodMs and MixIntResolutionMs (default)
1: Use polling to drive mixer (may cause drop out if other tasks hog CPU access)
2: Use waveout buffer-completion callback to drive mixer. Set MixBufferBytes to multiple of 1024
MixWaveDevice
Ranges from 0 (default) to the number of devices - 1.
MixBufferBytes
Defaults to 0. Set MixBufferMs to 0 and then set MixBufferBytes to multiple of 1024 to specify a buffer size in bytes.
MixBufferCount
Number of mixing buffers from 2 to 16 (default is 4).
MixBufferMs
Defines sound buffer length in milliseconds. Default is 200 milliseconds (size in bytes varies with sound format). To define buffer size in bytes using MixBufferBytes, set MixBufferMs to 0.
MixIntPeriodMs
Interrupt interval, defaults to 200 milliseconds. Used only when MixServiceMode is 0.
MixIntResolutionMs
Interrupt duration, defaults to 50 milliseconds. Used only when MixServiceMode is 0.
SoundLevel0 through SoundLevel7
Specifies "wave output" volume corresponding to the soundLevel property. Default values for the soundLevel = 0 to 7 are shown:[23]
SoundLevel0 = 0
SoundLevel1 = 24770
SoundLevel2 = 35030
SoundLevel3 = 42903
SoundLevel4 = 49540
SoundLevel5 = 55388
SoundLevel6 = 60674
SoundLevel7 = 65535
HighSpoolBufferMs
Length of one 16-bit spool buffer; default is 1500 milliseconds.
LowSpoolBufferMs
Length of one 8-bit spool buffer; default is 2500 milliseconds.
SpoolBufferAlloc
0: Allocates/deallocates spool buffers dynamically, when sound starts/stops (default)
1: Allocates spool buffer once at startup and keeps them it entire session
SpoolBufferCount
Number of spool buffers to allocate, from 2 (default) to 10.
Volume Levels and Sound Fades
Volume levels vary tremendously across platforms and even on different machines running the same OS. Perform tests to determine an appropriate volume level and then record all your sounds for a project at the same level. You can later adjust their relative volumes in Director (this is simplified greatly if all background sounds or voiceovers are played in a specific channel).
There are many commands that control sound volume in Director, including system-level volume controls, plus those at the sprite or cast member level. On the Macintosh, Lingo can set the master volume, but under Windows, Lingo controls only the "wave output" volume.
Provide a volume control with a mute option to the user. Macromedia provides an example volume slider in the D6 Behavior Library. You can use the keyboard characters 0 through 7 to set the soundLevel, as shown in Example 15-8.
Example 15-8: Setting the soundLevel via the Keyboard on keyDown-- 0 though 7 set the soundLevel. Keys 8 and 9 set it to 7.if charToNum(the key) >= 48 and charToNum(the key) <= 58 thenset the soundLevel = min(integer(the key), 7)end ifend keyDownIt is exceedingly rude to increase the system volume level automatically. If necessary, check the soundLevel or sprite volume via Lingo and suggest that the user change it. If you do set the soundLevel, set it to 5, not 7.
Table 15-12 lists commands that pertain to sound volumes in Director. See also Control
Volume and the volume button in the Control Panel.
Table 15-12: Volume-Related Lingo Command
Usage
sound fadeIn channel {, ticks}
Fades volume up from 0 to the current volume of sound setting, not up to 255, as in D5. See the D6 ReadMe.
sound fadeOut channel {, ticks}
Fades volume down from the current volume of sound setting to 0, not from 255 to 0, as in D5. See the D6 ReadMe.
the sound of member videoMember
Boolean indicating whether sound is enabled for a digital video or Flash cast member.
the soundEnabled
If FALSE, all sounds are muted.
the soundLevel
System volume from 0 (mute) to 7 (loudest). See Table 15-11.
the visibility of sprite
Muting a Sound channel or sprite channel in the Score prevents the sound, SWA, or digital video sprite from playing.
the volume of member
Volume level for SWA members (0 to 255). Doesn't work for Flash.
the volume of sound
Volume level for Sound channel 1 or 2 (0 to 255).
the volume of sprite
Volume level for digital video, AVI, QT2 in D6, QT3 in D7, and SWA sprites. Nominal range is 0 to 255, but can be set much higher.
the volumeLevel of sprite
Volume level for QT3 digital video sprites in D6.5. Use volume of sprite in D7. Nominal range is 0 to 255, but can be set much higher.
Volume levels
The soundLevel command sets the volume for the overall system on the Macintosh and it matches the settings in Sound or Monitors & Sound Control Panel. Under Windows, the soundLevel controls the "wave output" volume matching the SoundLevel0 through SoundLevel7 settings in the DIRECTOR.INI file (see Table 15-11). Note that human audio perception is nonlinear. The default settings for SoundLevel0 through SoundLevel3 are usually indistinguishable from each other and undesirably soft. Consider respecifying the range of SoundLevel1 to SoundLevel7 from 45,000 to 65,535 in the DIRECTOR.INI file for more useful control via Lingo's the soundLevel property.
For complete control of the master volume under Windows, either open the Windows Sound mixer or use a third-party Xtra.
Burak Kalayci's bkMixer Xtra adjusts the Windows master volume level:
http://www.updatestage.com/xtras/bkmixer.htmlBuddy API Xtra--see the baGetVolume( ) and baSetVolume( ) methods:
http://www.mods.com.au/budapi/Some Windows sound cards' volume mixers can be controlled via mci commands. Bear in mind that the volume can also be changed by the user on some speakers with external volume knobs.
The soundLevel affects all sounds; you can adjust the relative volumes of individual members or sprites using the commands shown in Table 15-12.
There is no volume control over Flash sprites beyond shutting sound off using the sound of member property. Use native Director sounds instead.
Modal MIAWs reportedly prevent the soundlevel from being set under Windows NT in D7.0.
Sound fades
Prior to D6, sound fadeIn and sound fadeOut always faded between the minimum and maximum volumes (0 to 255). In D6 and later they fade from the current volume of sound for the specified channel towards either 0 or 255 as appropriate.
Interrupting sound fades under Windows tends to freeze the volume of sound at the level it held when the fade was interrupted. For example, if a sound terminates in the Score before a sound fadeOut completes, it might lock the volume for that channel to a near-zero level. Use this to reset the problem:
set the volume of sound channel = 255You can manually construct your own fadeIn and fadeOut commands to fade between two arbitrary volume levels and avoid the buggy sound fade commands altogether. See http://www.zeusprod.com/nutshell/fade.html.
Some conflicts have been reported when fading sounds with different sampling rates at the same time. Always use sounds of the same rate at the same time.
Sound-Related Xtras
There are two broad categories of sound Xtras: those required by Director to play external sounds and those that add additional sound-related features of interest, but are not mandatory for most users.
Xtras needed to play external sounds in Director 6 and 7
Director 5 does not require any Xtras for sound playback. In Director 6 and 7, as with most external media, MIX Xtras are required to access external sounds at runtime. Note that in D6 the MIX Services and Sound Import Export Xtras are automatically added under Modify
Movie
Xtras when your cast includes linked sounds, but sometimes additional Xtras are needed. These Xtras, plus the SWA Xtras, are added by default to all D7 Projectors unless deleted from the Modify
Movies
Xtras list. This list also includes the MacroMix and DirectSound mixers. Regardless, I recommend against bundling Xtras with your Projector, so you should distribute the Xtras listed in this section with your Projector in a separate Xtras folder.
If all your sounds are embedded (unlinked) internal sounds, you don't need any Xtras unless you are using internal SWA compression.
Following is a list of Xtras needed in certain situations. See Table 15-13 for the exact names of the Xtras needed on the various platforms. The Xtras can be found in the MIX, Media Support, Net Support, Device, and QT3 subfolders within the Xtras folder where Director is installed.
- Playing any sounds in D7 or SW7 under Windows
- D7 and SW7 for Windows require the MacroMix.X32, DirectSound.X32, and/or QT3Asset.X32 Xtras, depending on the user's installed software.
- Linked sounds played via sound playFile, puppetSound, and the Score
- To use sound playFile or to play any externally linked sound cast members via the Score Sound channels or via puppetSound, include the MIX Services and Sound Import Export Xtras with your Projector.
- Local SWA audio played from a Projector
- To play SWA from a local drive, include the MIX Services, Sound Import Export, SWA Streaming, SWA Decompression, and NetFile Xtras with your Projector. (NetFile is needed even when not using the Internet.)
- SWA streaming over the Internet played from a Projector
- To play SWA from a remote server via a Projector, include the MIX Services, Sound Import Export, SWA Streaming, SWA Decompression, NetFile, INetURL, and NetLingo Xtras (and the NetManage Winsock Lib, for PowerPC only) with your Projector.
Table 15-13 lists sound-related Xtras.
Table 15-13: Xtras Needed for Sound Playback. PowerPC
Mac 68K
Win 32
Win 16
MIX Services
MIX Services
mix32.X32
mix16.X16
Sound Import Export
Sound Import Export 68k
Sound Import Export.X32
mixsound.X16
SWA Streaming PPC Xtra
SWA Streaming 68K Xtra
swastrm.X32
swastrm.X16
SWA Decompression PPC Xtra
SWA Decompression 68K Xtra
swadcmpr.X32
swadcmpr.X16
NetFile PPC Xtra
NetFile 68K Xtra
NetFile.X32
NetFile.X16
InetUrl PPC Xtra
None needed
INetUrl.X32
INetUrl.X16
NetLingo PPC Xtra
NetLingo 68K Xtra
NetLingo.X32
NetLingo.X16
NetManage WinSock Lib
None needed
None needed
None needed
MPEG 3 Import Export
MPEG 3 Import Export 68K
MPEG3 Import Export.X32
N/A
N/A
N/A
QT3Asset.X32[24 ] (contains QT3Mix)
N/A
N/A
N/A
MacroMix.X32[24]
N/A
N/A
N/A
DirectSound.X32[25]
N/A
If you choose to bundle Xtras with your Projector instead of shipping them separately, you can check the Check Movies for Xtras option in the D6 Projector creation dialog box in all of the previous cases. If playing SWA files either locally or remotely, you can also check the Include Network Xtras D6 Projector option. Instead of using these checkboxes, you can manually add the specified Xtras to your Projector file build list. In D7, individual Xtras can be flagged for inclusion under Modify
Movie
Xtras. All the previously listed Xtras are included by default for all D7.0.1 movies, whether needed or not. (Again, I recommend removing them from the list and placing them in an Xtras folder.) D7.0 movies will not include the DirectSound.X32 Xtra until upgraded to D7.0.1.
Xtras needed for sound in Shockwave
The equivalent of the MIX Services, Sound Import Export, and network-related Xtras (NetFile, INetURL, NetLingo, and the NetManage Winsock Lib for PowerPC) are built into Shockwave 6 and 7. These Xtras are needed only during authoring or in a Projector.
To play SWA from within Shockwave, the SWA Streaming and SWA Decompression Xtras must be installed in the Shockwave Xtras folder. These Xtras are both installed by default with Shockwave 6 and 7. Shockwave 7 for Windows also installs MacroMix.X32. SW7.0.1 installs DirectSound.X32 in addition. These Xtras are needed to mix sounds under Windows.
See Chapters 10 and 11 for more details on Xtras and Shockwave.
Other third-party sound-related Xtras
Besides the Xtras mentioned throughout this chapter, here are some that support more esoteric functions. See http://www.zeusprod.com/nutshell/links for a larger list of sound-related Xtras and other URLs of interest.
Audio Xtra (formerly sold as the Sound Xtra)--sound recording at runtime:
http://www.updatestage.com/xtrasDirectSound Xtra from DirectXtras:
http://www.directxtras.comSpeech Recognition--XtrAgent for Windows 95/98/NT support for speech input:
http://www.directxtras.com/xtragent.htmMultimixer Xtra--extensive control over QuickTime audio tracks:
http://www.turntable.comBeatnik Xtra (multichannel sound mixing):
http://www.headspace.comDin Xtra (unsupported)
The completely unsupported Din Xtra, which has some interesting methods for controlling streaming audio and checking sound channels, is found on the Director 6 CD under:
D:\Macromedia\XDK_d6a4\Goodies\Director\SoundXtr\Xtras\Din.X32or:
Director 6 CD:Macromedia:XDK for Director 6\Authorware 4:
Goodies:Director:SoundXtr:Xtras:DinTo see the Din Xtra's help text, type this in the Message window:
put mMessageList (xtra "Din")Table 15-14 explains the Din Xtra commands. Note that many of these commands appear highly unreliable, and none are officially supported. The Xtra is absent in D7.
Table 15-14: The Unsupported Din Xtra Din Command
Description/Usage
getChannelCount( )
Returns maximum number of sound channels.
set numSoundChannels = getChannelCount()
getFreeChannel( )
Returns number of highest free sound channel:
set highestFreeSoundChannel = getFreeChannel()
getPlayStatus( )
Determines if the sound is playing in specified channel:
set soundPlaying = getPlayStatus (soundChan)
Buggy; seems to always return TRUE. Use soundBusy( ).
getSndLength( )
Returns sound stream's total length in milliseconds:
set length = getSndLength (DinInstance)
getSndPosition( )
Returns sound stream's current time in milliseconds:
set currentTime = getSndPosition (DinInstance)
pauseRawSound( )
Pauses stream played through playRawSound:
pauseRawSound (DinInstance)
playRaw( )
Plays the list of files through raw sound as one stream. Returns sound channel:
set soundChan = playRaw (DinInstance, ¬
[file1, file2, ...], "aif" | "wav")
playRegular( )
Plays sound through playSound mechanism. Returns sound channel:
set soundChan = playRegular (DinInstance, ¬
soundFileName, "aif" | "wav")
setSoundTime( )
Sets stream to specified time (in milliseconds):
setSoundTime(DinInstance, time)
stopSound( )
Stops stream played through playSound or playRawSound:
stopSound (DinInstance)
stopSoundInChan( )
Stops sound in soundChan. Returns current time:
set currentTime = stopSoundInChan(soundChan)
Detecting the Sound Card at Runtime
All Macintosh models should include sound capabilities, but not all Windows PCs do. There are several techniques of varying reliability to detect whether a sound card is installed.
You can try playing a sound and then checking its status. For example, you might play a sound via puppetSound (remember to trigger it using updateStage) and then check whether soundBusy( ) returns TRUE for that channel. You can use a dummy sound containing silence for this test. Make it long enough to give you a chance to check it before it terminates.
Under Windows, you can use mci commands as follows:
mci "capability waveaudio can play"set soundCardInstalled = the resultBut it has been reported that some Windows 3.1 machines return TRUE as the result even though they do not have sound cards installed. Furthermore, if the MCI drivers are not properly installed (as is common under Windows 3.1), the result will be FALSE even though the system may be sound-capable.
For the highest accuracy, use the Buddy API Xtra's baSoundInstalled( ) method to check for a sound card, or perform a combination of these checks.
MIDI and MCI Device Control
There are a number of ways to play MIDI sounds under Director. The Beatnik Xtra will play MIDI files (and MOD as well).
QuickTime 3 Pro will import a MID file and convert it to a #midi track in a QuickTime 3 movie. Any such QT3 movie can be played in D6.5 or D7 via the QT3 Asset Xtra (also requires the QuickTime Musical Instruments extension).
Allegedly, RMI and MID files can be imported as OLE cast members under Windows and played with the MIDI OLE controller.
The Yamaha MIDI Xtra plays back MID files under Windows.
Windows sound cards have a separate MIDI port (configured via the Multimedia Control Panel), which should be independent of the DirectSound/WaveOut device discussed earlier. However, the Yamaha MIDI Xtra will lock out Director sounds. As long as the software synthesizer device is open (even if soundBusy( ) returns FALSE), Director can't play sounds via puppetSound, for example. Wait for a second (either via Lingo or via extra frames in the Score) after closing the software synthesizer to allow the sound card to switch sound drivers before playing puppetSounds.
MIDI files can be played under Windows via appropriate MCI calls. Playing MIDI via MCI is covered in the otherwise outdated "Windows 3.1 Multimedia" once published by QUE, or search Macromedia's TechNotes for the words "MCI" and "MIDI."
You can also use mci commands to control WAVE files under Windows (but Director commands won't affect it; for example, the soundLevel and volume of sound commands won't affect its volume).
Other sound formats
The MOD sound format was designed to store music for video games, especially background music, but is not supported by Director. The MOD Hypercard XCMDs work in D5. In D6 and D7, use the Beatnik Xtra to play MOD files and also RMF (Rich Music Format) files, which are very compact.
Enhanced CDs and RedBook Audio
Director is the dominant application used to create so-called Enhanced CDs that combine music and multimedia. RedBook is the standard format used for music CDs that are commonly played in home stereo systems. Enhanced CDs (ECDs) known variously or formerly as "CD Extra" or "CD Plus," combine RedBook audio with a separate computer-only (data) session on the same physical disc.
Most CD-ROM burning software, such as Toast, can create Enhanced CDs. Various hardware and software issues ensued before the preferred Enhanced CD format was ironed out a few years ago. The favored format is currently "Stamped Multisession" that conforms to the so-called BlueBook specification, and replaces older approaches such as "Track-Zero."
Cinram (http://www.cinram.com) has detailed white papers available on the various CD formats and specifications, including RedBook and BlueBook.
TIP:
Director can access the RedBook session (via an appropriate Xtra) or the multimedia (data) session, but not both simultaneously.
To access the RedBook audio from within Director requires an Xtra or MCI commands under Windows. To ensure smooth performance, you should not attempt to load multimedia content and play RedBook audio simultaneously or in rapid succession. Here are some possible alternatives:
- Load multimedia content into RAM
- If you have sufficient RAM to preload your multimedia content, it can play back from RAM while the RedBook audio is accessed off the CD. The upper limit for RAM playback is probably about 5 to 10 MB.
- Load multimedia content onto hard drive
- If the multimedia content is copied to the hard drive, it will not conflict with the attempt to read the RedBook audio from the CD. That said, users don't want large presentations loaded on their hard drive. Keep the content under 20 MB or (preferably) 10 MB. Copying 50 MB of content to someone's hard drive borders on the offensive.
- Play RedBook audio at limited times
- Playing RedBook audio throughout your entire presentation might require that the entire presentation to be preloaded or copied to the hard disk. Instead, play RedBook audio only within a small portion of Projector, perhaps via a single jukebox-like interface that can be loaded into RAM. If the remainder of the multimedia content does not require RedBook audio, it can be streamed from the CD as needed.
- Use limited non-RedBook Audio
- To simulate RedBook audio being played concurrently with your multimedia content, you can duplicate one or more RedBook tracks as typical Director WAVE or AIFF files on the multimedia session. Most computers don't do justice to CD-quality audio, so you can use 16-bit, 22 kHz, mono tracks or even SWA to save space. You may wish to provide alternate bonus tracks or even music videos instead of mere duplicates of the RedBook tracks available on the album.
- Use a caching Xtra
- LRU Cache Xtra (http://www.mca.com/newumg/lrucache.html) is designed for making Enhanced CDs. It caches parts of your program so you don't have to copy it to the hard drive.
To calculate how much room will be available on the CD for multimedia content, subtract the size of the RedBook audio from the CD's capacity.
CD-quality audio occupies 176 K/sec or about 10.3 MB per minute. For example, 55 minutes of RedBook audio would require 567 MB of CD-ROM space, leaving about 100 MB for multimedia. The capacity of CD-ROMs vary from about 650 to 720, depending on the format, manufacturer, and CD-burning software. (See http://www.cinram.com for more information.)
ECD resources
Refer to the following ECD resources in addition to the LRU Cache Xtra mentioned earlier.
CD Pro Xtra (free Xtra plays RedBook Audio cross-platform and replaces ECD Control and ECD File):
http://www.penworks.comMacromedia ECD Control and ECD File XObjects (obsolete toolkit that plays RedBook audio and optionally copies files to hard drive):
http://www.macromedia.com/ECD mailing list (and links to FAQs):
http://www.turntable.com/ecd/ECD support web site (includes a database of enhanced CDs):
http://www.musicfan.com/ecd/making.htmlApple Interactive Music Toolkit:
http://www.apple.comTroubleshooting Sound Problems
If your sound problem is widespread and not exclusive to a particular platform or configuration, then it can usually be addressed by restructuring your Lingo. Unfortunately, many sound problems are configuration-specific, especially under Windows. If the problem occurs under Windows, but not on the Macintosh, refer to the platform-specific caveats under "Sound Mixing Under Windows" earlier in this chapter and in Table 15-1.
Windows sound issues often depend on the sound card or sound driver. Conflicts with RSX and DirectSound are also sometimes reported. When in doubt, obtain the latest device driver for your sound card and the latest versions of RSX and DirectSound if you are using them. In all cases, you should perform compatibility testing on a variety of sound cards with various software installed (with and without RSX and DirectSound). Windows laptops tend to have nonstandard sound cards. Obtain the latest drivers and test on any laptops you are specifically targeting (as for a sales presentation).
Your ReadMe file should instruct your Windows users to update their sound card drivers (and RSX and DirectSound if applicable) if they encounter problems.
Sounds may skip during transitions or other processor- or disk-intensive activities. Either preload the sounds or avoid too much concurrent activity, such as loading or streaming other media. Refer to the distinctions between internal and external in Chapter 4 for additional insights.
Here are some common problems that are not specific to a given sound card:
- Sounds play in authoring mode, but not in a Projector
- You have most likely omitted the necessary Xtras. See "Xtras needed to play external sounds in Director 6 and 7" earlier in this chapter. You may also have failed to include the external sound files (AIFF, WAVE, or SWA) required by sound playFile or linked cast members.
- Director asks, "Where is xxxx?"
- You must include external sounds files in the same relative position to your Projector or Director movie as they were during authoring.
- Sounds can't be heard at all
- Check the soundLevel and soundEnabled properties and the volume for the particular item(s) of interest. See Table 15-12. Check the speakers by playing a test sound in the Windows Sound Control Panel.
- Sounds drop out in somewhat arbitrary fashion
- In low-memory situations, Director drop outs the sound first. Reduce and optimize memory usage as described in Chapter 9, Memory and Performance.
- Sound plays too late, particularly under Windows
- If using puppetSounds, issue an updateStage command to trigger the sound. Playing multiple sounds under Windows introduces a delay (see "Sound mixing latency" earlier in this chapter). Trigger sounds earlier in the Score or premix the audio into one sound using a sound editor.
- Sound synchronization is not accurate
- Sound synchronization in Director's Score is never guaranteed, especially when mixing multiple sounds under Windows. Use cue points for improved synchronization and ensure that they are located at the proper points within the audio file (build in some lead time if necessary). Use an audio track in a digital video file for optimal synchronization.
- Sounds pop and click or make screeching noises
- Use a clean audio source. Corrupt audio will sound like static or glass shattering and must be replaced or recompressed. Include about 100 to 500 milliseconds of silence at the beginning and end of sounds to reduce popping. RSX and/or DirectSound may also cause popping.
- Very short sounds don't play under Windows
- Sounds shorter than 250 milliseconds (1/4 second) may not play at all. Add at least 50 milliseconds of silence to the beginning of the sound and pad the end with some silence if the sound is very short.
- Problems playing both QT-based and Director-based sounds simultaneously
- Playing both QuickTime audio and Director audio is not reliably supported under Windows. See "Sound Mixing Under Windows" earlier in this chapter.
- Problems switching between QT-based and Director-based sounds
- Make sure that all Director sounds are stopped using sound stop, sound close, and puppetSound 0 before playing a QT sound. Ensure that QT sound is stopped by setting the movieRate of sprite to 0 or setting the sound of member to FALSE before playing a non-QT sound. Allow Director to release the sound device by setting the soundKeepDevice to FALSE.
- A digital video's audio can't be heard even though no other sounds are playing
- Ensure that the video contains an audio track and that the sound of member is TRUE and the volume of sprite is 255. Ensure that the movieRate of sprite is 1. Check the soundLevel property. Under Windows, you may need to stop all non-QuickTime sounds to free the sound card for QuickTime usage if not using QT3Mix.
- Multiple audio tracks in a digital video cannot be heard
- QuickTime 2 for Windows can't handle more than one audio track inside a single QuickTime movie. If necessary, separate the excess audio tracks into distinct audio-only QT movies. QuickTime 3 should handle multiple tracks within a single QuickTime movie and multiple QuickTime movies with separate audio tracks.
- Sounds play at the wrong pitch (chipmunk-like or very low-pitched)
- If using a non-standard rate, such as 15 KHz, Director will resample audio to the closest rate that the sound card supports. Use the standard Windows sampling rates: 11.025, 22.050, or 44.100 kHz.
- Last few seconds of SWA or MP3 don't play
- An SWA won't play the final few seconds of its sound if there is a cue point at the very end of the file. Use an alternate method for timing near the end of an SWA stream, such as checking the currentTime of sprite manually. The last few seconds of an MP3 file won't play in D7.
- Can't import AIFF, WAVE, or SWA files
- The MIX Services and Sound Import Export Xtras are needed to import sound files both during authoring and at runtime. Director won't import some compressed WAVE files, depending on the type of compression.
- Tempo channel Wait setting interferes with interactivity
- In Director 5, the Tempo channel locked out interactivity. In Director 6, using the Wait for Cue Point option may prevent Custom Buttons from behaving as expected. In either case, use Lingo alternatives to the Tempo channel, such as manually checking soundBusy( ) or waiting for cuePassed events as shown in Examples 15-4 and 15-6.
- Exported QT or AVI files missing sounds
- Sound tracks are often omitted during QuickTime export. Even if exported successfully, Director sometimes creates an excessive number of separate audio tracks in the QuickTime movie. Add the sound track to the exported digital video with a separate QuickTime editing application.
Sound Editing Applications and Utilities
Many applications can be used to create Director-ready sound files in either AIFF or WAVE format. SWA files can be created via SoundEdit, Peak LE, or Director for Windows.
SoundEdit is made by Macromedia and is included with Director 6 Multimedia Studio for the Macintosh (see also the SoundEdit Automator and SWAtomator utilities that come with it):
http://www.macromedia.com/support/soundedit/Peak LE is included with the Director 7 Multimedia Studio for the Macintosh. The full version is sold by Bias Inc., which also sells Sound Designer:
http://www.bias-inc.comSound Forge XP (included with Director Multimedia Studio for Windows) is made by Sonic Foundry:
http://www.sfoundry.comCool Edit 96 shareware and professional versions (Windows only):
http://www.syntrillium.comBarbaBatch by MacSourcery (Mac only) converts batches of sounds between various formats:
http://www.macsourcery.com/web/BarbaBatch/barbabatch.html
1. Any internal sounds are stored in Director's internal format, and are completely cross-platform. D7 can import SWA files via File
Import, but they are converted to Director's internal format.
2. AIFC is an AIFF file with IMA compression.
3. The Sun AU Import Export Xtra included with D6.5 and D7 is required for Sun AU file support.
4. Unsupported audio sampling rates under Windows are resampled to the nearest supported rate on the fly, distorting the pitch in some cases. The Macintosh supports just about any sampling rate, including variants such as 11,126, 22.253, and 22.254 MHz.
5. Windows does not necessarily allow Director-based and QuickTime or AVI-based audio to be played simultaneously and multiple sounds introduce latency. See "Sound Mixing Under Windows" later in this chapter for details.
6. The system audio buffer size is unrelated to the SWA buffer length, which can be set for each SWA member.
7. The Windows Volume Control accessory can be opened by double-clicking the speaker icon in the Task Bar or running C:\Windows\SNDVOL32.EXE, which is accessed via Start
Programs
Accessories
Multimedia
Volume Control.
8. Internal sounds are generally loopable, whereas external sound files are not. Even sounds that are not automatically loopable can be looped manually via Lingo, although the loop may not be as seamless as with internal sound cast members.
9. The third-party MPEG Xtra supports cue points, as may other Xtras.
10. See "Volume Levels and Sound Fades" later in this chapter.
11. You can use the Tempo channel or cue points to wait for any type of media that supports them. See "Cue Points and Timing" later in this chapter.
12. In D6.5, use the volumeLevel, mRate, and mTime of sprite properties for QT3 sprites. In D7, these properties are deprecated; use the volume, movieRate, and movieTime of sprite instead.
13. Preferred method in most Windows 95/98 configurations.
14. Only supported method under Windows 3.1.
15. Preferred method under Windows NT with SP3 and DirectSound 3.
16. WaveOut is the only supported configuration in SW7.0 unless QTW3 is installed and the QT3Asset.X32 Xtra is downloaded.
17. Cmd-Opt-M (Mac) or Ctrl-Alt-M (Windows) toggles the soundEnabled and does not affect the soundLevel property.
18. All SWA is decompressed as 16-bit audio. Stereo sounds are automatically folded (flattened) to monaural if an output rate of 32 Kbps or lower is used.
19. Only external SWA files can be compressed to 8, 16, or 24 Kbps as is necessary for streaming over a modem. Internal Director sounds can be compressed only to 32 Kbps or higher.
20. Returns 0, [ ], EMPTY, or meaningless data unless the state of member is 2, 3, 4, or 5.
21. Appears for the fist time in Director 6. Not supported in Shockwave for Director 5.
22. GetErrorString(0) returns the EMPTY string in my tests, not "OK" as claimed by Macromedia's documentation.
23. The soundLevel settings in the DIRECTOR.INI file can range from 0 to 65,535, but the output response is nonlinear. The default settings for soundLevel1 through soundLevel3 are inaudible on some PCs.
24. D7 only. MacroMix.X32 is bundled with SW7.0.
25. D7.0.1 only. MacroMix.X32 and DirectSound.X32b are bundled with SW7.0.1.
Back to: Sample Chapter Index
Back to: Director in a Nutshell
© 2001, O'Reilly & Associates, Inc.
webmaster@oreilly.com