HU/getSoundWaveData

From Multi Theft Auto: Wiki
Revision as of 13:02, 19 July 2018 by Surge (talk | contribs)
Jump to navigation Jump to search

Ez a funkció megkapja a hullámformátum adatait egy hangfolyamhoz, amely a float egyik táblája, ami az aktuális audiokeretet hullámként ábrázolja. Ez lehetővé teszi például a vizualizálást.

Ha az elem egy játékos, akkor ez a funkció a játékos hangját fogja használni

Syntax

table getSoundWaveData ( element sound, int iSamples )

OOP Syntax Help! I don't understand this!

Method: sound:getWaveData(...)


Required Arguments

  • sound: a sound element that is created using playSound or playSound3D. Streams are also supported
  • iSamples: allowed samples are 256, 512, 1024, 2048, 4096, 8192 and 16384.

Returns

Returns a table of iSamples floats representing the current audio frame waveform. Returns false if the sound is not playing yet or hasn't buffered in the case of streams.

Example

Click to collapse [-]
Client
soundHandler = playSound ( "sound.wav" )

function onSoundPlayRender ( )
    if ( soundHandler ) then
        local waveData = getSoundWaveData ( soundHandler, 256 )
	if ( waveData ) then
            for i=0,255 do
                dxDrawRectangle ( i, 128, 1, waveData[i] * 128)
            end
        end
    end
end
addEventHandler ( "onClientRender", getRootElement(), onSoundPlayRender )

Changelog

Version Description
1.3.2 Added player element to use a players voice

See Also