function testNode() { var context = new AudioContext(); var buffer = context.createBuffer(1, 2048, context.sampleRate);
for (var i = 0; i < 2048; ++i) {
buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
}
is(analyser.channelCount, 2, "analyser node has 2 input channels by default");
is(analyser.channelCountMode, "max", "Correct channelCountMode for the analyser node");
is(analyser.channelInterpretation, "speakers", "Correct channelCountInterpretation for the analyser node");
function testConstructor() { var context = new AudioContext();
var analyser = new AnalyserNode(context);
is(analyser.channelCount, 2, "analyser node has 2 input channels by default");
is(analyser.channelCountMode, "max", "Correct channelCountMode for the analyser node");
is(analyser.channelInterpretation, "speakers", "Correct channelCountInterpretation for the analyser node");
is(analyser.fftSize, 2048, "Correct default value for fftSize");
is(analyser.frequencyBinCount, 1024, "Correct default value for frequencyBinCount");
is(analyser.minDecibels, -100, "Correct default value for minDecibels");
is(analyser.maxDecibels, -30, "Correct default value for maxDecibels");
ok(Math.abs(analyser.smoothingTimeConstant - 0.8) < 0.001, "Correct default value for smoothingTimeConstant");
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 0 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 1 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 8 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 100 }); // non-power of two
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 2049 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 4097 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 8193 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 16385 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 32769 });
}, DOMException.INDEX_SIZE_ERR);
expectException(function() {
analyser = new AnalyserNode(context, { fftSize: 65536 });
}, DOMException.INDEX_SIZE_ERR);
analyser = new AnalyserNode(context, { fftSize: 1024 });
is(analyser.frequencyBinCount, 512, "Correct new value for frequencyBinCount");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.