104 if not isSoundEnabled then exit; |
105 if not isSoundEnabled then exit; |
105 WriteToConsole('Init OpenAL sound...'); |
106 WriteToConsole('Init OpenAL sound...'); |
106 isSoundEnabled:= openal_init(numSounds); |
107 isSoundEnabled:= openal_init(numSounds); |
107 if isSoundEnabled then WriteLnToConsole(msgOK) |
108 if isSoundEnabled then WriteLnToConsole(msgOK) |
108 else WriteLnToConsole(msgFailed); |
109 else WriteLnToConsole(msgFailed); |
|
110 |
|
111 Volume:=0; |
|
112 ChangeVolume(cInitVolume); |
109 end; |
113 end; |
110 |
114 |
111 procedure ReleaseSound; |
115 procedure ReleaseSound; |
112 begin |
116 begin |
113 if isMusicEnabled then openal_fadeout(Mus, 30); |
117 if isMusicEnabled then openal_fadeout(Mus, 30); |
114 openal_close(); |
118 openal_close(); |
115 end; |
119 end; |
116 |
120 |
117 procedure SoundLoad; |
121 procedure SoundLoad; |
118 const volume = 60; |
|
119 var i: TSound; |
122 var i: TSound; |
120 s: shortstring; |
123 s: shortstring; |
121 t: Longword; |
124 t: Longword; |
122 begin |
125 begin |
123 if not isSoundEnabled then exit; |
126 if not isSoundEnabled then exit; |
128 if Soundz[i].Path <> ptVoices then |
131 if Soundz[i].Path <> ptVoices then |
129 begin |
132 begin |
130 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
133 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
131 WriteToConsole(msgLoading + s + ' '); |
134 WriteToConsole(msgLoading + s + ' '); |
132 defVoicepack^.chunks[i]:= openal_loadfile (Str2PChar(s)); |
135 defVoicepack^.chunks[i]:= openal_loadfile (Str2PChar(s)); |
133 openal_setvolume(defVoicepack^.chunks[i],volume); |
|
134 TryDo(defVoicepack^.chunks[i] >= 0, msgFailed, true); |
136 TryDo(defVoicepack^.chunks[i] >= 0, msgFailed, true); |
135 WriteLnToConsole(msgOK); |
137 WriteLnToConsole(msgOK); |
136 end; |
138 end; |
137 |
139 |
138 for t:= 0 to cMaxTeams do |
140 for t:= 0 to cMaxTeams do |
141 if Soundz[i].Path = ptVoices then |
143 if Soundz[i].Path = ptVoices then |
142 begin |
144 begin |
143 s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; |
145 s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; |
144 WriteToConsole(msgLoading + s + ' '); |
146 WriteToConsole(msgLoading + s + ' '); |
145 voicepacks[t].chunks[i]:= openal_loadfile (Str2PChar(s)); |
147 voicepacks[t].chunks[i]:= openal_loadfile (Str2PChar(s)); |
146 openal_setvolume(voicepacks[t].chunks[i],volume); |
|
147 if voicepacks[t].chunks[i] < 0 then |
148 if voicepacks[t].chunks[i] < 0 then |
148 WriteLnToConsole(msgFailed) |
149 WriteLnToConsole(msgFailed) |
149 else |
150 else |
150 WriteLnToConsole(msgOK) |
151 WriteLnToConsole(msgOK) |
151 end; |
152 end; |
200 |
201 |
201 Mus:= openal_loadfile(Str2PChar(s)); |
202 Mus:= openal_loadfile(Str2PChar(s)); |
202 TryDo(Mus >= 0, msgFailed, false); |
203 TryDo(Mus >= 0, msgFailed, false); |
203 WriteLnToConsole(msgOK); |
204 WriteLnToConsole(msgOK); |
204 |
205 |
205 openal_setvolume(Mus, 60); |
206 //openal_setvolume(Mus, cInitVolume-40); |
206 openal_fadein(Mus, 20); |
207 openal_fadein(Mus, 20); |
207 openal_toggleloop(Mus); |
208 openal_toggleloop(Mus); |
208 end; |
209 end; |
209 |
210 |
210 function ChangeVolume(voldelta: LongInt): LongInt; |
211 function ChangeVolume(voldelta: LongInt): LongInt; |
211 begin |
212 begin |
212 if not isSoundEnabled then exit(0); |
213 if not isSoundEnabled then exit(0); |
213 openal_setglobalvolume(voldelta); |
214 |
|
215 inc(Volume, voldelta); |
|
216 if Volume < 0 then Volume:= 0; |
|
217 if Volume > 100 then Volume:= 100; |
|
218 |
|
219 openal_setglobalvolume(Volume); |
|
220 if isMusicEnabled then openal_setvolume(Mus, Volume shr 1); |
|
221 ChangeVolume:= Volume; |
214 end; |
222 end; |
215 |
223 |
216 procedure PauseMusic; |
224 procedure PauseMusic; |
217 begin |
225 begin |
218 if (MusicFN = '') or (not isMusicEnabled) then exit; |
226 if (MusicFN = '') or (not isMusicEnabled) then exit; |