add spatial distance scaler to init

main
cosmonaut 2021-10-24 16:24:37 -07:00
parent 4fceb026da
commit a8993eb776
2 changed files with 7 additions and 7 deletions

View File

@ -132,8 +132,8 @@ typedef struct FAudioGMS_SoundInstance
} parent; } parent;
} FAudioGMS_SoundInstance; } FAudioGMS_SoundInstance;
static const float SPEED_OF_SOUND = 343.5f;
static const float DOPPLER_SCALE = 1.0f; static const float DOPPLER_SCALE = 1.0f;
static const float CURVE_DISTANCE_SCALER = 1.0f;
typedef struct FAudioGMS_Device typedef struct FAudioGMS_Device
{ {
@ -144,7 +144,7 @@ typedef struct FAudioGMS_Device
FAudioMasteringVoice *masteringVoice; FAudioMasteringVoice *masteringVoice;
F3DAUDIO_LISTENER listener; F3DAUDIO_LISTENER listener;
float speedOfSound; float spatialDistanceScale;
FAudioGMS_StaticSound **staticSounds; FAudioGMS_StaticSound **staticSounds;
uint32_t staticSoundCount; uint32_t staticSoundCount;
@ -183,7 +183,7 @@ static inline FAudioGMS_SoundInstance* FAudioGMS_INTERNAL_LookupSoundInstance(ui
} }
} }
void FAudioGMS_Init(double speedOfSound) void FAudioGMS_Init(double spatialDistanceScale)
{ {
device = SDL_malloc(sizeof(FAudioGMS_Device)); device = SDL_malloc(sizeof(FAudioGMS_Device));
@ -256,11 +256,11 @@ void FAudioGMS_Init(double speedOfSound)
return; return;
} }
device->speedOfSound = speedOfSound; device->spatialDistanceScale = spatialDistanceScale;
F3DAudioInitialize( F3DAudioInitialize(
device->deviceDetails.OutputFormat.dwChannelMask, device->deviceDetails.OutputFormat.dwChannelMask,
device->speedOfSound, SPEED_OF_SOUND,
device->handle3D device->handle3D
); );
@ -781,7 +781,7 @@ static void FAudioGMS_INTERNAL_StaticSound_AddEmitter(FAudioGMS_SoundInstance* i
instance->emitter->InnerRadiusAngle = 0; instance->emitter->InnerRadiusAngle = 0;
instance->emitter->ChannelCount = instance->dspSettings.SrcChannelCount; instance->emitter->ChannelCount = instance->dspSettings.SrcChannelCount;
instance->emitter->CurveDistanceScaler = CURVE_DISTANCE_SCALER; instance->emitter->CurveDistanceScaler = device->spatialDistanceScale;
instance->emitter->DopplerScaler = 1.0f; instance->emitter->DopplerScaler = 1.0f;
instance->emitter->Position.x = x; instance->emitter->Position.x = x;

View File

@ -39,7 +39,7 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
FAUDIOGMSAPI void FAudioGMS_Init(double speedOfSound); /* recommend about 1500? for 2D game */ FAUDIOGMSAPI void FAudioGMS_Init(double spatialDistanceScale); /* recommend about 50 for a 2D game, 1 for a 3D game */
FAUDIOGMSAPI double FAudioGMS_StaticSound_LoadWAV(char *filePath); /* returns a static sound ID */ FAUDIOGMSAPI double FAudioGMS_StaticSound_LoadWAV(char *filePath); /* returns a static sound ID */
FAUDIOGMSAPI void FAudioGMS_StaticSound_PlayOneOff(double staticSoundID, double pan, double pitch, double volume, double reverb); /* automatically frees itself when done! */ FAUDIOGMSAPI void FAudioGMS_StaticSound_PlayOneOff(double staticSoundID, double pan, double pitch, double volume, double reverb); /* automatically frees itself when done! */