Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Test Biquad Tail Output</title> | |
| 5 <script src="../resources/js-test.js"></script> | |
| 6 <script src="resources/compatibility.js"></script> | |
| 7 <script src="resources/audio-testing.js"></script> | |
| 8 </head> | |
| 9 | |
| 10 <body> | |
| 11 <script> | |
| 12 description("Test Biquad Tail Output"); | |
| 13 window.jsTestIsAsync = true; | |
| 14 | |
| 15 // A high sample rate shows the issue more clearly. | |
| 16 var sampleRate = 192000; | |
| 17 // Some short duration because we don't need to run the test for very long . | |
| 18 var testDurationSec = 0.5; | |
| 19 var testDurationFrames = testDurationSec * sampleRate; | |
| 20 | |
| 21 // Amplitude experimentally determined to give a biquad output close to 1. (No attempt was | |
| 22 // made to produce exactly 1; it's not needed.) | |
| 23 var sourceAmplitude = 100; | |
| 24 | |
| 25 // The output of the biquad filter should not change by more than this muc h between output | |
| 26 // samples. Threshold was determined experimentally. | |
| 27 var glitchThreshold = 0.0129; | |
| 28 | |
| 29 // Test that a Biquad filter doesn't have it's output terminated because t he input has gone | |
| 30 // away. Generally, when a source node is finished, it disconnects itself from any downstream | |
| 31 // nodes. This is the correct behavior. Nodes that have no inputs (disco nnected) are | |
| 32 // generally assumed to output zeroes. This is also desired behavior. Ho wever, biquad | |
| 33 // filters have memory so they should not suddenly output zeroes when the input is | |
| 34 // disconnected. This test checks to see if the output doesn't suddenly c hange to zero. | |
| 35 function runTest() { | |
| 36 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ; | |
| 37 | |
| 38 // Create an impulse source. | |
| 39 var buffer = context.createBuffer(1, 1, context.sampleRate); | |
| 40 buffer.getChannelData(0)[0] = sourceAmplitude; | |
| 41 var source = context.createBufferSource(); | |
| 42 source.buffer = buffer; | |
| 43 | |
| 44 // Create the biquad filter. It doesn't really matter what kind, so the default filter type | |
| 45 // and parameters is fine. Connect the source to it. | |
| 46 var biquad = context.createBiquadFilter(); | |
| 47 source.connect(biquad); | |
| 48 biquad.connect(context.destination); | |
| 49 | |
| 50 source.start(); | |
| 51 | |
| 52 context.startRendering().then(function(result) { | |
| 53 // There should be no large discontinuities in the output | |
| 54 var success = true; | |
| 55 success = success && Should("Biquad output", result.getChannelData(0)) .notGlitch(glitchThreshold); | |
| 56 if (success) | |
| 57 testPassed("Biquad tail output correctly completed."); | |
| 58 else | |
| 59 testFailed("Biquad tail output not correctly completed."); | |
| 60 }).then(finishJSTest); | |
| 61 } | |
| 62 | |
| 63 runTest(); | |
| 64 successfullyParsed = true; </script> | |
|
hongchan
2015/08/17 20:25:40
Nit: Need a line break before the script tag.
Raymond Toy
2015/08/17 20:44:59
Done.
| |
| 65 </body> | |
| 66 </html> | |
| OLD | NEW |