forked from crosswalk-project/chromium-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't clip FFT output values to minDecibels.
If the (linear) FFT value is zero, the dB value was set to analyser.minDecibels. The spec doesn't require this and it makes more sense to return the expected -Infinity instead. BUG=588853 TEST=realtimeanalyser-zero.html Review URL: https://codereview.chromium.org/1729783002 Cr-Commit-Position: refs/heads/master@{#378081}
- Loading branch information
rtoy
authored and
Commit bot
committed
Feb 27, 2016
1 parent
455d762
commit ef6f6ae
Showing
4 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
third_party/WebKit/LayoutTests/webaudio/realtimeanalyser-zero-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Test AnalyserNode getFloatFrequencyData With Zero-Valued Input | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS getFloatFrequencyData() with zero-valued input contains only the constant -Infinity. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
63 changes: 63 additions & 0 deletions
63
third_party/WebKit/LayoutTests/webaudio/realtimeanalyser-zero.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="resources/compatibility.js"></script> | ||
<script src="resources/audio-testing.js"></script> | ||
<title>Test getFloatFrequencyData With Zero Inputs</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
description("Test AnalyserNode getFloatFrequencyData With Zero-Valued Input"); | ||
window.jsTestIsAsync = true; | ||
|
||
var sampleRate = 48000; | ||
|
||
// Render enough data to run the test. | ||
var renderFrames = 2*1024; | ||
var renderDuration = renderFrames / sampleRate; | ||
|
||
var audit = Audit.createTaskRunner(); | ||
|
||
|
||
// Test that getFloatFrequencyData returns -Infinity when the input is all-zeroes. | ||
audit.defineTask("zero input", function (done) { | ||
var context = new OfflineAudioContext(1, renderFrames, sampleRate); | ||
|
||
// Constant source of 0's. | ||
var source = context.createBufferSource(); | ||
source.buffer = createConstantBuffer(context, 1, 0); | ||
source.loop = true; | ||
|
||
// Create analyser and use some non-default minDecibels value. | ||
var analyser = context.createAnalyser(); | ||
analyser.minDecibels = -123; | ||
|
||
source.connect(analyser); | ||
analyser.connect(context.destination); | ||
|
||
source.start(); | ||
|
||
// Suspend after some number of frames and grab the float frequency data. | ||
context.suspend(1024 / sampleRate).then(function () { | ||
var f = new Float32Array(analyser.frequencyBinCount); | ||
analyser.getFloatFrequencyData(f); | ||
|
||
Should("getFloatFrequencyData() with zero-valued input", f) | ||
.beConstantValueOf(-Infinity); | ||
}).then(context.resume.bind(context)); | ||
|
||
context.startRendering().then(done); | ||
}); | ||
|
||
audit.defineTask("finish", function (done) { | ||
finishJSTest(); | ||
done(); | ||
}); | ||
|
||
audit.runTasks(); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters