diff -r b17aafd93c17 -r 48e1f9a04c28 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Fri Feb 25 16:32:24 2011 -0500 +++ b/hedgewars/uSound.pas Sat Feb 26 15:56:11 2011 +0100 @@ -35,7 +35,9 @@ procedure PlaySound(snd: TSound; voicepack: PVoicepack); procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); function LoopSound(snd: TSound): LongInt; +function LoopSound(snd: TSound; fadems: LongInt): LongInt; function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; +function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; procedure PlayMusic; procedure PauseMusic; procedure ResumeMusic; @@ -219,7 +221,17 @@ LoopSound:= LoopSound(snd, nil) end; +function LoopSound(snd: TSound; fadems: LongInt): LongInt; +begin + LoopSound:= LoopSound(snd, nil, fadems) +end; + function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; +begin + LoopSound:= LoopSound(snd, nil, 0) +end; + +function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; var s: shortstring; begin if (not isSoundEnabled) or fastUntilLag then @@ -252,13 +264,17 @@ TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); WriteLnToConsole(msgOK); end; - LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); + if fadems > 0 then + LoopSound:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1) + else + LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); end; end; procedure StopSound(snd: TSound); begin if not isSoundEnabled then exit; + if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then begin Mix_HaltChannel(lastChan[snd]); @@ -274,6 +290,14 @@ Mix_HaltChannel(chn); end; +procedure StopSound(chn, fadems: LongInt); +begin + if not isSoundEnabled then exit; + + if (chn <> -1) and (Mix_Playing(chn) <> 0) then + Mix_FadeOutChannel(chn, fadems); +end; + procedure PlayMusic; var s: shortstring; begin