Date: Sun, 5 Feb 1995 20:27:32 -0800 From: Roger Jones <roger@LANMINDS.COM>Puppet sounds normally play in channel 1 so you can fadeout a puppetsound with "sound fadeout 1,fadeRate" where fadeRate is the speed of the fadeout in ticks.
There is an undocumented (and unsupported) use of the puppetsound command using two integer arguments that allows playback of up to eight puppetsounds at once (four on PC) as well as fading and crossfading puppetsounds. The first argument is the sound channel, the second is the castnum of the sound to play.
For example:
puppetsound 2,40 --would play sound cast 40 in channel 2. puppetsound 4, cast "introloop" --would play a cast named "introloop" in channel 4
Here are some simple examples for playing,fading, and crossfading puppetsounds:
--multichannel puppetsound handlers
--2/3/95
--play a puppetsound in specified channel
--on the mac whchannel can be (1-8)
--on the pc whchannel can be (1-4) this requires DFW 4.0.4
--whcast can be the castnum or castname of a sound
--example: playPupSnd(2,"Robotic Bang")
on playPupSnd whChannel,whcast
if not integerp(whcast) then set whcast = cast(whcast)
puppetsound whChannel,whcast
end
--playback head must be moving or going to the frame for fades or crossfade to work
--fade in a puppetsound in specified channel
--on the mac whchannel can be (1-8)
--on the pc whchannel can be (1-4) this requires DFW 4.0.4
--whcast can be the castnum or castname of a sound
--rate is the fadein speed in ticks
--example: soundFadeIn(2,"Robotic Bang",200)
on soundFadeIn whChannel,whcast,rate
set the volume of sound whChannel = 0
if not integerp(whcast) then set whcast = cast(whcast)
puppetsound whChannel,whcast
sound fadein whChannel,rate
end
--fade out a puppetsound in specified channel
--rate is the fadeout speed in ticks
--example: soundFadeOut(2,200)
on soundFadeOut whChannel,rate
if not soundbusy(whChannel) then exit
sound fadeout whChannel,rate
end
--whcast can be the castnum or castname of a sound
--inChannel is the channel for the sound fading in
--outChannel is the channel of the currently playing sound
--rate is crossfade speed in ticks
--example: crossfade("light and Easy",3,2,100)
on crossfade whcast,inChannel,outChannel,Rate
set the volume of sound inChannel = 0
if not integerp(whcast) then set whcast = cast(whcast)
puppetsound inChannel,whcast
sound fadein inChannel,rate
sound fadeout outChannel,rate
end
-- changeVolume fades a sound channel up or down to "newvolume" setting
-- changeVolume does not return until volume change is complete
-- changes volume in one step if fade is 0 or not set
-- whChannel is the channel to change volume
-- newvolume is the new volume setting (0 - 255)
-- faderate is an optional argument for the duration of the fade in ticks
-- examples: changeVolume(1,200,100) changeVolume(2,75)
on changeVolume whChannel,newvolume,fadeRate
set curvolume = the volume of sound whChannel
if curvolume = newvolume then exit
if not integerP(fadeRate) or fadeRate = 0 then
set the volume of sound whChannel = newvolume
exit
end if
set deltasteps = abs(curvolume-newvolume)
if integerP(deltasteps) then
set deltatime = float(fadeRate)/deltasteps
else set deltatime = 0
set elapsedtime = deltatime
startTimer
if curvolume < newvolume then
repeat with n = curVolume to newvolume
set the volume of sound whChannel = n
updatestage
repeat while the timer < elapsedtime
end repeat
set elapsedtime = elapsedtime + deltatime
end repeat
else
repeat with n = curVolume down to newvolume
set the volume of sound whChannel = n
updatestage
repeat while the timer < elapsedtime
end repeat
set elapsedtime = elapsedtime + deltatime
end repeat
end if
This technique works with eight channels in director 4.0.4 and four
channels in Director Windows 4.0.4. but since it is undocumented and
unsupported you use it at your own risk. Don't call Macromedia tech support
if it breaks in a future version.
Thanks to the omniscient John Dowdell for his AOL post on this topic.