|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test DynamicsCompressorNode</title> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
7 </head> |
|
8 <body> |
|
9 <pre id="test"> |
|
10 <script class="testbody" type="text/javascript"> |
|
11 |
|
12 function near(a, b, msg) { |
|
13 ok(Math.abs(a - b) < 1e-4, msg); |
|
14 } |
|
15 |
|
16 SimpleTest.waitForExplicitFinish(); |
|
17 addLoadEvent(function() { |
|
18 var context = new AudioContext(); |
|
19 var buffer = context.createBuffer(1, 2048, context.sampleRate); |
|
20 for (var i = 0; i < 2048; ++i) { |
|
21 buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); |
|
22 } |
|
23 |
|
24 var destination = context.destination; |
|
25 |
|
26 var source = context.createBufferSource(); |
|
27 |
|
28 var compressor = context.createDynamicsCompressor(); |
|
29 |
|
30 source.buffer = buffer; |
|
31 |
|
32 source.connect(compressor); |
|
33 compressor.connect(destination); |
|
34 |
|
35 is(compressor.channelCount, 2, "compressor node has 2 input channels by default"); |
|
36 is(compressor.channelCountMode, "explicit", "Correct channelCountMode for the compressor node"); |
|
37 is(compressor.channelInterpretation, "speakers", "Correct channelCountInterpretation for the compressor node"); |
|
38 |
|
39 // Verify default values |
|
40 with (compressor) { |
|
41 near(threshold.defaultValue, -24, "Correct default value for threshold"); |
|
42 near(knee.defaultValue, 30, "Correct default value for knee"); |
|
43 near(ratio.defaultValue, 12, "Correct default value for ratio"); |
|
44 near(reduction.defaultValue, 0, "Correct default value for reduction"); |
|
45 near(attack.defaultValue, 0.003, "Correct default value for attack"); |
|
46 near(release.defaultValue, 0.25, "Correct default value for release"); |
|
47 } |
|
48 |
|
49 source.start(0); |
|
50 SimpleTest.executeSoon(function() { |
|
51 source.stop(0); |
|
52 source.disconnect(); |
|
53 compressor.disconnect(); |
|
54 |
|
55 SimpleTest.finish(); |
|
56 }); |
|
57 }); |
|
58 |
|
59 </script> |
|
60 </pre> |
|
61 </body> |
|
62 </html> |