hedgewars/uSound.pas
changeset 6990 40e5af28d026
parent 6898 344b0dbd9690
child 7021 0c75512a8920
equal deleted inserted replaced
6989:4c35e9cf6057 6990:40e5af28d026
   466     SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false)
   466     SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false)
   467 end;
   467 end;
   468 
   468 
   469 function ChangeVolume(voldelta: LongInt): LongInt;
   469 function ChangeVolume(voldelta: LongInt): LongInt;
   470 begin
   470 begin
       
   471     ChangeVolume:= 0;
   471     if not isSoundEnabled then
   472     if not isSoundEnabled then
   472         exit(0);
   473         exit;
   473 
   474 
   474     inc(Volume, voldelta);
   475     inc(Volume, voldelta);
   475     if Volume < 0 then
   476     if Volume < 0 then
   476         Volume:= 0;
   477         Volume:= 0;
   477     Mix_Volume(-1, Volume);
   478     Mix_Volume(-1, Volume);
   481     ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
   482     ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
   482 end;
   483 end;
   483 
   484 
   484 procedure DampenAudio;
   485 procedure DampenAudio;
   485 begin
   486 begin
   486 previousVolume:= Volume;
   487     previousVolume:= Volume;
   487 ChangeVolume(-Volume * 7 div 9);
   488     ChangeVolume(-Volume * 7 div 9);
   488 end;
   489 end;
   489 
   490 
   490 procedure UndampenAudio;
   491 procedure UndampenAudio;
   491 begin
   492 begin
   492 ChangeVolume(previousVolume - Volume);
   493 ChangeVolume(previousVolume - Volume);