diff --git a/gamemaker/objects/AUDIO/CleanUp_0.gml b/gamemaker/objects/AUDIO/CleanUp_0.gml index d8dbe47..5dfb697 100644 --- a/gamemaker/objects/AUDIO/CleanUp_0.gml +++ b/gamemaker/objects/AUDIO/CleanUp_0.gml @@ -1 +1,17 @@ +/// @description Clean up all resources when the game is about to end. + +/* Destroy sound instances first: */ +// sndInst.Stop(); +// sndInst.Destroy(); +// sndInst = undefined; + +/* Only then destroy static sounds: */ +// snd.Destroy(); +// snd = undefined; + +/* And only then, destroy effect chains */ +effChain.Destroy(); +effChain = undefined; + +/* Finish up the system */ FAudioGMS_Destroy(); diff --git a/gamemaker/objects/AUDIO/Create_0.gml b/gamemaker/objects/AUDIO/Create_0.gml index 9c5ef31..9a7d480 100644 --- a/gamemaker/objects/AUDIO/Create_0.gml +++ b/gamemaker/objects/AUDIO/Create_0.gml @@ -1,6 +1,15 @@ +/// @description Initialize audio. + +/* First initialize the system: */ var spatialDistanceScale = 50; // makes "3D" audio louder -FAudioGMS_Init(spatialDistanceScale, 1 / 60); +var timestep = game_get_speed(gamespeed_microseconds) / 1000000; // default, autodetect from GM timestep. +FAudioGMS_Init(spatialDistanceScale, timestep); /* Init Effects Chains Here */ +effChain = new EffectChain(); +effChain.AddDefaultReverb(); /* Load Audio Assets Here */ +// snd = LoadStaticSound("go-go-go-tigerblood.wav"); +// sndInst = snd.Play(); +// sndInst.SetEffectChain(effChain, 1); // apply default reverb to the instance. diff --git a/gamemaker/objects/AUDIO/Step_2.gml b/gamemaker/objects/AUDIO/Step_2.gml index 69c3986..008a1d2 100644 --- a/gamemaker/objects/AUDIO/Step_2.gml +++ b/gamemaker/objects/AUDIO/Step_2.gml @@ -1 +1,2 @@ -FAudioGMS_Update(); \ No newline at end of file +/// @description MUST be called once per frame! +FAudioGMS_Update(); diff --git a/gamemaker/scripts/FAudioGMS_Scripts/FAudioGMS_Scripts.gml b/gamemaker/scripts/FAudioGMS_Scripts/FAudioGMS_Scripts.gml index df7f48a..a9421dd 100644 --- a/gamemaker/scripts/FAudioGMS_Scripts/FAudioGMS_Scripts.gml +++ b/gamemaker/scripts/FAudioGMS_Scripts/FAudioGMS_Scripts.gml @@ -88,10 +88,10 @@ function StaticSound(_staticSoundID) constructor // The audio is streamed off the disk, so only a small amount of memory is used at a time. // Good for things like music or voiceover playback. // Note that StreamingSounds are SoundInstances. -function LoadStreamingSound(filename) +function LoadStreamingSound(filename, bufferSizeInBytes = 0) { var filePath = GetPathPrepend() + "audio/streaming/" + filename; - soundInstanceID = FAudioGMS_StreamingSound_LoadOGG(filePath); + soundInstanceID = FAudioGMS_StreamingSound_LoadOGG(filePath, bufferSizeInBytes); return new SoundInstance(soundInstanceID); } @@ -128,6 +128,12 @@ function SoundInstance(_soundInstanceID) constructor { FAudioGMS_SoundInstance_Set3DVelocity(soundInstanceID, xVelocity, yVelocity, zVelocity); } + + // Sets the 3-dimensional orientation of the sound. + static Set3DOrientation = function(xFront, yFront, zFront, xTop, yTop, zTop) + { + FAudioGMS_SoundInstance_Set3DOrientation(soundInstanceID, xFront, yFront, zFront, xTop, yTop, zTop); + } // Sets whether the sound instance loops (true) or does not (false). static SetLoop = function(loop) @@ -167,6 +173,12 @@ function SoundInstance(_soundInstanceID) constructor { FAudioGMS_SoundInstance_SetTrackPositionInSeconds(soundInstanceID, seconds); } + + // Queues this sound instance for playing in sync. + static QueueSyncPlay = function() + { + FAudioGMS_SoundInstance_QueueSyncPlay(soundInstanceID); + } // Sets the playback region for the sound instance. static SetPlayRegion = function(loopStartInMilliseconds, loopEndInMilliseconds) @@ -216,7 +228,7 @@ function SoundInstance(_soundInstanceID) constructor static QueueSoundInstance = function(queueSoundInstance) { - FAudioGMS_SoundInstance_QueueSoundInstance(soundInstanceID, queueSoundInstance.soundInstanceID); + FAudioGMS_SoundInstance_QueueSoundInstance(soundInstanceID, queueSoundInstance.soundInstanceID); } // Gets the pitch of the sound. @@ -263,6 +275,12 @@ function SoundInstance(_soundInstanceID) constructor SetVolume(1); } +// Plays the sound instance queue. +function SyncPlay() +{ + FAudioGMS_SoundInstance_SyncPlay(); +} + // Effect chains allow you to modify sound playback using audio effects. // Right now only reverb is implemented, but more effects will probably come later. function EffectChain() constructor @@ -348,6 +366,12 @@ function SetListenerVelocity(xVelocity, yVelocity, zVelocity) FAudioGMS_SetListenerVelocity(xVelocity, yVelocity, zVelocity); } +// Sets the orientation of the listener for 3D audio. +function SetListenerOrientation(xFront, yFront, zFront, xTop, yTop, zTop) +{ + FAudioGMS_SetListenerOrientation(xFront, yFront, zFront, xTop, yTop, zTop); +} + // Stops all audio playback. function StopAllAudio() {