Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test ConvolverNode channel count</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 src="webaudio.js" type="text/javascript"></script> |
michael@0 | 11 | <script class="testbody" type="text/javascript"> |
michael@0 | 12 | |
michael@0 | 13 | const signalLength = 2048; |
michael@0 | 14 | const responseLength = 1000; |
michael@0 | 15 | const outputLength = 2048; // < signalLength + responseLength to test bug 910171 |
michael@0 | 16 | |
michael@0 | 17 | var gTest = { |
michael@0 | 18 | length: outputLength, |
michael@0 | 19 | numberOfChannels: 2, |
michael@0 | 20 | createGraph: function(context) { |
michael@0 | 21 | var buffer = context.createBuffer(2, signalLength, context.sampleRate); |
michael@0 | 22 | for (var i = 0; i < signalLength; ++i) { |
michael@0 | 23 | var sample = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); |
michael@0 | 24 | // When mixed into a single channel, this produces silence |
michael@0 | 25 | buffer.getChannelData(0)[i] = sample; |
michael@0 | 26 | buffer.getChannelData(1)[i] = -sample; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | var response = context.createBuffer(2, responseLength, context.sampleRate); |
michael@0 | 30 | for (var i = 0; i < responseLength; ++i) { |
michael@0 | 31 | response.getChannelData(0)[i] = i / responseLength; |
michael@0 | 32 | response.getChannelData(1)[i] = 1 - (i / responseLength); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | var convolver = context.createConvolver(); |
michael@0 | 36 | convolver.buffer = response; |
michael@0 | 37 | convolver.channelCount = 1; |
michael@0 | 38 | |
michael@0 | 39 | expectException(function() { convolver.channelCount = 3; }, |
michael@0 | 40 | DOMException.NOT_SUPPORTED_ERR); |
michael@0 | 41 | convolver.channelCountMode = "explicit"; |
michael@0 | 42 | expectException(function() { convolver.channelCountMode = "max"; }, |
michael@0 | 43 | DOMException.NOT_SUPPORTED_ERR); |
michael@0 | 44 | convolver.channelInterpretation = "discrete"; |
michael@0 | 45 | convolver.channelInterpretation = "speakers"; |
michael@0 | 46 | |
michael@0 | 47 | var source = context.createBufferSource(); |
michael@0 | 48 | source.buffer = buffer; |
michael@0 | 49 | source.connect(convolver); |
michael@0 | 50 | source.start(0); |
michael@0 | 51 | |
michael@0 | 52 | return convolver; |
michael@0 | 53 | }, |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | runTest(); |
michael@0 | 57 | |
michael@0 | 58 | </script> |
michael@0 | 59 | </pre> |
michael@0 | 60 | </body> |
michael@0 | 61 | </html> |