From 30cb6959e03490efb03a59f228d457e71738ecdf Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 29 Nov 2021 10:45:08 -0800 Subject: [PATCH] add 3d orientation API --- gamemaker/extensions/FAudioGMS/FAudioGMS.dll | 4 +- gamemaker/extensions/FAudioGMS/FAudioGMS.yy | 20 ++++++++ src/FAudioGMS.c | 52 +++++++++++++++++++- src/FAudioGMS.h | 16 ++++++ 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/gamemaker/extensions/FAudioGMS/FAudioGMS.dll b/gamemaker/extensions/FAudioGMS/FAudioGMS.dll index 59c9164..2afdb95 100644 --- a/gamemaker/extensions/FAudioGMS/FAudioGMS.dll +++ b/gamemaker/extensions/FAudioGMS/FAudioGMS.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b9ca9d72cefbd6f9da1eef87324769053cfde6c596588141b5f494552ca46336 -size 1521664 +oid sha256:0ec97d81ca716b4d2ccb36f45fbdda5acc529ae89fd3b2d54f9285b9bb7ee2a1 +size 1522176 diff --git a/gamemaker/extensions/FAudioGMS/FAudioGMS.yy b/gamemaker/extensions/FAudioGMS/FAudioGMS.yy index e0393b4..db24bd5 100644 --- a/gamemaker/extensions/FAudioGMS/FAudioGMS.yy +++ b/gamemaker/extensions/FAudioGMS/FAudioGMS.yy @@ -181,6 +181,24 @@ 2, ],"resourceVersion":"1.0","name":"FAudioGMS_SoundInstance_QueueSyncPlay","tags":[],"resourceType":"GMExtensionFunction",}, {"externalName":"FAudioGMS_SoundInstance_SyncPlay","kind":1,"help":"FAudioGMS_SoundInstance_SyncPlay()","hidden":false,"returnType":2,"argCount":0,"args":[],"resourceVersion":"1.0","name":"FAudioGMS_SoundInstance_SyncPlay","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"FAudioGMS_SoundInstance_Set3DOrientation","kind":1,"help":"FAudioGMS_SoundInstance_Set3DOrientation(soundInstanceID, xFront, yFront, zFront, xTop, yTop, zTop)","hidden":false,"returnType":2,"argCount":0,"args":[ + 2, + 2, + 2, + 2, + 2, + 2, + 2, + ],"resourceVersion":"1.0","name":"FAudioGMS_SoundInstance_Set3DOrientation","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"FAudioGMS_SetListenerOrientation","kind":1,"help":"FAudioGMS_SetListenerOrientation(soundInstanceID, xFront, yFront, zFront, xTop, yTop, zTop)","hidden":false,"returnType":2,"argCount":0,"args":[ + 2, + 2, + 2, + 2, + 2, + 2, + 2, + ],"resourceVersion":"1.0","name":"FAudioGMS_SetListenerOrientation","tags":[],"resourceType":"GMExtensionFunction",}, ],"constants":[],"ProxyFiles":[ {"TargetMask":7,"resourceVersion":"1.0","name":"libFAudioGMS.so","tags":[],"resourceType":"GMProxyFile",}, {"TargetMask":3,"resourceVersion":"1.0","name":"FAudioGMSAndroidDummy.ext","tags":[],"resourceType":"GMProxyFile",}, @@ -202,6 +220,7 @@ {"name":"FAudioGMS_SoundInstance_SetVolume","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_SoundInstance_Set3DPosition","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_SoundInstance_Set3DVelocity","path":"extensions/FAudioGMS/FAudioGMS.yy",}, + {"name":"FAudioGMS_SoundInstance_Set3DOrientation","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_SoundInstance_SetTrackPositionInSeconds","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_SoundInstance_SetPlayRegion","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_SoundInstance_SetVolumeOverTime","path":"extensions/FAudioGMS/FAudioGMS.yy",}, @@ -225,6 +244,7 @@ {"name":"FAudioGMS_SetMasteringEffectGain","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_SetListenerPosition","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_SetListenerVelocity","path":"extensions/FAudioGMS/FAudioGMS.yy",}, + {"name":"FAudioGMS_SetListenerOrientation","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_ResumeAll","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_PauseAll","path":"extensions/FAudioGMS/FAudioGMS.yy",}, {"name":"FAudioGMS_StopAll","path":"extensions/FAudioGMS/FAudioGMS.yy",}, diff --git a/src/FAudioGMS.c b/src/FAudioGMS.c index 6929093..669c754 100644 --- a/src/FAudioGMS.c +++ b/src/FAudioGMS.c @@ -1391,7 +1391,37 @@ void FAudioGMS_SoundInstance_Set3DVelocity( } } -/* FIXME: this will die horribly if position is greater than total length */ +void FAudioGMS_SoundInstance_Set3DOrientation( + double soundInstanceID, + double xFront, + double yFront, + double zFront, + double xTop, + double yTop, + double zTop) +{ + RETURN_ON_NULL_DEVICE_VOID + FAudioGMS_SoundInstance *instance = + FAudioGMS_INTERNAL_LookupSoundInstance((uint32_t)soundInstanceID); + + if (instance != NULL) + { + if (!instance->is3D) + { + Log("Not a 3D sound!"); + return; + } + + instance->emitter->OrientFront.x = xFront; + instance->emitter->OrientFront.y = yFront; + instance->emitter->OrientFront.z = zFront; + + instance->emitter->OrientTop.x = xTop; + instance->emitter->OrientTop.y = yTop; + instance->emitter->OrientTop.z = zTop; + } +} + /* FIXME: this will die horribly if position is greater than total length */ void FAudioGMS_SoundInstance_SetTrackPositionInSeconds( double soundInstanceID, double trackPositionInSeconds) @@ -1618,7 +1648,25 @@ void FAudioGMS_SetListenerVelocity(double xVelocity, double yVelocity, double zV device->listener.Velocity.z = zVelocity; } -static void FAudioGMS_INTERNAL_SoundInstance_Destroy(FAudioGMS_SoundInstance *instance) +void FAudioGMS_SetListenerOrientation( + double soundInstanceID, + double xFront, + double yFront, + double zFront, + double xTop, + double yTop, + double zTop) +{ + RETURN_ON_NULL_DEVICE_VOID + device->listener.OrientFront.x = xFront; + device->listener.OrientFront.y = yFront; + device->listener.OrientFront.z = zFront; + device->listener.OrientTop.x = xTop; + device->listener.OrientTop.y = yTop; + device->listener.OrientTop.z = zTop; +} + + static void FAudioGMS_INTERNAL_SoundInstance_Destroy(FAudioGMS_SoundInstance *instance) { uint32_t i; diff --git a/src/FAudioGMS.h b/src/FAudioGMS.h index 590afb4..001f0cc 100644 --- a/src/FAudioGMS.h +++ b/src/FAudioGMS.h @@ -78,6 +78,14 @@ extern "C" double xVelocity, double yVelocity, double zVelocity); + FAUDIOGMSAPI void FAudioGMS_SoundInstance_Set3DOrientation( + double soundInstanceID, + double xFront, + double yFront, + double zFront, + double xTop, + double yTop, + double zTop); FAUDIOGMSAPI void FAudioGMS_SoundInstance_SetTrackPositionInSeconds( double soundInstanceID, double trackPositionInSeconds); @@ -151,6 +159,14 @@ extern "C" double xVelocity, double yVelocity, double zVelocity); + FAUDIOGMSAPI void FAudioGMS_SetListenerOrientation( + double soundInstanceID, + double xFront, + double yFront, + double zFront, + double xTop, + double yTop, + double zTop); FAUDIOGMSAPI void FAudioGMS_PauseAll(); /* useful for mobile platforms, etc */