1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webaudio/test/test_dynamicsCompressorNode.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test DynamicsCompressorNode</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.10 +</head> 1.11 +<body> 1.12 +<pre id="test"> 1.13 +<script class="testbody" type="text/javascript"> 1.14 + 1.15 +function near(a, b, msg) { 1.16 + ok(Math.abs(a - b) < 1e-4, msg); 1.17 +} 1.18 + 1.19 +SimpleTest.waitForExplicitFinish(); 1.20 +addLoadEvent(function() { 1.21 + var context = new AudioContext(); 1.22 + var buffer = context.createBuffer(1, 2048, context.sampleRate); 1.23 + for (var i = 0; i < 2048; ++i) { 1.24 + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); 1.25 + } 1.26 + 1.27 + var destination = context.destination; 1.28 + 1.29 + var source = context.createBufferSource(); 1.30 + 1.31 + var compressor = context.createDynamicsCompressor(); 1.32 + 1.33 + source.buffer = buffer; 1.34 + 1.35 + source.connect(compressor); 1.36 + compressor.connect(destination); 1.37 + 1.38 + is(compressor.channelCount, 2, "compressor node has 2 input channels by default"); 1.39 + is(compressor.channelCountMode, "explicit", "Correct channelCountMode for the compressor node"); 1.40 + is(compressor.channelInterpretation, "speakers", "Correct channelCountInterpretation for the compressor node"); 1.41 + 1.42 + // Verify default values 1.43 + with (compressor) { 1.44 + near(threshold.defaultValue, -24, "Correct default value for threshold"); 1.45 + near(knee.defaultValue, 30, "Correct default value for knee"); 1.46 + near(ratio.defaultValue, 12, "Correct default value for ratio"); 1.47 + near(reduction.defaultValue, 0, "Correct default value for reduction"); 1.48 + near(attack.defaultValue, 0.003, "Correct default value for attack"); 1.49 + near(release.defaultValue, 0.25, "Correct default value for release"); 1.50 + } 1.51 + 1.52 + source.start(0); 1.53 + SimpleTest.executeSoon(function() { 1.54 + source.stop(0); 1.55 + source.disconnect(); 1.56 + compressor.disconnect(); 1.57 + 1.58 + SimpleTest.finish(); 1.59 + }); 1.60 +}); 1.61 + 1.62 +</script> 1.63 +</pre> 1.64 +</body> 1.65 +</html>