Bug 213393

Summary: Added getFloatTimeDomainData method to AnalyserNode
Product: WebKit Reporter: Clark Wang <clark_wang>
Component: Web AudioAssignee: Clark Wang <clark_wang>
Status: RESOLVED FIXED    
Severity: Minor CC: cdumez, eric.carlson, esprehn+autocc, ews-watchlist, glenn, jer.noble, kondapallykalyan, parametrize, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 212611    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Clark Wang 2020-06-19 11:09:53 PDT
Added getFloatTimeDomainData method to AnalyserNode
Comment 1 Clark Wang 2020-06-19 11:13:18 PDT
Created attachment 402296 [details]
Patch
Comment 2 Chris Dumez 2020-06-19 11:36:50 PDT
Comment on attachment 402296 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402296&action=review

> Source/WebCore/Modules/webaudio/AnalyserNode.idl:45
> +    void getFloatTimeDomainData(Float32Array? array); // FIXME: The parameter should not be nullable.

Since this is new code, why a FIXME comment? Why not make the parameter non-nullable?

Also, everything you add should be behind the Modern Web Audio flag so:
[EnabledBySetting=ModernUnprefixedWebAudio] void getFloatTimeDomainData(Float32Array array);

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:265
> +void RealtimeAnalyser::getFloatTimeDomainData(Float32Array* destinationArray)

If this implementation is based on the Blink one, please state so in the ChangeLog file.

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:273
> +    size_t len = std::min(fftSize, destinationArray->length());

No abbreviations in WebKit: len -> length

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:285
> +        for (unsigned i = 0; i < len; ++i) {

len is a size_t so please use same type for i.

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:287
> +            float value = inputBuffer[(i + writeIndex - fftSize + InputBufferSize) % InputBufferSize];

This local variable is not needed.
Comment 3 Clark Wang 2020-06-19 15:27:04 PDT
Created attachment 402335 [details]
Patch
Comment 4 Chris Dumez 2020-06-19 17:52:19 PDT
Comment on attachment 402335 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402335&action=review

> Source/WebCore/Modules/webaudio/AnalyserNode.h:58
> +    void getFloatTimeDomainData(const RefPtr<JSC::Float32Array>& array) { m_analyser.getFloatTimeDomainData(array.get()); }

const Ref<JSC::Float32Array>&

Same for others.

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:-107
> -        return;    

Please configure your IDE to stop doing these things. We try to avoid unrelated changes in patches as much as possible.

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:-207
> -    if (!destinationArray)

Since destinationArray cannot take null anymore, the parameter should be of type:
Float32Array& destinationArray

This means you'll need to update AnalyzerNode::getFloatFrequencyData() to take in a Ref<> instead of a RefPtr<>.

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:-232
> -    if (!destinationArray)

ditto

> Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:-269
> -    if (!destinationArray)

ditto.
Comment 5 Clark Wang 2020-06-22 08:12:36 PDT
Created attachment 402474 [details]
Patch
Comment 6 EWS 2020-06-22 12:26:49 PDT
Committed r263359: <https://trac.webkit.org/changeset/263359>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402474 [details].
Comment 7 Radar WebKit Bug Importer 2020-06-22 12:27:17 PDT
<rdar://problem/64603798>
Comment 8 Chris Dumez 2021-01-05 08:30:38 PST
*** Bug 220023 has been marked as a duplicate of this bug. ***