Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TigerPRO

macrumors 6502
Original poster
Mar 27, 2003
414
0
Wisconsin
If anyone has heard of any application, script, or plugin that can fade out the volume of my computer at a specified moment for specified duration, could you let me know? I'm running some should effects on our PowerBook, and I'm playing them as AIFFs in Quicktime. I need to have a way of automatically and smoothly fading the volume down. Seems like simple task, but I haven't been able to find anything like it. I know I can manually drag the volume slider, but that's cumbersome and inaccurate. I need a worry-free way of doing this. Have any of you come across something I could use? Thanks.
 

bousozoku

Moderator emeritus
Jun 25, 2002
15,718
1,893
Lard
I'm definitely not certain what you want, but I wrote the follwing AppleScript:

Code:
repeat with volumeLevel from 7 to 0 by -1
	set volume volumeLevel
end repeat
repeat with volumeLevel from 0 to 7 by 1
	set volume volumeLevel
end repeat
 

TigerPRO

macrumors 6502
Original poster
Mar 27, 2003
414
0
Wisconsin
bousozoku said:
I'm definitely not certain what you want, but I wrote the follwing AppleScript:

Code:
repeat with volumeLevel from 7 to 0 by -1
	set volume volumeLevel
end repeat
repeat with volumeLevel from 0 to 7 by 1
	set volume volumeLevel
end repeat
Thanks! This almost exactly what I need. I was thinking AppleScript could do the job, but I don't know how to program in it YET.

How would that code look if you wanted it to fade from the CURRENT volume. Is there a way to set the fade out from where the volume is currently set? I noticed that it jumps up to 7 before going down. And finally, is there any way to put a time delay between each volume level decrease, so it doesn't go down as fast?
 

bousozoku

Moderator emeritus
Jun 25, 2002
15,718
1,893
Lard
I'm sure there is some way to get the current volume. I can't find any reference to it, though.

To slow the change in volume, add

delay x

to a separate line prior to the line with set volume, where x is the number of seconds to wait.
 

TigerPRO

macrumors 6502
Original poster
Mar 27, 2003
414
0
Wisconsin
bousozoku said:
I'm sure there is some way to get the current volume. I can't find any reference to it, though.

To slow the change in volume, add

delay x

to a separate line prior to the line with set volume, where x is the number of seconds to wait.
Great, it's working perfectly now. But I think I'll have to search for a different solution. Because you can hear the volume steps very predominately. So the fade it not smooth at all. But it can't be helped when you only have a scale from 1 to 7. Oh well. Thanks for your help though.
 

HexMonkey

Administrator emeritus
Feb 5, 2004
2,240
504
New Zealand
Since you're playing them in Quicktime, use this code. The advantage to this is that it has a scale of 0 to 256, much more accurate than the 0 to 7 scale of the system sound.

Code:
tell application "QuickTime Player"
	set delayTime to 0
	set soundChangeAmount to 1
	
	set currVolume to sound volume of front movie
	repeat with volumeLevel from currVolume to 0 by -soundChangeAmount
		set sound volume of front movie to volumeLevel
		delay delayTime
	end repeat
end tell

Change delayTime and soundChangeAmount as appropriate. This script applies to the front player, but can be modifed for others. Eg, if you have multiple sounds playing at the same volume that you want to fade out, you can change 'set sound volume of front movie to volumeLevel' to 'set sound volume of every movie to volumeLevel'. If you want to change to volume of a player with a specific name, change both occurances of 'front movie' to 'movie "[Sound name]"'.
 

TigerPRO

macrumors 6502
Original poster
Mar 27, 2003
414
0
Wisconsin
HexMonkey said:
Since you're playing them in Quicktime, use this code. The advantage to this is that it has a scale of 0 to 256, much more accurate than the 0 to 7 scale of the system sound.

Code:
tell application "QuickTime Player"
	set delayTime to 0
	set soundChangeAmount to 1
	
	set currVolume to sound volume of front movie
	repeat with volumeLevel from currVolume to 0 by -soundChangeAmount
		set sound volume of front movie to volumeLevel
		delay delayTime
	end repeat
end tell

Change delayTime and soundChangeAmount as appropriate. This script applies to the front player, but can be modifed for others. Eg, if you have multiple sounds playing at the same volume that you want to fade out, you can change 'set sound volume of front movie to volumeLevel' to 'set sound volume of every movie to volumeLevel'. If you want to change to volume of a player with a specific name, change both occurances of 'front movie' to 'movie "[Sound name]"'.
Beautiful! Thank you very much, this will do the trick perfectly!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.