33 procedure PlaySound(snd: TSound); |
33 procedure PlaySound(snd: TSound); |
34 procedure PlaySound(snd: TSound; keepPlaying: boolean); |
34 procedure PlaySound(snd: TSound; keepPlaying: boolean); |
35 procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
35 procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
36 procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); |
36 procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); |
37 function LoopSound(snd: TSound): LongInt; |
37 function LoopSound(snd: TSound): LongInt; |
|
38 function LoopSound(snd: TSound; fadems: LongInt): LongInt; |
38 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
39 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
|
40 function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; |
39 procedure PlayMusic; |
41 procedure PlayMusic; |
40 procedure PauseMusic; |
42 procedure PauseMusic; |
41 procedure ResumeMusic; |
43 procedure ResumeMusic; |
42 procedure ChangeMusic; |
44 procedure ChangeMusic; |
43 procedure StopSound(snd: TSound); |
45 procedure StopSound(snd: TSound); |
217 function LoopSound(snd: TSound): LongInt; |
219 function LoopSound(snd: TSound): LongInt; |
218 begin |
220 begin |
219 LoopSound:= LoopSound(snd, nil) |
221 LoopSound:= LoopSound(snd, nil) |
220 end; |
222 end; |
221 |
223 |
|
224 function LoopSound(snd: TSound; fadems: LongInt): LongInt; |
|
225 begin |
|
226 LoopSound:= LoopSound(snd, nil, fadems) |
|
227 end; |
|
228 |
222 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
229 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
|
230 begin |
|
231 LoopSound:= LoopSound(snd, nil, 0) |
|
232 end; |
|
233 |
|
234 function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; |
223 var s: shortstring; |
235 var s: shortstring; |
224 begin |
236 begin |
225 if (not isSoundEnabled) or fastUntilLag then |
237 if (not isSoundEnabled) or fastUntilLag then |
226 begin |
238 begin |
227 LoopSound:= -1; |
239 LoopSound:= -1; |
250 WriteToConsole(msgLoading + s + ' '); |
262 WriteToConsole(msgLoading + s + ' '); |
251 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
263 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
252 TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
264 TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
253 WriteLnToConsole(msgOK); |
265 WriteLnToConsole(msgOK); |
254 end; |
266 end; |
255 LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); |
267 if fadems > 0 then |
|
268 LoopSound:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1) |
|
269 else |
|
270 LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); |
256 end; |
271 end; |
257 end; |
272 end; |
258 |
273 |
259 procedure StopSound(snd: TSound); |
274 procedure StopSound(snd: TSound); |
260 begin |
275 begin |
261 if not isSoundEnabled then exit; |
276 if not isSoundEnabled then exit; |
|
277 |
262 if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
278 if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
263 begin |
279 begin |
264 Mix_HaltChannel(lastChan[snd]); |
280 Mix_HaltChannel(lastChan[snd]); |
265 lastChan[snd]:= -1; |
281 lastChan[snd]:= -1; |
266 end; |
282 end; |
270 begin |
286 begin |
271 if not isSoundEnabled then exit; |
287 if not isSoundEnabled then exit; |
272 |
288 |
273 if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
289 if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
274 Mix_HaltChannel(chn); |
290 Mix_HaltChannel(chn); |
|
291 end; |
|
292 |
|
293 procedure StopSound(chn, fadems: LongInt); |
|
294 begin |
|
295 if not isSoundEnabled then exit; |
|
296 |
|
297 if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
|
298 Mix_FadeOutChannel(chn, fadems); |
275 end; |
299 end; |
276 |
300 |
277 procedure PlayMusic; |
301 procedure PlayMusic; |
278 var s: shortstring; |
302 var s: shortstring; |
279 begin |
303 begin |