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 var success = true; |
24 | 25 |
25 renderedData = event.renderedBuffer.getChannelData(0); | 26 renderedData = event.renderedBuffer.getChannelData(0); |
26 // Check that the rendered data is all ones, like the buffer source. | 27 |
27 for (k = 0; k < renderedData.length; ++k) { | 28 // Check that the reduction value is 0.0. |
28 if (renderedData[k] != 1) { | 29 if (compressor.reduction.value !== 0.0) { |
29 success = false; | 30 success = false; |
30 testFailed("Expected all ones, but sample " + k + " is " + ren deredData[k]); | 31 testFailed("Expected reduction of 0.0, but the value is " + compre ssor.reduction.value); |
31 break; | |
32 } | |
33 } | 32 } |
Raymond Toy
2014/10/21 19:28:56
I would simplify this by removing the variable suc
hongchan
2014/10/21 20:20:37
I tried to keep the code untouched as much as poss
| |
34 if (success) | 33 if (success) |
35 testPassed("All samples equal to 1"); | 34 testPassed("Reduction is 0.0"); |
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. |
Raymond Toy
2014/10/21 19:28:56
Correct the comment. It's not 0.5 sec, right?
hongchan
2014/10/21 20:20:37
I have to figure out this problem - because the li
| |
47 buffer = createConstantBuffer(context, 1, 1); | 46 buffer = createConstantBuffer(context, testDurationSamples / 2, 1); |
47 | |
48 // Create comporessor and set parameters accordingly. | |
49 compressor = context.createDynamicsCompressor(); | |
Raymond Toy
2014/10/21 19:28:56
The compressor doesn't seem to have anything conne
hongchan
2014/10/21 20:20:37
The same problem, the changes were not applied to
| |
50 compressor.threshold.value = -24.0; | |
51 compressor.ratio.value = -8.0; | |
Raymond Toy
2014/10/21 19:28:56
Why these values? Does it really matter for the te
hongchan
2014/10/21 20:20:37
This is to make sure that the compression to actua
| |
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; | |
53 source.connect(context.destination); | 56 source.connect(context.destination); |
54 source.start(); | 57 source.start(0.0); |
58 source.stop(0.5); | |
Raymond Toy
2014/10/21 19:28:56
Why 0.5 sec? The value of testDurationSamples is m
hongchan
2014/10/21 20:20:37
The reason behind this is that we play the buffer
| |
55 | 59 |
56 // Render it! | 60 // Render it! |
57 context.startRendering(); | 61 context.startRendering(); |
58 } | 62 } |
59 | 63 |
60 runTest(); | 64 runTest(); |
61 succesfullyParsed = true; | 65 succesfullyParsed = true; |
62 </script> | 66 </script> |
63 </body> | 67 </body> |
64 </html> | 68 </html> |
OLD | NEW |