Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: LayoutTests/webaudio/dynamicscompressor-simple.html

Issue 152333003: Remove emphasis/de-emphasis filters from DynamicsCompressor. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add expected result. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/webaudio/dynamicscompressor-simple-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/webaudio/dynamicscompressor-simple.html
diff --git a/LayoutTests/webaudio/dynamicscompressor-simple.html b/LayoutTests/webaudio/dynamicscompressor-simple.html
new file mode 100644
index 0000000000000000000000000000000000000000..b4000d21e8b656ee9a898138347f1a3c2abf05f8
--- /dev/null
+++ b/LayoutTests/webaudio/dynamicscompressor-simple.html
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <script src="../resources/js-test.js"></script>
+ <script type="text/javascript" src="resources/audio-testing.js"></script>
+ </head>
+
+ <body>
+ <div id="description"></div>
+ <div id="console"></div>
+
+ <script>
+ description("Test pre-emphasis in DynamicsCompressor is removed");
+ var context;
+ var sampleRate = 44100;
+ var lengthInSeconds = 1;
+ var renderedData;
+ // This threshold experimentally determined. It depends on the the gain value of the gain node
+ // below and the dynamics compressor. When the DynamicsCompressor had the pre-emphasis
+ // filters, the peak value is about 0.21. Without it, the peak is 0.85.
+ var peakThreshold = 0.85;
+
+ function checkResult(event) {
+ var renderedBuffer = event.renderedBuffer;
+ renderedData = renderedBuffer.getChannelData(0);
+ // Search for a peak in the last part of the data.
+ var startSample = sampleRate * (lengthInSeconds - .1);
+ var endSample = renderedData.length;
+ var k;
+ var peak = -1;
+
+ for (k = startSample; k < endSample; ++k) {
+ var sample = Math.abs(renderedData[k]);
+ if (peak < sample)
+ peak = sample;
+ }
+
+ if (peak >= peakThreshold) {
+ testPassed("Pre-emphasis effect not applied as expected..");
+ } else {
+ testFailed("Pre-emphasis caused output to be decreased to " + peak
+ + " (expected >= " + peakThreshold + ")");
+ }
+
+ finishJSTest();
+ }
+
+ function runTest() {
+ if (!window.testRunner) {
+ testRunner.dumpAsTest();
+ testRunner.waitUntilDone();
+ }
+
+ window.jsTestIsAsync = true;
+
+ context = new webkitOfflineAudioContext(1, sampleRate * lengthInSeconds, sampleRate);
+ // Connect an oscillator to a gain node to the compressor. The
+ // oscillator frequency is set to a high value for the (original)
+ // emphasis to kick in. The gain is a little extra boost to get the
+ // compressor enabled.
+ //
+ var osc = context.createOscillator();
+ osc.frequency.value = 15000;
+ var gain = context.createGain();
+ gain.gain.value = 1.5;
+ var compressor = context.createDynamicsCompressor();
+ osc.connect(gain);
+ gain.connect(compressor);
+ compressor.connect(context.destination);
+ osc.start();
+ context.oncomplete = checkResult;
+ context.startRendering();
+ }
+
+ runTest();
+ successfullyParsed = true;
+
+ </script>
+
+ </body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/webaudio/dynamicscompressor-simple-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698