| <!DOCTYPE html> |
| <html> |
| <head> |
| <title> |
| Validate Reduction Value of DynamicsComporessor after Disabling |
| </title> |
| <script src="../../imported/w3c/web-platform-tests/resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../resources/audit-util.js"></script> |
| <script src="../resources/audit.js"></script> |
| </head> |
| <body> |
| <script id="layout-test-code"> |
| let audit = Audit.createTaskRunner(); |
| let context; |
| let buffer; |
| let source; |
| let compressor; |
| |
| // Use a low sample rate to reduce complexity because we need to run for |
| // quite a few seconds to get the reduction to converge. |
| let sampleRate = 8192; |
| let testDurationSamples = 10 * sampleRate; |
| |
| audit.define( |
| { |
| label: 'test', |
| description: |
| 'Validate Reduction Value of DynamicsCompressor after Disabling' |
| }, |
| function(task, should) { |
| // Create the offline context for the test. |
| context = |
| new OfflineAudioContext(1, testDurationSamples, sampleRate); |
| |
| // Create the constant sample buffer of 0.5 sec. |
| buffer = createConstantBuffer(context, testDurationSamples / 2, 1); |
| |
| // Create compressor and use default parameters for the compression. |
| compressor = context.createDynamicsCompressor(); |
| |
| // Create the source and connect it to the destination |
| source = context.createBufferSource(); |
| source.buffer = buffer; |
| source.connect(compressor); |
| compressor.connect(context.destination); |
| source.start(0.0); |
| |
| // Render it! |
| context.startRendering().then(() => { |
| // Check that the reduction value sufficiently close to 0. |
| // Error threshold experimentally determined. |
| let errorThreshold = 4.8223e-2; |
| should( |
| Math.abs(compressor.reduction), |
| 'Math.abs(compressor.reduction) (' |
| + Math.abs(compressor.reduction) + ')') |
| .beLessThanOrEqualTo(errorThreshold); |
| task.done(); |
| }); |
| }); |
| |
| audit.run(); |
| </script> |
| </body> |
| </html> |