Chromium Code Reviews| Index: LayoutTests/webaudio/dynamicscompressor-clear-internal-state.html |
| diff --git a/LayoutTests/webaudio/audiobuffersource-one-sample-loop.html b/LayoutTests/webaudio/dynamicscompressor-clear-internal-state.html |
| similarity index 51% |
| copy from LayoutTests/webaudio/audiobuffersource-one-sample-loop.html |
| copy to LayoutTests/webaudio/dynamicscompressor-clear-internal-state.html |
| index f15d77e0b6a774a962f6858ef3f4cc930e211ae3..e971ef0ae4b81c095fa7aa86fa41734e77193761 100644 |
| --- a/LayoutTests/webaudio/audiobuffersource-one-sample-loop.html |
| +++ b/LayoutTests/webaudio/dynamicscompressor-clear-internal-state.html |
| @@ -1,7 +1,7 @@ |
| <!doctype html> |
| <html> |
| <head> |
| - <title>Test AudioBufferSourceNode With Looping a Single-Sample Buffer</title> |
| + <title>Validate Reduction Value of DynamicsComporessor after Disabling</title> |
| <script src="resources/compatibility.js"></script> |
| <script src="resources/audio-testing.js"></script> |
| <script src="../resources/js-test.js"></script> |
| @@ -9,30 +9,29 @@ |
| <body> |
| <script> |
| - description("Test AudioBufferSourceNode With Looping a Single-Sample Buffer"); |
| + description("Validate Reduction Value of DynamicsComporessor after Disabling"); |
| var context; |
| - var source; |
| var buffer; |
| + var source; |
| + var compressor; |
| var renderedData; |
| var sampleRate = 44100; |
| - var testDurationSamples = 1000; |
| + var testDurationSamples = 44100; |
| function checkResult (event) { |
| - var success = true; |
| renderedData = event.renderedBuffer.getChannelData(0); |
| - // Check that the rendered data is all ones, like the buffer source. |
| - for (k = 0; k < renderedData.length; ++k) { |
| - if (renderedData[k] != 1) { |
| - success = false; |
| - testFailed("Expected all ones, but sample " + k + " is " + renderedData[k]); |
| - break; |
| - } |
| + |
| + // Check that the reduction value is 0.0. |
| + if (compressor.reduction.value !== 0.0) { |
| + testFailed("Expected reduction of 0.0, but the value is " + compressor.reduction.value); |
| } |
| - if (success) |
| - testPassed("All samples equal to 1"); |
| + else { |
| + testPassed("Reduction is 0.0"); |
| + } |
| + |
| finishJSTest(); |
| } |
| @@ -43,15 +42,20 @@ |
| context = new OfflineAudioContext(1, testDurationSamples, sampleRate); |
| context.oncomplete = checkResult; |
| - // Create the single sample buffer |
| - buffer = createConstantBuffer(context, 1, 1); |
| + // Create the constant sample buffer of 0.5 sec. |
| + buffer = createConstantBuffer(context, testDurationSamples / 2, 1); |
| + |
| + // Create compressor and set parameters accordingly. |
| + compressor = context.createDynamicsCompressor(); |
| + compressor.threshold.value = -24.0; |
| + compressor.ratio.value = -8.0; |
|
Raymond Toy
2014/10/21 23:25:51
Nit: Add comment that the threshold and ratio valu
hongchan
2014/10/21 23:43:20
Actually the default parameter values for threshol
|
| // Create the source and connect it to the destination |
| source = context.createBufferSource(); |
| source.buffer = buffer; |
| - source.loop = true; |
| - source.connect(context.destination); |
| - source.start(); |
| + source.connect(compressor); |
| + compressor.connect(context.destination); |
| + source.start(0.0); |
| // Render it! |
| context.startRendering(); |