I’m using “afplay” to play wave files, but I cannot find any function (or equivalent command) to fadein or fadeout the sound from scripting.
I cannot use an app to play/control the sound (such as iTunes, Quicktime, Vlc or so) but I’d prefer to stick to terminal/applescript commands.
You guys have any idea if this is possible at all?
You would prefer stick to terminal/applescript commands, but there is some limitations with shell commands. For example, you can’t use ignoring application responses block of AppleScript, which is needed in the given case. Why not control Quicktime on the background as here?:
set wavAudio to choose file of type "wav" with prompt "WELCOME TO MODIFIED AFPLAY!
PLEASE, SELECT WAV AUDIO FILE TO PLAY"
tell application "QuickTime Player"
open wavAudio
ignoring application responses
play document 1
end ignoring
end tell
-- Gradually increase the volume
repeat with X from 0 to 100
set volume output volume X
delay 0.1
end repeat
-- Gradually decrease the volume
repeat with X from 100 to 0 by -1
set volume output volume X
delay 0.1
end repeat
Of course, you can save the do shell script “afplay …” as an application and use it instead of QuickTime, but this will be a meaningless replacement.