Commit 42c916b

Nick committed on
Removed bass, replaced with SDL2
commit 42c916b80a44008146376b8a11293d9ba41dc6af parent 459c53b
2 changed files +31−41
ModifiedGBEmu.lpi +8−26
@@ -43,43 +43,25 @@
43 </Mode0> 43 </Mode0>
44 </Modes> 44 </Modes>
45 </RunParams> 45 </RunParams>
46 <RequiredPackages Count="12"> 46 <RequiredPackages Count="6">
47 <Item1> 47 <Item1>
48 <PackageName Value="laz_acs_lib"/> 48 <PackageName Value="etpackage"/>
49 </Item1> 49 </Item1>
50 <Item2> 50 <Item2>
51 <PackageName Value="etpackage"/> 51 <PackageName Value="RackCtlsPkg"/>
52 </Item2> 52 </Item2>
53 <Item3> 53 <Item3>
54 <PackageName Value="LazColorPalette"/> 54 <PackageName Value="SynEdit"/>
55 </Item3> 55 </Item3>
56 <Item4> 56 <Item4>
57 <PackageName Value="RackCtlsPkg"/> 57 <PackageName Value="eccontrols"/>
58 </Item4> 58 </Item4>
59 <Item5> 59 <Item5>
60 <PackageName Value="laz_fpspreadsheet_visual"/> 60 <PackageName Value="LazControls"/>
61 </Item5> 61 </Item5>
62 <Item6> 62 <Item6>
63 <PackageName Value="RunTimeTypeInfoControls"/>
64 </Item6>
65 <Item7>
66 <PackageName Value="virtualtreeview_package"/>
67 </Item7>
68 <Item8>
69 <PackageName Value="SynEdit"/>
70 </Item8>
71 <Item9>
72 <PackageName Value="eccontrols"/>
73 </Item9>
74 <Item10>
75 <PackageName Value="LazControls"/>
76 </Item10>
77 <Item11>
78 <PackageName Value="BGRABitmapPack"/>
79 </Item11>
80 <Item12>
81 <PackageName Value="LCL"/> 63 <PackageName Value="LCL"/>
82 </Item12> 64 </Item6>
83 </RequiredPackages> 65 </RequiredPackages>
84 <Units Count="23"> 66 <Units Count="23">
85 <Unit0> 67 <Unit0>
@@ -205,7 +187,7 @@
205 <Version Value="11"/> 187 <Version Value="11"/>
206 <PathDelim Value="\"/> 188 <PathDelim Value="\"/>
207 <SearchPaths> 189 <SearchPaths>
208 <IncludeFiles Value="Debugger;Directx;GPU;CPU;Sound;Global;Components;$(ProjOutDir)"/> 190 <IncludeFiles Value="SDL2_headers;GPU;CPU;Sound;Global;$(ProjOutDir)"/>
209 <OtherUnitFiles Value="GPU;CPU;Sound;Global"/> 191 <OtherUnitFiles Value="GPU;CPU;Sound;Global"/>
210 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 192 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
211 </SearchPaths> 193 </SearchPaths>
ModifiedSound/sound.pas +23−15
@@ -166,15 +166,15 @@ var
166 166
167 implementation 167 implementation
168 168
169 uses vars, bass; 169 uses vars, sdl2;
170 170
171 const 171 const
172 playbackFrequency = 44100; 172 playbackFrequency = 44100;
173 sampleCycles: longint = (8192 * 1024) div playbackFrequency; 173 sampleCycles: longint = (8192 * 1024) div playbackFrequency;
174 TooFullThreshold: DWORD = (playbackFrequency div 10)*sizeof(single); //0.1s 174 TooFullThreshold: Integer = (playbackFrequency div 10)*sizeof(single); //0.1s
175 175
176 var 176 var
177 playStream: HStream; 177 playStream: TSDL_AudioDeviceID;
178 bufCycles, bufLVal, bufRVal: integer; 178 bufCycles, bufLVal, bufRVal: integer;
179 179
180 procedure ResetSound; 180 procedure ResetSound;
@@ -198,27 +198,34 @@ end;
198 198
199 function SoundBufferTooFull: Boolean; 199 function SoundBufferTooFull: Boolean;
200 begin 200 begin
201 Result := BASS_ChannelGetData(PlayStream, nil, BASS_DATA_AVAILABLE) > TooFullThreshold; 201 Result := SoundBufferSize > TooFullThreshold
202 end; 202 end;
203 203
204 function SoundBufferSize: Integer; 204 function SoundBufferSize: Integer;
205 begin 205 begin
206 Result := BASS_ChannelGetData(PlayStream, nil, BASS_DATA_AVAILABLE); 206 Result := SDL_GetQueuedAudioSize(playStream)
207 end; 207 end;
208 208
209 procedure EnableSound; 209 procedure EnableSound;
210 var
211 Want, Have: TSDL_AudioSpec;
210 begin 212 begin
211 if soundEnable then 213 if soundEnable then
212 exit; 214 exit;
213 215
214 BASS_Init(-1, playbackFrequency, 0, 0, nil); 216 Want := Default(TSDL_AudioSpec);
215 PlayStream := BASS_StreamCreate( 217 Have := Default(TSDL_AudioSpec);
216 playbackFrequency, 218
217 2, 219 SDL_Init(SDL_INIT_AUDIO);
218 BASS_SAMPLE_FLOAT, 220
219 StreamProc(STREAMPROC_PUSH), 221 Want.freq := playbackFrequency;
220 nil); 222 Want.format := AUDIO_F32;
221 BASS_ChannelPlay(PlayStream, True); 223 Want.channels := 2;
224 Want.samples := 512; //????
225 Want.callback := nil;
226
227 PlayStream := SDL_OpenAudioDevice(nil, 0, @Want, @Have, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
228 SDL_PauseAudioDevice(playStream, 0);
222 229
223 soundEnable := True; 230 soundEnable := True;
224 bufCycles := 0; 231 bufCycles := 0;
@@ -231,7 +238,8 @@ begin
231 if not soundEnable then 238 if not soundEnable then
232 exit; 239 exit;
233 240
234 BASS_Free; 241 SDL_CloseAudioDevice(playStream);
242 SDL_Quit;
235 243
236 soundEnable := False; 244 soundEnable := False;
237 end; 245 end;
@@ -250,7 +258,7 @@ begin
250 bufCycles := 0; 258 bufCycles := 0;
251 bufLVal := 0; 259 bufLVal := 0;
252 bufRVal := 0; 260 bufRVal := 0;
253 BASS_StreamPutData(PlayStream, @buf, 8 {2 32-bit float samples}); 261 SDL_QueueAudio(playStream, @buf, 8);
254 end; 262 end;
255 end; 263 end;
256 264