Give GML scripts some love.
parent
c37921a181
commit
48a6501f47
|
@ -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();
|
FAudioGMS_Destroy();
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
|
/// @description Initialize audio.
|
||||||
|
|
||||||
|
/* First initialize the system: */
|
||||||
var spatialDistanceScale = 50; // makes "3D" audio louder
|
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 */
|
/* Init Effects Chains Here */
|
||||||
|
effChain = new EffectChain();
|
||||||
|
effChain.AddDefaultReverb();
|
||||||
|
|
||||||
/* Load Audio Assets Here */
|
/* Load Audio Assets Here */
|
||||||
|
// snd = LoadStaticSound("go-go-go-tigerblood.wav");
|
||||||
|
// sndInst = snd.Play();
|
||||||
|
// sndInst.SetEffectChain(effChain, 1); // apply default reverb to the instance.
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
/// @description MUST be called once per frame!
|
||||||
FAudioGMS_Update();
|
FAudioGMS_Update();
|
|
@ -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.
|
// 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.
|
// Good for things like music or voiceover playback.
|
||||||
// Note that StreamingSounds are SoundInstances.
|
// Note that StreamingSounds are SoundInstances.
|
||||||
function LoadStreamingSound(filename)
|
function LoadStreamingSound(filename, bufferSizeInBytes = 0)
|
||||||
{
|
{
|
||||||
var filePath = GetPathPrepend() + "audio/streaming/" + filename;
|
var filePath = GetPathPrepend() + "audio/streaming/" + filename;
|
||||||
soundInstanceID = FAudioGMS_StreamingSound_LoadOGG(filePath);
|
soundInstanceID = FAudioGMS_StreamingSound_LoadOGG(filePath, bufferSizeInBytes);
|
||||||
return new SoundInstance(soundInstanceID);
|
return new SoundInstance(soundInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +129,12 @@ function SoundInstance(_soundInstanceID) constructor
|
||||||
FAudioGMS_SoundInstance_Set3DVelocity(soundInstanceID, xVelocity, yVelocity, zVelocity);
|
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).
|
// Sets whether the sound instance loops (true) or does not (false).
|
||||||
static SetLoop = function(loop)
|
static SetLoop = function(loop)
|
||||||
{
|
{
|
||||||
|
@ -168,6 +174,12 @@ function SoundInstance(_soundInstanceID) constructor
|
||||||
FAudioGMS_SoundInstance_SetTrackPositionInSeconds(soundInstanceID, seconds);
|
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.
|
// Sets the playback region for the sound instance.
|
||||||
static SetPlayRegion = function(loopStartInMilliseconds, loopEndInMilliseconds)
|
static SetPlayRegion = function(loopStartInMilliseconds, loopEndInMilliseconds)
|
||||||
{
|
{
|
||||||
|
@ -216,7 +228,7 @@ function SoundInstance(_soundInstanceID) constructor
|
||||||
|
|
||||||
static QueueSoundInstance = function(queueSoundInstance)
|
static QueueSoundInstance = function(queueSoundInstance)
|
||||||
{
|
{
|
||||||
FAudioGMS_SoundInstance_QueueSoundInstance(soundInstanceID, queueSoundInstance.soundInstanceID);
|
FAudioGMS_SoundInstance_QueueSoundInstance(soundInstanceID, queueSoundInstance.soundInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the pitch of the sound.
|
// Gets the pitch of the sound.
|
||||||
|
@ -263,6 +275,12 @@ function SoundInstance(_soundInstanceID) constructor
|
||||||
SetVolume(1);
|
SetVolume(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plays the sound instance queue.
|
||||||
|
function SyncPlay()
|
||||||
|
{
|
||||||
|
FAudioGMS_SoundInstance_SyncPlay();
|
||||||
|
}
|
||||||
|
|
||||||
// Effect chains allow you to modify sound playback using audio effects.
|
// Effect chains allow you to modify sound playback using audio effects.
|
||||||
// Right now only reverb is implemented, but more effects will probably come later.
|
// Right now only reverb is implemented, but more effects will probably come later.
|
||||||
function EffectChain() constructor
|
function EffectChain() constructor
|
||||||
|
@ -348,6 +366,12 @@ function SetListenerVelocity(xVelocity, yVelocity, zVelocity)
|
||||||
FAudioGMS_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.
|
// Stops all audio playback.
|
||||||
function StopAllAudio()
|
function StopAllAudio()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue