diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/media/webaudio/test/test_convolverNodeFiniteInfluence.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webaudio/test/test_convolverNodeFiniteInfluence.html')
-rw-r--r-- | dom/media/webaudio/test/test_convolverNodeFiniteInfluence.html | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_convolverNodeFiniteInfluence.html b/dom/media/webaudio/test/test_convolverNodeFiniteInfluence.html new file mode 100644 index 0000000000..1cfb51ce8a --- /dev/null +++ b/dom/media/webaudio/test/test_convolverNodeFiniteInfluence.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<title>Test convolution effect has finite duration</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +promise_test(function() { + + const responseLength = 256; + // Accept an influence period of twice the responseLength to accept FFT + // implementations. + const tolerancePeriod = 2 * responseLength; + const totalSize = tolerancePeriod + responseLength; + + var context = new OfflineAudioContext(1, totalSize, 48000); + + var responseBuffer = + context.createBuffer(1, responseLength, context.sampleRate); + var responseChannelData = responseBuffer.getChannelData(0); + responseChannelData[0] = 1; + responseChannelData[responseLength - 1] = 1; + var convolver = context.createConvolver(); + convolver.buffer = responseBuffer; + convolver.connect(context.destination); + + var sourceBuffer = context.createBuffer(1, totalSize, context.sampleRate); + sourceBuffer.getChannelData(0)[0] = NaN; + var source = context.createBufferSource(); + source.buffer = sourceBuffer; + source.connect(convolver); + source.start(); + + return context.startRendering(). + then((buffer) => { + var convolverOutput = buffer.getChannelData(0); + // There should be no non-zeros after the tolerance period. + var testIndex = tolerancePeriod; + for (; + testIndex < buffer.length - 1 && convolverOutput[testIndex] == 0; + ++testIndex) { + } + assert_equals(convolverOutput[testIndex], 0, "output at " + testIndex); + }); +}); +</script> |