Sounds in Lua
Functions for loading sounds
Functions
#1: Sound:LoadSound( sound , flags );
#2: Sound:Load3DSound( sound , arg2 , arg3 , arg4 , arg5 );
#3: Sound:LoadStreamSound( sound , flags );

Arguments
#1: sound - path to sound , flags - some settings for sound (optional)
#2: sound - path to sound , arg2 - some settings for sound (number or flag) , arg3 , arg4 , arg5 - some number
#3: sound - path to sound , flags - some settings for sound (optional)
idl
Functions for playing sounds
Functions
#1: Sound:PlaySound( sound );
#2: Sound:StopSound( sound );

Arguments
#1: sound - loaded sound
#2: sound - loaded sound
idl
Functions for editing sounds
Functions
#01: Sound:SetSoundVolume( sound , volume );
#02: Sound:SetSoundPitching( sound , pitch );
#04: Sound:SetGroupScale( flag1 , flag2 );
#02: Sound:SetMinMaxDistance( sound , min , max );
#05: Sound:SetSoundLoop( sound , loop );
#06: Sound:AddToScaleGroup( sound , flag );
#07: Sound:SetSoundFrequency( sound , frequency );
#08: Sound:SetSoundProperties( sound , properties );
#09: Sound:SetSoundPosition( sound , position );
#10: Sound:SetDirectionalAttenuation( position , angles , fov );
#11: Sound:RemoveFromScaleGroup( sound , flag );

Arguments
#01: sound - loaded sound , volume - some number from 0 to 255
#02: sound - loaded sound , pitch - some number
#04: flag1 - some flag , flag2 - some flag or number
#02: sound - loaded sound , min - minimum radius of sound , max - maximum radius of sound
#05: sound - loaded sound , loop - number
#06: sound - loaded sound , flag - some flag
#07: sound - loaded sound , frequency - some number
#08: sound - loaded sound , properties - some properties (like fade)
#09: sound - loaded sound , position - some position
#10: position - some position , angles - some angles , fov - field of vision.
#11: sound - loaded sound , flag - some flag.
idl
Functions for getting information about sounds
Functions
#1: Sound:IsPlaying( sound );

Arguments
#1: sound - loaded sound
idl
Functions for music system
Functions
#1: Sound:AddMusicMoodEvent( mood , timeout );
#2: Sound:SetDefaultMusicMood( mood );
#4: Sound:SetMusicMood( mood );
#2: Sound:SetMusicTheme( theme );
#5: Sound:ResetMusicThemeOverride( );
#6: Sound:IsInMusicMood( mood );

Arguments
#1: mood - name of mood , timeout - itself timeout (in seconds)
#2: mood - name of mood
#4: mood - name of mood
#2: theme - name of theme
#5: no arguments used for this one
#6: mood - name of mood
idl
Functions for EAX system
Functions
#1: Sound:SetEaxEnvironment( eax , flags );

Arguments
#1: eax - name of EAX effect , flags - some flags
idl
Some flags for sounds
• SOUND_RADIUS
• SOUND_OCCLUSION
• SOUND_UNSCALABLE
• SOUND_RELATIVE
• SOUND_NO_SW_ATTENUATION
• SOUND_MUSIC
• SOUNDSCALE_UNDERWATER
• SOUNDSCALE_MISSIONHINT
• SOUND_VOLUMESCALEMISSIONHINT
• SOUNDSCALE_DEAFNESS
• SOUND_INDOOR
• SOUND_OUTDOOR
• SOUND_LOOP
idl
Some music moods for music system.
• Sneaking
• Combat
• Suspense
• NearSuspense
• Alert
• Victory
• Vehicle
• Observe
idl
Examples
Various examples. Starting with the fourth example, these need the sounds to be loaded

#01: local snd = Sound:LoadSound( "sounds/player/water/swim2.wav" ); - loading sound using path in 2D space (few formats work like "wav", "mp3").
#02: local snd = Sound:Load3DSound( "sounds/player/water/WaterSplash.wav" , SOUND_RADIUS , 160 , 3 , 50 ); - loading sound using path and optional properties in 3D space (few formats work like "wav").
#03: local snd = Sound:LoadStreamSound( "sounds/player/water/swim2.wav" , SOUND_INDOOR ); - loading sound using path in 2D space (many formats work like "ogg", "wav", "mp3").
#04: Sound:PlaySound( self.SwimSound ); - play loaded sound.
#05: Sound:StopSound( self.SwimSound ); - stop playing loaded sound.
#06: Sound:SetSoundVolume( self.SwimSound , 70 ); - set volume from 255 (by default) to 70.
#07: Sound:SetSoundPitching( CurrSound , 100 ); - set pitch to 100.
#08: Sound:SetGroupScale( SOUNDSCALE_DEAFNESS , 1 ); - all sounds other than this will not be heard.
#09: Sound:SetMinMaxDistance( CurSnd , .2 , 200 ); - set minimum radius of sound to 0.2 and set maximum radius of sound to 200 in 3D space.
#10: Sound:SetSoundLoop( self.SwimSound , 1 ); - set loop mode for this sound.
#11: Sound:AddToScaleGroup( self.Sounds[ i ].Sound , SOUNDSCALE_UNDERWATER ); - set for this sound flag SOUNDSCALE_UNDERWATER.
#12: Sound:SetSoundFrequency( self.LastPhysicsSounds.Roll , Volume * 400 + 800 ); - set frequency for this sound.
#13: Sound:SetSoundProperties( self.sound , self.Properties.fFadeValue ); - set fade effect for this sound in 3D space.
#14: Sound:SetSoundPosition( self.sndBreathIn , System:GetViewCameraPos( ) ); - set position for this sound in 3D space (in this case I get the position of player 's camera).
#15: Sound:SetDirectionalAttenuation( _localplayer:GetPos( ), _localplayer:GetAngles( ), Game:GetCameraFov( ) ); - set directional attenuation (this effect used for binocular).
#16: Sound:RemoveFromScaleGroup( self.EarRinging , SOUNDSCALE_DEAFNESS ); - make a default sound.
#17: local getsnd = Sound:IsPlaying( sound ); - check this sound for load.
#18: Sound:AddMusicMoodEvent( "Sneaking" , 1 ); - set time out for mood "Sneaking" to 1.
#19: Sound:SetDefaultMusicMood( "Sneaking" ); - set default music mood to Sneaking.
#20: Sound:SetMusicMood( "Sneaking" ); - change current music mood to Sneaking.
#21: Sound:SetMusicTheme( "Forest" ); - set music theme to "Forest".
#22: Sound:ResetMusicThemeOverride( ); - unused function for vehicles.
#23: local mood = Sound:IsInMusicMood( "Combat" ); - mood "Combat" is playing?
#24: Sound:SetEaxEnvironment( "Cave" , 0 ); - set EAX environment to OFF mode (default).
idl