From 685c9554bd2840d5da3d738e3243cc19d2cdac0b Mon Sep 17 00:00:00 2001 From: Hongchan Choi Date: Fri, 5 Apr 2024 12:55:08 -0700 Subject: [PATCH 1/2] adding test for 331682035 --- src/_data/build_info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_data/build_info.json b/src/_data/build_info.json index 7052a0704..1b57a15e2 100644 --- a/src/_data/build_info.json +++ b/src/_data/build_info.json @@ -1 +1 @@ -{"version":"3.1.0","revision":"7201485","lastUpdated":"2023-11-02","copyrightYear":2023} \ No newline at end of file +{"version":"3.1.0","revision":"0643084","lastUpdated":"2024-03-07","copyrightYear":2024} \ No newline at end of file From 333a1ca83b2bc94b3ffc256a1e3bc2f1f7b1b948 Mon Sep 17 00:00:00 2001 From: Hongchan Choi Date: Fri, 5 Apr 2024 12:57:08 -0700 Subject: [PATCH 2/2] initial commit --- src/tests/resampler/app.js | 131 ++++++++++++++++++++++++++++++++++ src/tests/resampler/index.njk | 33 +++++++++ 2 files changed, 164 insertions(+) create mode 100644 src/tests/resampler/app.js create mode 100644 src/tests/resampler/index.njk diff --git a/src/tests/resampler/app.js b/src/tests/resampler/app.js new file mode 100644 index 000000000..eafe9865f --- /dev/null +++ b/src/tests/resampler/app.js @@ -0,0 +1,131 @@ +'use strict'; + +const Test = { + initialized: false +}; + +const logMessage = (message, delayInSecond = 0) => { + console.assert(Test.log); + + setTimeout(() => { + Test.log.textContent += + '[' + performance.now().toFixed(2) + '] ' + message + '\r\n'; + }, delayInSecond * 1000); +}; + +const startAudio = async () => { + console.assert(Test.initialized); + + testBody(); + + Test.startAudioButton.disabled = true; + logMessage('Test started.'); +}; + +const testBody = async () => { + const samplerate = 16000; + const allSempl = 44100; + const tele_checked = { + checked: true, + }; + + + // Creating an audio stream + let audioCtx = new AudioContext({ + latencyHint: 'interactive', + sampleRate: samplerate, + }); + audioCtx.suspend(); + + let myArrayBuffer = audioCtx.createBuffer(1 , allSempl * 3, samplerate); + let nowBuffering = myArrayBuffer.getChannelData(0); + + // Filling nowBuffering in the view using Web Bluetooth: + // nowBuffering[i] = + // Create a playback object + + let source = audioCtx.createBufferSource(); + source.loop = true; + source.buffer = myArrayBuffer; + + // let mediaStreamDestination = null; + // if(tele_checked.checked) { + // mediaStreamDestination = audioCtx.createMediaStreamDestination(); + // } + + // *** INCOMPLETE CODE *** + // let ratio_coeff = base_30/filter_save[0].gain_value; + // for(var i=0; i < filter_save.length; i++) { + // filter[i] = audioCtx.createBiquadFilter(); + // filter[i].type = "highshelf"; + // filter[i].frequency.value = filter_save[i].frequency_value; + // filter[i].gain.value = + // (i==0)?base_30:filter_save[i].gain_value*ratio_coeff; + + // if(i>0) { + // document.getElementById('fr-text-'+i).innerHTML = + // filter_save[i].frequency_value; + // document.getElementById('gain-text-'+i).innerHTML = + // filter_save[i].gain_value; + // } + // } + + let myAnalyser = audioCtx.createAnalyser(); + // myAnalyser.smoothingTimeConstant = smoothingTime; + // myAnalyser.fftSize = fft_Size; + + let gainNode = audioCtx.createGain(); + // gainNode.gain.value = level_num.value/100. * ratio_level; // 0..1 + gainNode.gain.value = 0.25; // 0..1 + + source.connect(gainNode); + + // *** INCOMPLETE CODE *** + // let time_sempl = 0.2; + // Adding a WorkProcessor + // audioCtx.audioWorklet.addModule("worker_processor.js").then(() => { + // worker_processor = new AudioWorkletNode(audioCtx, "worker_processor"); + // worker_processor.port.onmessage = (event) => { + // let worker_data = event.data; + // for(let i = 0; i < worker_data.length; i++) { + // time_sempl = time_sempl + 1./samplerate; + // ys.push({simpl_time:time_sempl, simpl_value:wavevolume - Math.floor(worker_data[i]*wavevolume) }); + // } + // }; + // gainNode.connect(worker_processor); // Data pack for graph and spectrogram + + // *** INCOMPLETE CODE *** + // source.connect(filter[0]); + // for(i=0; i { + Test.log = document.getElementById('log'); + Test.inspector = document.getElementById('inspector'); + Test.startAudioButton = document.getElementById('btn-start-test'); + + Test.startAudioButton.onclick = startAudio; + Test.startAudioButton.disabled = false; + + logMessage('Test initialized. Press "Start Audio" to begin.'); + Test.initialized = true; +}; + +// Entry point +window.addEventListener('load', initializeTest); diff --git a/src/tests/resampler/index.njk b/src/tests/resampler/index.njk new file mode 100644 index 000000000..d8d6e43d3 --- /dev/null +++ b/src/tests/resampler/index.njk @@ -0,0 +1,33 @@ +--- +eleventyNavigation: + key: test-resampler-bug + title: Resampler Verificaiton + parent: tests +to_root_dir: ../../ +--- + +{% extends "../../_includes/base.njk" %} + +{% block content %} + +

{{ eleventyNavigation.title }}

+

Press "Start Audio" button to start the test. Check if you can hear any + audio glitches from your eadbuds or a headset. See + Issue 331682035 for more details. +

+

Refresh the page to run the test again.

+ +
+ + {% include "../../_includes/example-source-code.njk" %} +
+ +
+
+
+
+ + + +{% endblock %}