75 AskForVoicepack:= @voicepacks[i] |
75 AskForVoicepack:= @voicepacks[i] |
76 end; |
76 end; |
77 |
77 |
78 procedure InitSound; |
78 procedure InitSound; |
79 var i: TSound; |
79 var i: TSound; |
|
80 channels: LongInt; |
80 begin |
81 begin |
81 if not isSoundEnabled then exit; |
82 if not isSoundEnabled then exit; |
82 WriteToConsole('Init sound...'); |
83 WriteToConsole('Init sound...'); |
83 isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; |
84 isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; |
84 |
85 |
|
86 {$IFDEF IPHONEOS} |
|
87 channels:= 1; |
|
88 {$ELSE} |
|
89 channels:= 2; |
|
90 {$ENDIF} |
|
91 |
85 if isSoundEnabled then |
92 if isSoundEnabled then |
86 isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0; |
93 isSoundEnabled:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0; |
87 |
94 |
88 {$IFDEF SDL_MIXER_NEWER} |
95 {$IFDEF SDL_MIXER_NEWER} |
89 WriteToConsole('Init SDL_mixer... '); |
96 WriteToConsole('Init SDL_mixer... '); |
90 SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); |
97 SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); |
91 WriteLnToConsole(msgOK); |
98 WriteLnToConsole(msgOK); |
134 s:shortstring; |
141 s:shortstring; |
135 begin |
142 begin |
136 if not isSoundEnabled then exit; |
143 if not isSoundEnabled then exit; |
137 |
144 |
138 defVoicepack:= AskForVoicepack('Default'); |
145 defVoicepack:= AskForVoicepack('Default'); |
139 |
146 |
140 for t:= 0 to cMaxTeams do |
147 for t:= 0 to cMaxTeams do |
141 if voicepacks[t].name <> '' then |
148 if voicepacks[t].name <> '' then |
142 for i:= Low(TSound) to High(TSound) do |
149 for i:= Low(TSound) to High(TSound) do |
143 voicepacks[t].chunks[i]:= nil; |
150 voicepacks[t].chunks[i]:= nil; |
144 |
151 |
145 for i:= Low(TSound) to High(TSound) do |
152 for i:= Low(TSound) to High(TSound) do |
146 begin |
153 begin |
147 defVoicepack^.chunks[i]:= nil; |
154 defVoicepack^.chunks[i]:= nil; |
148 // preload all the big sound files (>32k) that would otherwise lockup the game |
155 // preload all the big sound files (>32k) that would otherwise lockup the game |
149 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
156 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
150 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
157 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
151 begin |
158 begin |
152 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
159 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
153 WriteToConsole(msgLoading + s + ' '); |
160 WriteToConsole(msgLoading + s + ' '); |
154 defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
161 defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |