Bug 216859 - Slightly improve AudioBufferSourceNode resampling
Summary: Slightly improve AudioBufferSourceNode resampling
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 212611
  Show dependency treegraph
 
Reported: 2020-09-22 16:54 PDT by Chris Dumez
Modified: 2020-09-22 18:50 PDT (History)
9 users (show)

See Also:


Attachments
Patch (15.06 KB, patch)
2020-09-22 16:58 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (16.11 KB, patch)
2020-09-22 17:01 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.91 KB, patch)
2020-09-22 17:13 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (16.13 KB, patch)
2020-09-22 17:56 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-09-22 16:54:10 PDT
Slightly improve AudioBufferSourceNode resampling. Use simple linear extrapolation to resample the data when we reach the end of the buffer. Previously, the last sample would just be repeated enough times.
Comment 1 Chris Dumez 2020-09-22 16:58:56 PDT
Created attachment 409423 [details]
Patch
Comment 2 Chris Dumez 2020-09-22 17:01:44 PDT
Created attachment 409424 [details]
Patch
Comment 3 Eric Carlson 2020-09-22 17:03:35 PDT
Comment on attachment 409424 [details]
Patch

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

> Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp:416
> +                float sample;
> +                if (readIndex == readIndex2 && readIndex >= 1) {
> +                    // We're at the end of the buffer, so just linearly extrapolate from the last two samples.
> +                    float sample1 = source[readIndex - 1];
> +                    float sample2 = source[readIndex];
> +                    sample = sample2 + (sample2 - sample1) * interpolationFactor;
> +                } else {
> +                    float sample1 = source[readIndex];
> +                    float sample2 = source[readIndex2];
> +                    sample = sample1 + interpolationFactor * (sample2 - sample1);
> +                }
>  
> -                destination[writeIndex] = narrowPrecisionToFloat(sample);
> +                destination[writeIndex] = sample;

It looks like this is an identical copy of the code above. Can it be moved to a shared function?
Comment 4 Chris Dumez 2020-09-22 17:13:26 PDT
Created attachment 409428 [details]
Patch
Comment 5 Chris Dumez 2020-09-22 17:56:57 PDT
Created attachment 409432 [details]
Patch
Comment 6 EWS 2020-09-22 18:49:36 PDT
Committed r267453: <https://trac.webkit.org/changeset/267453>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 409432 [details].
Comment 7 Radar WebKit Bug Importer 2020-09-22 18:50:21 PDT
<rdar://problem/69406153>