SlashCo.AudioSystem
AudioSystem
This library mainly contains functions related to the audiosystem.
Methods
number SlashCo.AudioSystem.CalculateTime( IGModAudioChannel channel, number tickCount, boolean looping )
Returns the calculated time a channel is supposed to be at, it accounts for looping sounds
This function is frequently used to synchronize channels, especially for the background channel.
SlashCo.AudioSystem.CheckChannels()
Checks all existing channels and removes any from the internal table if they are invalid.
This function is simply a cleanup function to get rid of destroyed channels.
This function is simply a cleanup function to get rid of destroyed channels.
This is used internally - although you're able to use it you probably shouldn't.
SlashCo.AudioSystem.CreateChannel( string soundFile, string mode, function callback, function errorCallback = nil )
Creates a new IGModAudioChannel using the given inputs
This function accounts for and fixes the rare case that GMod's BASS fails to play a sound and errors with BASS_ERROR_FILEFORM
In this case it will write out the sound onto disk and play the disk file, as this issue is related to BASS somehow failing to load sounds from mounted content.
This is used internally - although you're able to use it you probably shouldn't.
In this case it will write out the sound onto disk and play the disk file, as this issue is related to BASS somehow failing to load sounds from mounted content.
SlashCo.AudioSystem.DestroyChannel( IGModAudioChannel channel, number fadeOutTime = nil, function callback = nil )
Destroys the given channel.
SlashCo.AudioSystem.DisableBackgroundMusic( boolean forced = false )
Disables the background music until it's enabled again by calling SlashCo.AudioSystem.EnableBackgroundMusic
SlashCo.AudioSystem.EffectThink()
Renders the AudioSystem effects.
Currently this function is not called normally as it has not yet been finished.
Currently this function is not called normally as it has not yet been finished.
This is used internally - although you're able to use it you probably shouldn't.
SlashCo.AudioSystem.EnableBackgroundMusic( boolean forced = false )
Enables the background music again after it was disabled using SlashCo.AudioSystem.DisableBackgroundMusic
Checks if the input value is a NaN value and if so it will return 0
This is used internally - although you're able to use it you probably shouldn't.
This function acts more as an internal safeguard in case our math somehow explodes.
This function acts more as an internal safeguard in case our math somehow explodes.
Fades the given sound to the given volume over the specified time
SlashCo.AudioSystem.FadeToPlaybackRate( IGModAudioChannel channel, number fadeTime = 3, number targetPlaybackRate = 1, function callback = nil )
Fades the given channel to the given target playbackRate over time
It sounds shit if you keep the channel synced like how the background channel does which is why SlashCo.AudioSystem.SetBackgroundMusicPlaybackRate sets the playbackRate instantly.
It sounds shit if you keep the channel synced like how the background channel does which is why SlashCo.AudioSystem.SetBackgroundMusicPlaybackRate sets the playbackRate instantly.
SlashCo.AudioSystem.FadeToVolume( IGModAudioChannel channel, number fadeTime = 1, number targetVol = 1, function callback = nil )
Fades the given channel to the given target volume over time
Returns the current soundFile of the background music.
Returns the current PlaybackRate of the background music.
number SlashCo.AudioSystem.GetBackgroundMusicTime( )
Returns the current background music time syncronized with all players.
Returns the current volume of the background music.
Returns the current volume of the background music but unlike SlashCo.AudioSystem.GetBackgroundMusicVolume this function will respect the ConVar value of snd_musicvolume (The GMod Settings Music volume slider) while being in the Lobby.
In a round it will return the same volume as SlashCo.AudioSystem.GetBackgroundMusicVolume
In a round it will return the same volume as SlashCo.AudioSystem.GetBackgroundMusicVolume
Finds the channel matching the given identifier and entity index.
This will skip channels that have not yet been created or have been marked for destruction.
This will skip channels that have not yet been created or have been marked for destruction.
This is used internally - although you're able to use it you probably shouldn't.
Returns the unique ChannelID for the given channel.
This will only work on channels created by SlashCo.AudioSystem.CreateChannel
This will only work on channels created by SlashCo.AudioSystem.CreateChannel
This is used internally - although you're able to use it you probably shouldn't.
Returns all channels that were parented to the given entity.
IGModAudioChannel SlashCo.AudioSystem.GetPrecachedChannel( string identifier, function callback, SoundData precacheData )
Returns the given precached channel using the identifier, returns nil on failure. If given a callback, it will use that function which will be more reliable.
Returns a copy of the given registered soundData
Returns the soundFile of a registered sound script or if it has multiple one of them randomly.
This function is specifically meant to be used for sounds registered using sound.Add
This function is specifically meant to be used for sounds registered using sound.Add
SlashCo.AudioSystem.Init()
Initializes the AudioSystem clientside
This is used internally - although you're able to use it you probably shouldn't.
Do not call this yourself! This function is called by the gamemode!
Do not call this yourself! This function is called by the gamemode!
SlashCo.AudioSystem.NukeChannels()
Destroys all channels that exist.
This is used internally - although you're able to use it you probably shouldn't.
This function is mainly used while developing the audiosystem for testing
This function is mainly used while developing the audiosystem for testing
Parents the channel onto the Entity causing it to follow it's movement.
SlashCo.AudioSystem.PlayBackgroundMusic( string soundFile )
Creates and sets the background music channel to the given soundFile
This is used internally - although you're able to use it you probably shouldn't.
SlashCo.AudioSystem.PlayPrecachedChannel( string identifier )
Plays the precached sound if it exists.
SlashCo.AudioSystem.PrecacheSound( string soundFile, string mode, string identifier, function callback )
Precaches a sound that can then be played using the given identifier
This function currently does nothing serverside.
This function may be changed in the future due to the following ToDo:
ToDo: Switch this function over to use PlaySound instead of implementing the logic itself again.
ToDo: Switch this function over to use PlaySound instead of implementing the logic itself again.
Registers the given sound with the given name and data.
This function is currently not used in the game mode, and it's unknown if it works or if it's broken.
Sets the current soundFile and volume of the background music.
The volume will fade over 3 seconds when it's changed- it does not set it instantly.
IMPORTANT You should NOT call this function every tick! If you want to adjust the volume every frame use SlashCo.AudioSystem.SetBackgroundMusicVolume
The volume will fade over 3 seconds when it's changed- it does not set it instantly.
IMPORTANT You should NOT call this function every tick! If you want to adjust the volume every frame use SlashCo.AudioSystem.SetBackgroundMusicVolume
SlashCo.AudioSystem.SetBackgroundMusicPlaybackRate( number playbackRate = 1 )
Sets the current PlaybackRate of the background music.
SlashCo.AudioSystem.SetBackgroundMusicVolume( number volume = 1 )
Sets the current volume of the background music.
The volume will fade over 3 seconds when it's changed- it does not set it instantly.
The volume will fade over 3 seconds when it's changed- it does not set it instantly.
Sets the new identifier for the given channel.
This will only work on channels created by SlashCo.AudioSystem.CreateChannel
This will only work on channels created by SlashCo.AudioSystem.CreateChannel
This is used internally - although you're able to use it you probably shouldn't.
SlashCo.AudioSystem.SetGroupVolume( string groupName, number groupVolume, number lerpTime, table or Entity sendToEntity )
Fades the given group of sounds to the given volume over the specified time
This function is currently not used in the game mode, and it's unknown if it works or if it's broken.
boolean SlashCo.AudioSystem.ShouldPlayBackgroundMusic( )
Returns true if the background music should currently be playing or not.
SlashCo.AudioSystem.StopBackgroundMusic()
Destroys the background music channel.
This is used internally - although you're able to use it you probably shouldn't.
This function is mainly used while developing the audiosystem for testing
This function is mainly used while developing the audiosystem for testing
SlashCo.AudioSystem.StopSound( string identifier, number fadeOut = 0, Entity entity, table or Entity sendToEntity )
Stops the sound matching the given information
Converts the given CurTime to the tick count.