78 Volume:= Mix_Volume(-1, Volume) |
87 Volume:= Mix_Volume(-1, Volume) |
79 end; |
88 end; |
80 |
89 |
81 procedure ReleaseSound; |
90 procedure ReleaseSound; |
82 var i: TSound; |
91 var i: TSound; |
|
92 t: Longword; |
83 begin |
93 begin |
84 for i:= Low(TSound) to High(TSound) do |
94 for t:= 0 to cMaxTeams do |
85 Mix_FreeChunk(Soundz[i].id); |
95 if voicepacks[t].name <> '' then |
|
96 for i:= Low(TSound) to High(TSound) do |
|
97 if voicepacks[t].chunks[i] <> nil then |
|
98 Mix_FreeChunk(voicepacks[t].chunks[i]); |
86 |
99 |
87 Mix_FreeMusic(Mus); |
100 Mix_FreeMusic(Mus); |
88 Mix_CloseAudio |
101 Mix_CloseAudio |
89 end; |
102 end; |
90 |
103 |
91 procedure SoundLoad; |
104 procedure SoundLoad; |
92 var i: TSound; |
105 var i: TSound; |
93 s: shortstring; |
106 s: shortstring; |
|
107 t: Longword; |
94 begin |
108 begin |
95 if not isSoundEnabled then exit; |
109 if not isSoundEnabled then exit; |
96 AskForVoicepack('Default'); |
110 |
|
111 defVoicepack:= AskForVoicepack('Default'); |
|
112 SetVoicePack(defVoicepack); |
97 |
113 |
98 for i:= Low(TSound) to High(TSound) do |
114 for i:= Low(TSound) to High(TSound) do |
99 begin |
115 if Soundz[i].Path <> ptVoices then |
100 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
116 begin |
101 WriteToConsole(msgLoading + s + ' '); |
117 s:= Pathz[Soundz[i].Path] + '/Default/' + Soundz[i].FileName; |
102 Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
118 WriteToConsole(msgLoading + s + ' '); |
103 TryDo(Soundz[i].id <> nil, msgFailed, true); |
119 defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
104 WriteLnToConsole(msgOK); |
120 TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); |
105 end; |
121 WriteLnToConsole(msgOK); |
|
122 end; |
|
123 |
|
124 for t:= 0 to cMaxTeams do |
|
125 if voicepacks[t].name <> '' then |
|
126 for i:= Low(TSound) to High(TSound) do |
|
127 if Soundz[i].Path = ptVoices then |
|
128 begin |
|
129 s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; |
|
130 WriteToConsole(msgLoading + s + ' '); |
|
131 voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
132 if voicepacks[t].chunks[i] = nil then |
|
133 WriteLnToConsole(msgFailed) |
|
134 else |
|
135 WriteLnToConsole(msgOK) |
|
136 end; |
106 end; |
137 end; |
107 |
138 |
108 procedure PlaySound(snd: TSound; infinite: boolean); |
139 procedure PlaySound(snd: TSound; infinite: boolean); |
109 var loops: LongInt; |
140 var loops: LongInt; |
110 begin |
141 begin |
111 if (not isSoundEnabled) or fastUntilLag then exit; |
142 if (not isSoundEnabled) or fastUntilLag then exit; |
112 if infinite then loops:= -1 else loops:= 0; |
143 if infinite then loops:= -1 else loops:= 0; |
113 lastChan[snd]:= Mix_PlayChannelTimed(-1, Soundz[snd].id, loops, -1) |
144 |
|
145 if currentVP^.chunks[snd] <> nil then |
|
146 lastChan[snd]:= Mix_PlayChannelTimed(-1, currentVP^.chunks[snd], loops, -1) |
|
147 else |
|
148 lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], loops, -1) |
114 end; |
149 end; |
115 |
150 |
116 procedure StopSound(snd: TSound); |
151 procedure StopSound(snd: TSound); |
117 begin |
152 begin |
118 if not isSoundEnabled then exit; |
153 if not isSoundEnabled then exit; |