1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webaudio/test/test_pannerNode.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test PannerNode</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 panner = context.createPanner(); 1.32 + 1.33 + source.buffer = buffer; 1.34 + 1.35 + source.connect(panner); 1.36 + panner.connect(destination); 1.37 + 1.38 + // Verify default values 1.39 + is(panner.panningModel, "HRTF", "Correct default value for panning model"); 1.40 + is(panner.distanceModel, "inverse", "Correct default value for distance model"); 1.41 + near(panner.refDistance, 1, "Correct default value for ref distance"); 1.42 + near(panner.maxDistance, 10000, "Correct default value for max distance"); 1.43 + near(panner.rolloffFactor, 1, "Correct default value for rolloff factor"); 1.44 + near(panner.coneInnerAngle, 360, "Correct default value for cone inner angle"); 1.45 + near(panner.coneOuterAngle, 360, "Correct default value for cone outer angle"); 1.46 + near(panner.coneOuterGain, 0, "Correct default value for cone outer gain"); 1.47 + is(panner.channelCount, 2, "panner node has 2 input channels by default"); 1.48 + is(panner.channelCountMode, "clamped-max", "Correct channelCountMode for the panner node"); 1.49 + is(panner.channelInterpretation, "speakers", "Correct channelCountInterpretation for the panner node"); 1.50 + 1.51 + panner.panningModel = panner.EQUALPOWER; 1.52 + is(panner.panningModel, "equalpower", "Correct alternate panningModel enum value"); 1.53 + panner.panningModel = panner.HRTF; 1.54 + is(panner.panningModel, "HRTF", "Correct alternate panningModel enum value"); 1.55 + panner.distanceModel = panner.LINEAR_DISTANCE; 1.56 + is(panner.distanceModel, "linear", "Correct alternate distanceModel enum value"); 1.57 + panner.distanceModel = panner.INVERSE_DISTANCE; 1.58 + is(panner.distanceModel, "inverse", "Correct alternate distanceModel enum value"); 1.59 + panner.distanceModel = panner.EXPONENTIAL_DISTANCE; 1.60 + is(panner.distanceModel, "exponential", "Correct alternate distanceModel enum value"); 1.61 + 1.62 + panner.setPosition(1, 1, 1); 1.63 + panner.setOrientation(1, 1, 1); 1.64 + panner.setVelocity(1, 1, 1); 1.65 + 1.66 + source.start(0); 1.67 + SimpleTest.executeSoon(function() { 1.68 + source.stop(0); 1.69 + source.disconnect(); 1.70 + panner.disconnect(); 1.71 + 1.72 + SimpleTest.finish(); 1.73 + }); 1.74 +}); 1.75 + 1.76 +</script> 1.77 +</pre> 1.78 +</body> 1.79 +</html>