34 procedure free_uSound; |
34 procedure free_uSound; |
35 |
35 |
36 procedure InitSound; |
36 procedure InitSound; |
37 procedure ReleaseSound; |
37 procedure ReleaseSound; |
38 procedure SoundLoad; |
38 procedure SoundLoad; |
39 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack); |
39 procedure PlaySound(snd: TSound); |
40 procedure LoopSound(snd: TSound; voicepack: PVoicepack); |
40 procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
|
41 function LoopSound(snd: TSound): LongInt; |
|
42 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
41 procedure PlayMusic; |
43 procedure PlayMusic; |
42 procedure PauseMusic; |
44 procedure PauseMusic; |
43 procedure ResumeMusic; |
45 procedure ResumeMusic; |
44 procedure StopSound(snd: TSound); |
46 procedure StopSound(snd: TSound); |
|
47 procedure StopSound(chn: LongInt); |
45 function ChangeVolume(voldelta: LongInt): LongInt; |
48 function ChangeVolume(voldelta: LongInt): LongInt; |
46 function AskForVoicepack(name: shortstring): Pointer; |
49 function AskForVoicepack(name: shortstring): Pointer; |
47 |
50 |
48 |
51 |
49 implementation |
52 implementation |
150 {$IFDEF SDL_MIXER_NEWER} |
153 {$IFDEF SDL_MIXER_NEWER} |
151 Mix_Quit(); |
154 Mix_Quit(); |
152 {$ENDIF} |
155 {$ENDIF} |
153 end; |
156 end; |
154 |
157 |
155 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack); |
158 procedure PlaySound(snd: TSound); |
156 var loops: LongInt; |
159 begin |
|
160 PlaySound(snd, nil); |
|
161 end; |
|
162 |
|
163 procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
157 begin |
164 begin |
158 if (not isSoundEnabled) or fastUntilLag then exit; |
165 if (not isSoundEnabled) or fastUntilLag then exit; |
159 if infinite and (lastChan[snd] <> -1) then exit; |
|
160 if infinite then loops:= -1 else loops:= 0; |
|
161 |
166 |
162 if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then |
167 if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then |
163 lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], loops, -1) |
168 lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1) |
164 else |
169 else |
165 lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], loops, -1) |
170 lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) |
166 end; |
171 end; |
167 |
172 |
168 procedure LoopSound(snd: TSound; voicepack: PVoicepack); |
173 function LoopSound(snd: TSound): LongInt; |
|
174 begin |
|
175 LoopSound:= LoopSound(snd, nil) |
|
176 end; |
|
177 |
|
178 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
169 begin |
179 begin |
170 if (not isSoundEnabled) or fastUntilLag then exit; |
180 if (not isSoundEnabled) or fastUntilLag then exit; |
171 if lastChan[snd] <> -1 then exit; |
|
172 |
181 |
173 if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then |
182 if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then |
174 lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) |
183 LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) |
175 else |
184 else |
176 lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1) |
185 LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1) |
177 end; |
186 end; |
178 |
187 |
179 procedure StopSound(snd: TSound); |
188 procedure StopSound(snd: TSound); |
180 begin |
189 begin |
181 if not isSoundEnabled then exit; |
190 if not isSoundEnabled then exit; |