SetSoundPan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} This function is used to change the pan level of the specified sound element. ==Syntax== <syntaxhighlight lang="lua">bool setSoundPan ( element theSound, fl...")
 
m (It should just bias the pan despite the 3D pan applied.)
 
(6 intermediate revisions by 4 users not shown)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setSoundPan ( element theSound, float pan )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setSoundPan ( element theSound, float pan )</syntaxhighlight>  
 
{{OOP||[[sound]]:setPan|pan|getSoundPan}}
===Required Arguments===  
===Required Arguments===  
*'''theSound:''' The [[sound]] element which volume you want to modify.
*'''theSound:''' The [[sound]] element which pan you want to modify.
*'''pan:''' A [[float|floating]] point number representing the desired pan level. Range is from ''0.0 (left)'' to ''1.0 (right)''
*'''pan:''' A [[float|floating]] point number representing the desired pan level. Range is from ''-1.0 (left)'' to ''1.0 (right)''


===Returns===
===Returns===
Line 19: Line 19:
         local left = playSFX("genrl", 75, 6, true)    -- Play loading theme music
         local left = playSFX("genrl", 75, 6, true)    -- Play loading theme music
         local right = playSFX("genrl", 75, 7, true)
         local right = playSFX("genrl", 75, 7, true)
         setSoundPan(left, 0)                         -- switch the first music to left channel
         setSoundPan(left, -1)                         -- switch the first music to left channel
         setSoundPan(right, 1)                        -- switch the second music to right channel
         setSoundPan(right, 1)                        -- switch the second music to right channel
end
end
Line 29: Line 29:
==See Also==
==See Also==
{{Client_audio_functions}}
{{Client_audio_functions}}
[[hu:setSoundPan]]

Latest revision as of 15:40, 7 September 2018

This function is used to change the pan level of the specified sound element.

Syntax

bool setSoundPan ( element theSound, float pan )

OOP Syntax Help! I don't understand this!

Method: sound:setPan(...)
Variable: .pan
Counterpart: getSoundPan


Required Arguments

  • theSound: The sound element which pan you want to modify.
  • pan: A floating point number representing the desired pan level. Range is from -1.0 (left) to 1.0 (right)

Returns

Returns true if the sound element pan was successfully changed, false otherwise.

Example

Click to collapse [-]
Client
function playMusic ()
        local left = playSFX("genrl", 75, 6, true)    -- Play loading theme music
        local right = playSFX("genrl", 75, 7, true)
        setSoundPan(left, -1)                         -- switch the first music to left channel
        setSoundPan(right, 1)                         -- switch the second music to right channel
end

addCommandHandler("music", playMusic)                 -- add the command handler

See Also