[WebAudio] AudioBufferSourceNodes should accurately play backwards if given a negativ...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Feb 2015 19:45:54 +0000 (19:45 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Feb 2015 19:45:54 +0000 (19:45 +0000)
commitc1f61b2d66fb18c86b4c92e6f9bb891a36d7c1af
tree8856f3383b54d1e617b60862438b668548e9b2bb
parent01a0025ac8a004d3b855651c30faa041d4813a2f
[WebAudio] AudioBufferSourceNodes should accurately play backwards if given a negative playbackRate.
https://bugs.webkit.org/show_bug.cgi?id=140955

Reviewed by Eric Carlson.

Source/WebCore:

Tests: webaudio/audiobuffersource-negative-playbackrate-interpolated.html
       webaudio/audiobuffersource-negative-playbackrate.html

Add support for playing an AudioBufferSourceNode at a negative playbackRate. Change the meaning of
start() to set the initial playback position at the end of the play range if the rate of playback
is negtive.

* Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::AudioBufferSourceNode): Allow the playbackRate AudioParam to range from [-32, 32].
(WebCore::AudioBufferSourceNode::renderFromBuffer): Change variable names from "start" and "end" to "min" and "max"
    for clarity. Add a non-interpolated and interpolated render step for negative playback.
(WebCore::AudioBufferSourceNode::start): Drive-by fix: default value of grainDuration is not 0.02.
(WebCore::AudioBufferSourceNode::startPlaying): Start playing at the end of the buffer for negative playback.
(WebCore::AudioBufferSourceNode::totalPitchRate): Allow the pitch to be negative.

LayoutTests:

* webaudio/audiobuffersource-negative-playbackrate-expected.txt: Added.
* webaudio/audiobuffersource-negative-playbackrate-interpolated-expected.txt: Added.
* webaudio/audiobuffersource-negative-playbackrate-interpolated-loop-expected.txt: Added.
* webaudio/audiobuffersource-negative-playbackrate-interpolated-loop.html: Added.
* webaudio/audiobuffersource-negative-playbackrate-interpolated.html:
* webaudio/audiobuffersource-negative-playbackrate-loop-expected.txt: Added.
* webaudio/audiobuffersource-negative-playbackrate-loop.html: Added.
* webaudio/audiobuffersource-negative-playbackrate.html:
* webaudio/resources/audiobuffersource-testing.js:
(createRamp):

Get rid of extra HRTF padding as it's now unnecessary.

* webaudio/resources/note-grain-on-testing.js:
(createSignalBuffer):
(verifyStartAndEndFrames):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179838 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/webaudio/audiobuffersource-negative-playbackrate-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/audiobuffersource-negative-playbackrate-interpolated-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/audiobuffersource-negative-playbackrate-interpolated-loop-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/audiobuffersource-negative-playbackrate-interpolated-loop.html [new file with mode: 0644]
LayoutTests/webaudio/audiobuffersource-negative-playbackrate-interpolated.html [new file with mode: 0644]
LayoutTests/webaudio/audiobuffersource-negative-playbackrate-loop-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/audiobuffersource-negative-playbackrate-loop.html [new file with mode: 0644]
LayoutTests/webaudio/audiobuffersource-negative-playbackrate.html [new file with mode: 0644]
LayoutTests/webaudio/resources/audiobuffersource-testing.js
LayoutTests/webaudio/resources/note-grain-on-testing.js
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp