174 |
174 |
175 Volume:= 0; |
175 Volume:= 0; |
176 ChangeVolume(cInitVolume) |
176 ChangeVolume(cInitVolume) |
177 end; |
177 end; |
178 |
178 |
179 procedure ReleaseSound; |
179 // when complete is false, this procedure just releases some of the chucks on inactive channels |
|
180 // this way music is not stopped, nor are chucks currently being plauyed |
|
181 procedure ReleaseSound(complete: boolean); |
180 var i: TSound; |
182 var i: TSound; |
181 t: Longword; |
183 t: Longword; |
182 begin |
184 begin |
|
185 // release and nil all sounds |
183 for t:= 0 to cMaxTeams do |
186 for t:= 0 to cMaxTeams do |
184 if voicepacks[t].name <> '' then |
187 if voicepacks[t].name <> '' then |
185 for i:= Low(TSound) to High(TSound) do |
188 for i:= Low(TSound) to High(TSound) do |
186 if voicepacks[t].chunks[i] <> nil then |
189 if voicepacks[t].chunks[i] <> nil then |
187 Mix_FreeChunk(voicepacks[t].chunks[i]); |
190 if complete or (Mix_Playing(lastChan[i]) = 0) then |
188 |
191 begin |
189 if Mus <> nil then |
192 Mix_HaltChannel(lastChan[i]); |
190 Mix_FreeMusic(Mus); |
193 lastChan[i]:= -1; |
191 |
194 Mix_FreeChunk(voicepacks[t].chunks[i]); |
192 // make sure all instances of sdl_mixer are unloaded before continuing |
195 voicepacks[t].chunks[i]:= nil; |
193 while Mix_Init(0) <> 0 do |
196 end; |
194 Mix_Quit(); |
197 |
195 |
198 // stop music |
196 Mix_CloseAudio(); |
199 if complete then |
|
200 begin |
|
201 if Mus <> nil then |
|
202 begin |
|
203 Mix_HaltMusic(); |
|
204 Mix_FreeMusic(Mus); |
|
205 Mus:= nil; |
|
206 end; |
|
207 |
|
208 // make sure all instances of sdl_mixer are unloaded before continuing |
|
209 while Mix_Init(0) <> 0 do |
|
210 Mix_Quit(); |
|
211 |
|
212 Mix_CloseAudio(); |
|
213 end; |
197 end; |
214 end; |
198 |
215 |
199 procedure SoundLoad; |
216 procedure SoundLoad; |
200 var i: TSound; |
217 var i: TSound; |
201 t: Longword; |
218 t: Longword; |
203 begin |
220 begin |
204 if not isSoundEnabled then exit; |
221 if not isSoundEnabled then exit; |
205 |
222 |
206 defVoicepack:= AskForVoicepack('Default'); |
223 defVoicepack:= AskForVoicepack('Default'); |
207 |
224 |
|
225 // initialize all voices to nil so that they can be loaded when needed |
208 for t:= 0 to cMaxTeams do |
226 for t:= 0 to cMaxTeams do |
209 if voicepacks[t].name <> '' then |
227 if voicepacks[t].name <> '' then |
210 for i:= Low(TSound) to High(TSound) do |
228 for i:= Low(TSound) to High(TSound) do |
211 voicepacks[t].chunks[i]:= nil; |
229 voicepacks[t].chunks[i]:= nil; |
212 |
230 |
|
231 // preload all the big sound files (>32k) that would otherwise lockup the game |
213 for i:= Low(TSound) to High(TSound) do |
232 for i:= Low(TSound) to High(TSound) do |
214 begin |
233 begin |
215 defVoicepack^.chunks[i]:= nil; |
234 defVoicepack^.chunks[i]:= nil; |
216 // preload all the big sound files (>32k) that would otherwise lockup the game |
|
217 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, |
235 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, |
218 sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
236 sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
219 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
237 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
220 begin |
238 begin |
221 s:= UserPathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
239 s:= UserPathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |