Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test PannerNode</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <pre id="test"> |
michael@0 | 10 | <script class="testbody" type="text/javascript"> |
michael@0 | 11 | |
michael@0 | 12 | function near(a, b, msg) { |
michael@0 | 13 | ok(Math.abs(a - b) < 1e-4, msg); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | addLoadEvent(function() { |
michael@0 | 18 | var context = new AudioContext(); |
michael@0 | 19 | var buffer = context.createBuffer(1, 2048, context.sampleRate); |
michael@0 | 20 | for (var i = 0; i < 2048; ++i) { |
michael@0 | 21 | buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | var destination = context.destination; |
michael@0 | 25 | |
michael@0 | 26 | var source = context.createBufferSource(); |
michael@0 | 27 | |
michael@0 | 28 | var panner = context.createPanner(); |
michael@0 | 29 | |
michael@0 | 30 | source.buffer = buffer; |
michael@0 | 31 | |
michael@0 | 32 | source.connect(panner); |
michael@0 | 33 | panner.connect(destination); |
michael@0 | 34 | |
michael@0 | 35 | // Verify default values |
michael@0 | 36 | is(panner.panningModel, "HRTF", "Correct default value for panning model"); |
michael@0 | 37 | is(panner.distanceModel, "inverse", "Correct default value for distance model"); |
michael@0 | 38 | near(panner.refDistance, 1, "Correct default value for ref distance"); |
michael@0 | 39 | near(panner.maxDistance, 10000, "Correct default value for max distance"); |
michael@0 | 40 | near(panner.rolloffFactor, 1, "Correct default value for rolloff factor"); |
michael@0 | 41 | near(panner.coneInnerAngle, 360, "Correct default value for cone inner angle"); |
michael@0 | 42 | near(panner.coneOuterAngle, 360, "Correct default value for cone outer angle"); |
michael@0 | 43 | near(panner.coneOuterGain, 0, "Correct default value for cone outer gain"); |
michael@0 | 44 | is(panner.channelCount, 2, "panner node has 2 input channels by default"); |
michael@0 | 45 | is(panner.channelCountMode, "clamped-max", "Correct channelCountMode for the panner node"); |
michael@0 | 46 | is(panner.channelInterpretation, "speakers", "Correct channelCountInterpretation for the panner node"); |
michael@0 | 47 | |
michael@0 | 48 | panner.panningModel = panner.EQUALPOWER; |
michael@0 | 49 | is(panner.panningModel, "equalpower", "Correct alternate panningModel enum value"); |
michael@0 | 50 | panner.panningModel = panner.HRTF; |
michael@0 | 51 | is(panner.panningModel, "HRTF", "Correct alternate panningModel enum value"); |
michael@0 | 52 | panner.distanceModel = panner.LINEAR_DISTANCE; |
michael@0 | 53 | is(panner.distanceModel, "linear", "Correct alternate distanceModel enum value"); |
michael@0 | 54 | panner.distanceModel = panner.INVERSE_DISTANCE; |
michael@0 | 55 | is(panner.distanceModel, "inverse", "Correct alternate distanceModel enum value"); |
michael@0 | 56 | panner.distanceModel = panner.EXPONENTIAL_DISTANCE; |
michael@0 | 57 | is(panner.distanceModel, "exponential", "Correct alternate distanceModel enum value"); |
michael@0 | 58 | |
michael@0 | 59 | panner.setPosition(1, 1, 1); |
michael@0 | 60 | panner.setOrientation(1, 1, 1); |
michael@0 | 61 | panner.setVelocity(1, 1, 1); |
michael@0 | 62 | |
michael@0 | 63 | source.start(0); |
michael@0 | 64 | SimpleTest.executeSoon(function() { |
michael@0 | 65 | source.stop(0); |
michael@0 | 66 | source.disconnect(); |
michael@0 | 67 | panner.disconnect(); |
michael@0 | 68 | |
michael@0 | 69 | SimpleTest.finish(); |
michael@0 | 70 | }); |
michael@0 | 71 | }); |
michael@0 | 72 | |
michael@0 | 73 | </script> |
michael@0 | 74 | </pre> |
michael@0 | 75 | </body> |
michael@0 | 76 | </html> |