SetSoundProperties: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} This function edit's the properties of a specific sound.<br /> <br /> ==Syntax== <syntaxhighlight lang="lua">bool setSoundProperties(element sound, float fS...")
 
mNo edit summary
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
This function edit's the properties of a specific [[sound]].<br />
{{New feature/item|3.0130|1.3.0|4097|
<br />
This function edits the properties of a specific [[sound]].
}}
{{Note|Streams are not supported.}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setSoundProperties(element sound, float fSampleRate, float fTempo, float fPitch, bool bReverse )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setSoundProperties(element sound, float fSampleRate, float fTempo, float fPitch [, bool bReverse = false ] )</syntaxhighlight>  
 
{{OOP||[[sound]]:setProperties||getSoundProperties}}
===Required Arguments===  
===Required Arguments===  
*'''sound:''' A sound element that is created using [[playSound]] or [[playSound3D]]
*'''sound:''' a [[sound]] [[element]] that is created using [[playSound]] or [[playSound3D]]


*'''fSampleRate:''' A float that defines the new sound's [http://en.wikipedia.org/wiki/Sampling_rate sample rate]
*'''fSampleRate:''' a [[float]] that defines the new sound's [http://en.wikipedia.org/wiki/Sampling_rate sample rate]


*'''fTempo:''' A float that defines the new sound [http://en.wikipedia.org/wiki/Tempo tempo]
*'''fTempo:''' a [[float]] that defines the new sound [http://en.wikipedia.org/wiki/Tempo tempo]


*'''fPitch:''' A float that defines the new sound [http://en.wikipedia.org/wiki/Pitch_%28music%29 pitch]
*'''fPitch:''' a [[float]] that defines the new sound [http://en.wikipedia.org/wiki/Pitch_%28music%29 pitch]


*'''bReverse:''' A boolean representing whether the sound will be reversed or not.
===Optional Arguments===
{{OptionalArg}}
*'''bReverse:''' a [[boolean]] representing whether the sound will be reversed or not.


===Returns===
===Returns===
Returns true if the properties sucessfully set, false otherwise.
Returns ''true'' if the properties sucessfully set, ''false'' otherwise.


==Example==  
==Example==  
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- not done yet
function editSongSound()
local sound = playSound("song.wav", false) -- Play the file 'song.wav' and make it play only once
setSoundProperties(sound, 48000.0, 128.00, 440.0, false) -- Set its samplerate to 48,000 Hz, tempo to 128.00, pitch to 440 Hz and not reversed
end
addEventHandler("onClientResourceStart", resourceRoot, editSongSound) -- Execute the function when the resource is started
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
Line 30: Line 38:
==See Also==
==See Also==
{{Client_audio_functions}}
{{Client_audio_functions}}
[[hu:setSoundProperties]]
[[ar:setSoundProperties]]
[[ro:setSoundProperties]]

Latest revision as of 09:42, 3 March 2019

This function edits the properties of a specific sound.

[[{{{image}}}|link=|]] Note: Streams are not supported.

Syntax

bool setSoundProperties(element sound, float fSampleRate, float fTempo, float fPitch [, bool bReverse = false ] )

OOP Syntax Help! I don't understand this!

Method: sound:setProperties(...)
Counterpart: getSoundProperties


Required Arguments

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • bReverse: a boolean representing whether the sound will be reversed or not.

Returns

Returns true if the properties sucessfully set, false otherwise.

Example

Click to collapse [-]
Client
function editSongSound()
	local sound = playSound("song.wav", false) -- Play the file 'song.wav' and make it play only once
	setSoundProperties(sound, 48000.0, 128.00, 440.0, false) -- Set its samplerate to 48,000 Hz, tempo to 128.00, pitch to 440 Hz and not reversed
end
addEventHandler("onClientResourceStart", resourceRoot, editSongSound) -- Execute the function when the resource is started

See Also