AR/getSoundFFTData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
 
(15 intermediate revisions by 2 users not shown)
Line 2: Line 2:
{{Client function}}
{{Client function}}
{{New feature/item|3.0130|1.3.0|4125|
{{New feature/item|3.0130|1.3.0|4125|
This function gets the fast fourier transform data for an audio stream which is a table of floats representing the current audio frame.
تحصل هذه الوظيفة على بيانات تحويل فورييه السريع لدفق صوتي وهو عبارة عن جدول عوامات يمثل الإطار الصوتي الحالي.
This allows things like visualisations.
هذا يسمح بأشياء مثل التصورات.


a fast fourier transform generates a table of all the frequencies of the current audio frame which starts at the bass end of the spectrum to mids to highs in that order
 
يولد تحويل فورييه السريع جدولًا لجميع ترددات الإطار الصوتي الحالي الذي يبدأ عند نهاية باس الطيف إلى متوسط إلى ارتفاعات في هذا الترتيب
}}
}}


Should you have any problems there is an example resource located on the resource svn here:
إذا واجهتك أي مشاكل ، فهناك مثال لمورد موجود على svn للمورد هنا:
[https://code.google.com/p/mtasa-resources/source/browse/#svn%2Ftrunk%2F%5Bgameplay%5D%2FVisualiser Visualiser]
[https://code.google.com/p/mtasa-resources/source/browse/#svn%2Ftrunk%2F%5Bgameplay%5D%2FVisualiser Visualiser]


just type "startmusic mystreamurl" in your console and it will play on the cinema billboard near A51
فقط اكتب "startmusic mystreamurl" في وحدة التحكم الخاصة بك وسيتم تشغيله على لوحة السينما بالقرب من A51
{{New_feature|3.0139|1.3.2|
{{New_feature|3.0139|1.3.2|
If the element is a player, this function will use the players voice.
إذا كان العنصر لاعبًا ، فستستخدم هذه الوظيفة صوت اللاعبين.
}}
}}
==Syntax==  
==تركيب الوظيفة==  
<syntaxhighlight lang="lua">table getSoundFFTData ( element sound, int iSamples [, int iBands = 0 ] )</syntaxhighlight>  
<syntaxhighlight lang="lua">table getSoundFFTData ( element sound, int iSamples [, int iBands = 0 ] )</syntaxhighlight>  


===Required Arguments===  
===الفراغات المطلوبة===  
*'''sound:'''عنصر الصوت يتم انشاؤه باستخدام [[playSound]] او [[playSound3D]].
*'''الصوت:'''عنصر الصوت يتم انشاؤه باستخدام [[playSound]] او [[playSound3D]].
*'''iSamples:''' العينات المسموح بها هي 128 و 256 و 512 و 1024 و 2048 و 4096 و 8192 و 16384
*'''عينات:''' العينات المسموح بها هي 128 و 256 و 512 و 1024 و 2048 و 4096 و 8192 و 16384


===Optional Arguments===
===الفراغات الاختيارية===
*'''iBands:''' Post processing option allows you to split the samples into the desired amount of bands or bars so if you only need 5 bars this saves a lot of cpu power compared to trying to do it in Lua
*'''مجموعات:''' يسمح لك خيار ما بعد المعالجة بتقسيم العينات إلى العدد المطلوب من الأشرطة أو الأشرطة ، لذلك إذا كنت تحتاج إلى 5 أشرطة فقط ، فهذا يوفر الكثير من طاقة المعالج مقارنة بمحاولة القيام بذلك في Lua


===Returns===
===المعطيات===
Returns a table of floats representing the current audio frame.
* جدول للعينات التي تمثل الاطار الصوتي
Returns false if the sound is not playing yet or hasn't buffered in the
* اذا لم تنجح تعطي false
case of streams.


==Example==  
==مثال==  
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("playsound",
soundHandler = playSound ( "sound.wav" )
function ()  
 
     local sound  = playSound("wasted.mp3")
function onSoundPlayRender ( )
    local data = getSoundWaveData(sound, 512) -- returns table
     if ( soundHandler ) then
    for i, v in pairs(data) do
        local soundFFT = getSoundFFTData ( soundHandler, 2048, 256 )
         outputChatBox(v) -- outputs the float representing the current audio frame
if ( soundFFT ) then
            for i = 0, 255 do -- تبدأ البيانات من الفهرس 0
                dxDrawRectangle ( i, 0, 1, math.sqrt ( soundFFT[i] ) * 256 )
            end
         end
     end
     end
end
end
)
addEventHandler ( "onClientRender", getRootElement(), onSoundPlayRender )
 
</syntaxhighlight>
</syntaxhighlight>
</section>


==Changelog==
==التغير==
{{ChangelogHeader}}
{{AR/ChangelogHeader}}
{{ChangelogItem|1.3.2|Added player element to use a players voice}}
{{ChangelogItem|1.3.2|اضافة عنصر الاعب لاستخدام صوت الاعب}}


==أنظر أيضاً==
==أنظر أيضاً==
{{AR/Audio_functions}}
{{AR/Audio_functions}}
[[HU:getSoundFFTData]]
[[ES:getSoundFFTData]]
[[en:getSoundFFTData]]
[[PT-BR:getSoundFFTData]]

Latest revision as of 19:14, 15 August 2021

تحصل هذه الوظيفة على بيانات تحويل فورييه السريع لدفق صوتي وهو عبارة عن جدول عوامات يمثل الإطار الصوتي الحالي. هذا يسمح بأشياء مثل التصورات.


يولد تحويل فورييه السريع جدولًا لجميع ترددات الإطار الصوتي الحالي الذي يبدأ عند نهاية باس الطيف إلى متوسط إلى ارتفاعات في هذا الترتيب

إذا واجهتك أي مشاكل ، فهناك مثال لمورد موجود على svn للمورد هنا: Visualiser

فقط اكتب "startmusic mystreamurl" في وحدة التحكم الخاصة بك وسيتم تشغيله على لوحة السينما بالقرب من A51 إذا كان العنصر لاعبًا ، فستستخدم هذه الوظيفة صوت اللاعبين.

تركيب الوظيفة

table getSoundFFTData ( element sound, int iSamples [, int iBands = 0 ] )

الفراغات المطلوبة

  • الصوت:عنصر الصوت يتم انشاؤه باستخدام playSound او playSound3D.
  • عينات: العينات المسموح بها هي 128 و 256 و 512 و 1024 و 2048 و 4096 و 8192 و 16384

الفراغات الاختيارية

  • مجموعات: يسمح لك خيار ما بعد المعالجة بتقسيم العينات إلى العدد المطلوب من الأشرطة أو الأشرطة ، لذلك إذا كنت تحتاج إلى 5 أشرطة فقط ، فهذا يوفر الكثير من طاقة المعالج مقارنة بمحاولة القيام بذلك في Lua

المعطيات

  • جدول للعينات التي تمثل الاطار الصوتي
  • اذا لم تنجح تعطي false

مثال

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

function onSoundPlayRender ( )
    if ( soundHandler ) then
        local soundFFT = getSoundFFTData ( soundHandler, 2048, 256 )
	if ( soundFFT ) then
            for i = 0, 255 do -- تبدأ البيانات من الفهرس 0
                dxDrawRectangle ( i, 0, 1, math.sqrt ( soundFFT[i] ) * 256 )
            end
        end
    end
end
addEventHandler ( "onClientRender", getRootElement(), onSoundPlayRender )

التغير

الاصدار الوصف
1.3.2 اضافة عنصر الاعب لاستخدام صوت الاعب

أنظر أيضاً