hedgewars/uSound.pas
changeset 1128 9b3f42bf4eef
parent 1127 7e1b94a0fc1f
child 1137 58cd4277382e
equal deleted inserted replaced
1127:7e1b94a0fc1f 1128:9b3f42bf4eef
    46 if isSoundEnabled then
    46 if isSoundEnabled then
    47    isSoundEnabled:= Mix_OpenAudio(22050, $8010, 2, 512) = 0;
    47    isSoundEnabled:= Mix_OpenAudio(22050, $8010, 2, 512) = 0;
    48 if isSoundEnabled then WriteLnToConsole(msgOK)
    48 if isSoundEnabled then WriteLnToConsole(msgOK)
    49                   else WriteLnToConsole(msgFailed);
    49                   else WriteLnToConsole(msgFailed);
    50 Mix_AllocateChannels(Succ(chanTPU));
    50 Mix_AllocateChannels(Succ(chanTPU));
    51 Mix_VolumeMusic(64);
    51 if isMusicEnabled then Mix_VolumeMusic(64);
    52 
    52 
    53 Volume:= cInitVolume;
    53 Volume:= cInitVolume;
    54 if Volume < 0 then Volume:= 0;
    54 if Volume < 0 then Volume:= 0;
    55 Volume:= Mix_Volume(-1, Volume)
    55 Volume:= Mix_Volume(-1, Volume)
    56 end;
    56 end;
    97 
    97 
    98 procedure PlayMusic;
    98 procedure PlayMusic;
    99 var s: string;
    99 var s: string;
   100 begin
   100 begin
   101 if (not isSoundEnabled)
   101 if (not isSoundEnabled)
   102 	or (MusicFN = '') then exit;
   102 	or (MusicFN = '')
       
   103 	or (not isMusicEnabled)then exit;
   103 
   104 
   104 s:= PathPrefix + '/Music/' + MusicFN;
   105 s:= PathPrefix + '/Music/' + MusicFN;
   105 WriteToConsole(msgLoading + s + ' ');
   106 WriteToConsole(msgLoading + s + ' ');
   106 
   107 
   107 Mus:= Mix_LoadMUS(Str2PChar(s));
   108 Mus:= Mix_LoadMUS(Str2PChar(s));
   118 
   119 
   119 inc(Volume, voldelta);
   120 inc(Volume, voldelta);
   120 if Volume < 0 then Volume:= 0;
   121 if Volume < 0 then Volume:= 0;
   121 Mix_Volume(-1, Volume);
   122 Mix_Volume(-1, Volume);
   122 Volume:= Mix_Volume(-1, -1);
   123 Volume:= Mix_Volume(-1, -1);
   123 Mix_VolumeMusic(Volume * 5 div 8);
   124 if isMusicEnabled then Mix_VolumeMusic(Volume * 5 div 8);
   124 ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
   125 ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
   125 end;
   126 end;
   126 
   127 
   127 end.
   128 end.