Skip to content

Commit 3a74546

Browse files
committed
[GEN] Fix legacy function calls to miles in WWAudio (#709)
1 parent 12b2e62 commit 3a74546

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

Generals/Code/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp

+20-4
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ void
164164
Sound2DHandleClass::Set_Sample_Pan (S32 pan)
165165
{
166166
if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
167-
::AIL_set_sample_pan (SampleHandle, pan);
167+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_sample_pan.
168+
// TheSuperHackers @todo Perhaps use float natively.
169+
float fVolume = 0.0F;
170+
::AIL_sample_volume_pan (SampleHandle, &fVolume, NULL);
171+
float fPan = pan / 127.0F;
172+
::AIL_set_sample_volume_pan (SampleHandle, fVolume, fPan);
168173
}
169174

170175
return ;
@@ -182,7 +187,10 @@ Sound2DHandleClass::Get_Sample_Pan (void)
182187
S32 retval = 0;
183188

184189
if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
185-
retval = ::AIL_sample_pan (SampleHandle);
190+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_sample_pan.
191+
float fPan = 0.5F;
192+
::AIL_sample_volume_pan (SampleHandle, NULL, &fPan);
193+
retval = fPan * 127;
186194
}
187195

188196
return retval;
@@ -198,7 +206,12 @@ void
198206
Sound2DHandleClass::Set_Sample_Volume (S32 volume)
199207
{
200208
if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
201-
::AIL_set_sample_volume (SampleHandle, volume);
209+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_sample_volume.
210+
// TheSuperHackers @todo Perhaps use float natively.
211+
float fPan = 0.5F;
212+
::AIL_sample_volume_pan (SampleHandle, NULL, &fPan);
213+
float fVolume = volume / 127.0F;
214+
::AIL_set_sample_volume_pan (SampleHandle, fVolume, fPan);
202215
}
203216
return ;
204217
}
@@ -215,7 +228,10 @@ Sound2DHandleClass::Get_Sample_Volume (void)
215228
S32 retval = 0;
216229

217230
if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
218-
retval = ::AIL_sample_volume (SampleHandle);
231+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_sample_volume.
232+
float fVolume = 0.0F;
233+
::AIL_sample_volume_pan (SampleHandle, &fVolume, NULL);
234+
retval = fVolume * 127;
219235
}
220236

221237
return retval;

Generals/Code/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp

+24-10
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,11 @@ SoundStreamHandleClass::Initialize (SoundBufferClass *buffer)
7575
if (Buffer != NULL) {
7676

7777
//
78-
// Create a stream from the sample handle
78+
// Create a stream
7979
//
80-
StreamHandle = ::AIL_open_stream_by_sample (WWAudioClass::Get_Instance ()->Get_2D_Driver (),
81-
SampleHandle, buffer->Get_Filename (), 0);
82-
83-
/*StreamHandle = ::AIL_open_stream (WWAudioClass::Get_Instance ()->Get_2D_Driver (),
84-
buffer->Get_Filename (), 0);*/
80+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_open_stream_by_sample.
81+
StreamHandle = ::AIL_open_stream (WWAudioClass::Get_Instance ()->Get_2D_Driver (),
82+
buffer->Get_Filename (), 0);
8583
}
8684

8785
return ;
@@ -163,7 +161,12 @@ void
163161
SoundStreamHandleClass::Set_Sample_Pan (S32 pan)
164162
{
165163
if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
166-
::AIL_set_stream_pan (StreamHandle, pan);
164+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_stream_pan.
165+
// TheSuperHackers @todo Perhaps use float natively.
166+
float fVolume = 0.0F;
167+
::AIL_stream_volume_pan (StreamHandle, &fVolume, NULL);
168+
float fPan = pan / 127.0F;
169+
::AIL_set_stream_volume_pan (StreamHandle, fVolume, fPan);
167170
}
168171
return ;
169172
}
@@ -180,7 +183,10 @@ SoundStreamHandleClass::Get_Sample_Pan (void)
180183
S32 retval = 0;
181184

182185
if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
183-
retval = ::AIL_stream_pan (StreamHandle);
186+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_stream_pan.
187+
float fPan = 0.5F;
188+
::AIL_stream_volume_pan (StreamHandle, NULL, &fPan);
189+
retval = fPan * 127;
184190
}
185191

186192
return retval;
@@ -196,7 +202,12 @@ void
196202
SoundStreamHandleClass::Set_Sample_Volume (S32 volume)
197203
{
198204
if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
199-
::AIL_set_stream_volume (StreamHandle, volume);
205+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_stream_volume.
206+
// TheSuperHackers @todo Perhaps use float natively.
207+
float fPan = 0.5F;
208+
::AIL_stream_volume_pan (StreamHandle, NULL, &fPan);
209+
float fVolume = volume / 127.0F;
210+
::AIL_set_stream_volume_pan (StreamHandle, fVolume, fPan);
200211
}
201212
return ;
202213
}
@@ -213,7 +224,10 @@ SoundStreamHandleClass::Get_Sample_Volume (void)
213224
S32 retval = 0;
214225

215226
if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) {
216-
retval = ::AIL_stream_volume (StreamHandle);
227+
// TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_stream_volume.
228+
float fVolume = 0.0F;
229+
::AIL_stream_volume_pan (StreamHandle, &fVolume, NULL);
230+
retval = fVolume * 127;
217231
}
218232

219233
return retval;

0 commit comments

Comments
 (0)