| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../resources/js-test.js"></script> |
| <script src="resources/audio-testing.js"></script> |
| </head> |
| |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| |
| <script> |
| description("Basic tests for BiquadFilterNode."); |
| |
| var context = 0; |
| |
| function runTest() { |
| context = new webkitAudioContext(); |
| var filter = context.createBiquadFilter(); |
| |
| if (filter.numberOfInputs === 1) |
| testPassed("BiquadFilterNode has one input."); |
| else |
| testFailed("BiquadFilterNode should have one input."); |
| |
| if (filter.numberOfOutputs === 1) |
| testPassed("BiquadFilterNode has one output."); |
| else |
| testFailed("BiquadFilterNode should have one output."); |
| |
| if (filter.type === "lowpass") |
| testPassed("Biquad filter defaults to low-pass filter."); |
| else |
| testFailed("Biquad filter should default to low-pass filter."); |
| |
| if (filter.frequency.value === 350) |
| testPassed("The default value of frequency is 350."); |
| else |
| testFailed("The default value of frequency should be 350."); |
| |
| if (filter.Q.value === 1) |
| testPassed("The default value of Q is 1."); |
| else |
| testFailed("The default value of Q should be 1."); |
| |
| if (filter.gain.value === 0) |
| testPassed("The default value of gain is 0."); |
| else |
| testFailed("The default value of gain should be 0."); |
| |
| // Check that all legal filter types can be set. |
| var filterTypeArray = [{type: "lowpass"}, |
| {type: "highpass"}, |
| {type: "bandpass"}, |
| {type: "lowshelf"}, |
| {type: "highshelf"}, |
| {type: "peaking"}, |
| {type: "notch"}, |
| {type: "allpass"}]; |
| |
| for (var i = 0; i < filterTypeArray.length; ++i) { |
| try { |
| filter.type = filterTypeArray[i].type; |
| if (filter.type === filterTypeArray[i].type) { |
| var message = "Biquad filter type '" + filterTypeArray[i].type + "' is settable."; |
| testPassed(message); |
| } else { |
| var message = "Biquad filter type '" + filterTypeArray[i].type + "' was not correctly set."; |
| testFailed(message); |
| } |
| } catch(e) { |
| var message = "Biquad filter type " + i + " should not throw exception."; |
| testFailed(message); |
| } |
| } |
| |
| // Check that we don't throw an exception for illegal .type values as per WebIDL. |
| shouldNotThrowException(function() { filter.type = "xyz12349jfksd"; }, "Setting .type to illegal string value"); |
| shouldNotThrowException(function() { filter.type = new Float32Array(1); }, "Setting .type to illegal type"); |
| } |
| |
| runTest(); |
| |
| </script> |
| </body> |
| </html> |