OLD | NEW |
---|---|
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test AudioBufferSourceNode With Looping a Single-Sample Buffer</title > | 4 <title>Validate Reduction Value of DynamicsComporessor after Disabling</titl e> |
5 <script src="resources/compatibility.js"></script> | 5 <script src="resources/compatibility.js"></script> |
6 <script src="resources/audio-testing.js"></script> | 6 <script src="resources/audio-testing.js"></script> |
7 <script src="../resources/js-test.js"></script> | 7 <script src="../resources/js-test.js"></script> |
8 </head> | 8 </head> |
9 | 9 |
10 <body> | 10 <body> |
11 <script> | 11 <script> |
12 description("Test AudioBufferSourceNode With Looping a Single-Sample Buffe r"); | 12 description("Validate Reduction Value of DynamicsComporessor after Disabli ng"); |
13 | 13 |
14 var context; | 14 var context; |
15 var buffer; | |
15 var source; | 16 var source; |
16 var buffer; | 17 var compressor; |
17 var renderedData; | 18 var renderedData; |
18 | 19 |
19 var sampleRate = 44100; | 20 var sampleRate = 44100; |
20 var testDurationSamples = 1000; | 21 var testDurationSamples = 44100; |
21 | 22 |
22 function checkResult (event) { | 23 function checkResult (event) { |
23 var success = true; | |
24 | 24 |
25 renderedData = event.renderedBuffer.getChannelData(0); | 25 renderedData = event.renderedBuffer.getChannelData(0); |
26 // Check that the rendered data is all ones, like the buffer source. | 26 |
27 for (k = 0; k < renderedData.length; ++k) { | 27 // Check that the reduction value is 0.0. |
28 if (renderedData[k] != 1) { | 28 if (compressor.reduction.value !== 0.0) { |
29 success = false; | 29 testFailed("Expected reduction of 0.0, but the value is " + compre ssor.reduction.value); |
30 testFailed("Expected all ones, but sample " + k + " is " + ren deredData[k]); | |
31 break; | |
32 } | |
33 } | 30 } |
34 if (success) | 31 else { |
35 testPassed("All samples equal to 1"); | 32 testPassed("Reduction is 0.0"); |
33 } | |
34 | |
36 finishJSTest(); | 35 finishJSTest(); |
37 } | 36 } |
38 | 37 |
39 function runTest() { | 38 function runTest() { |
40 window.jsTestIsAsync = true; | 39 window.jsTestIsAsync = true; |
41 | 40 |
42 // Create the offline context for the test. | 41 // Create the offline context for the test. |
43 context = new OfflineAudioContext(1, testDurationSamples, sampleRate); | 42 context = new OfflineAudioContext(1, testDurationSamples, sampleRate); |
44 context.oncomplete = checkResult; | 43 context.oncomplete = checkResult; |
45 | 44 |
46 // Create the single sample buffer | 45 // Create the constant sample buffer of 0.5 sec. |
47 buffer = createConstantBuffer(context, 1, 1); | 46 buffer = createConstantBuffer(context, testDurationSamples / 2, 1); |
47 | |
48 // Create comporessor and set parameters accordingly. | |
Raymond Toy
2014/10/21 20:47:57
Nit: Typo: "comporessor"
hongchan
2014/10/21 20:58:53
Acknowledged.
| |
49 compressor = context.createDynamicsCompressor(); | |
50 compressor.threshold.value = -24.0; | |
51 compressor.ratio.value = -8.0; | |
48 | 52 |
49 // Create the source and connect it to the destination | 53 // Create the source and connect it to the destination |
50 source = context.createBufferSource(); | 54 source = context.createBufferSource(); |
51 source.buffer = buffer; | 55 source.buffer = buffer; |
52 source.loop = true; | 56 source.connect(compressor); |
53 source.connect(context.destination); | 57 compressor.connect(context.destination); |
54 source.start(); | 58 source.start(0.0); |
59 source.stop(0.5); | |
Raymond Toy
2014/10/21 20:47:57
Nit: this seems redundant. The source is 0.5 sec l
hongchan
2014/10/21 20:58:53
Acknowledged.
| |
55 | 60 |
56 // Render it! | 61 // Render it! |
57 context.startRendering(); | 62 context.startRendering(); |
58 } | 63 } |
59 | 64 |
60 runTest(); | 65 runTest(); |
61 succesfullyParsed = true; | 66 succesfullyParsed = true; |
62 </script> | 67 </script> |
63 </body> | 68 </body> |
64 </html> | 69 </html> |
OLD | NEW |