1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webaudio/test/test_gainNode.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test GainNode</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="text/javascript" src="webaudio.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.11 +</head> 1.12 +<body> 1.13 +<pre id="test"> 1.14 +<script class="testbody" type="text/javascript"> 1.15 + 1.16 +var gTest = { 1.17 + length: 2048, 1.18 + numberOfChannels: 1, 1.19 + createGraph: function(context) { 1.20 + var buffer = context.createBuffer(1, 2048, context.sampleRate); 1.21 + for (var i = 0; i < 2048; ++i) { 1.22 + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); 1.23 + } 1.24 + 1.25 + var source = context.createBufferSource(); 1.26 + 1.27 + var gain = context.createGain(); 1.28 + 1.29 + source.buffer = buffer; 1.30 + 1.31 + source.connect(gain); 1.32 + 1.33 + ok(gain.gain, "The audioparam member must exist"); 1.34 + is(gain.gain.value, 1.0, "Correct initial value"); 1.35 + is(gain.gain.defaultValue, 1.0, "Correct default value"); 1.36 + gain.gain.value = 0.5; 1.37 + is(gain.gain.value, 0.5, "Correct initial value"); 1.38 + is(gain.gain.defaultValue, 1.0, "Correct default value"); 1.39 + is(gain.channelCount, 2, "gain node has 2 input channels by default"); 1.40 + is(gain.channelCountMode, "max", "Correct channelCountMode for the gain node"); 1.41 + is(gain.channelInterpretation, "speakers", "Correct channelCountInterpretation for the gain node"); 1.42 + 1.43 + source.start(0); 1.44 + return gain; 1.45 + }, 1.46 + createExpectedBuffers: function(context) { 1.47 + var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate); 1.48 + for (var i = 0; i < 2048; ++i) { 1.49 + expectedBuffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate) / 2; 1.50 + } 1.51 + return expectedBuffer; 1.52 + }, 1.53 +}; 1.54 + 1.55 +runTest(); 1.56 + 1.57 +</script> 1.58 +</pre> 1.59 +</body> 1.60 +</html>