From b5c319ef472c24eb384fcfe43b0492184124ff89 Mon Sep 17 00:00:00 2001 From: Toby Jaffey Date: Wed, 4 Dec 2024 10:03:09 +0000 Subject: [PATCH] Add samplerate debug --- src/doom/doom.zig | 2 +- src/wasmpcm.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/doom/doom.zig b/src/doom/doom.zig index ebc7d13..9c36219 100644 --- a/src/doom/doom.zig +++ b/src/doom/doom.zig @@ -20,7 +20,7 @@ var music_right: [RENDER_QUANTUM_FRAMES]f32 = undefined; var mix_left: [RENDER_QUANTUM_FRAMES]f32 = undefined; var mix_right: [RENDER_QUANTUM_FRAMES]f32 = undefined; var music_leftright: [RENDER_QUANTUM_FRAMES * 2]f32 = undefined; -var sampleRate: f32 = 44100; +var sampleRate: f32 = 22050; var synthesizer: Synthesizer = undefined; const WIDTH = 320; diff --git a/src/wasmpcm.js b/src/wasmpcm.js index 3e56919..c8a8be9 100644 --- a/src/wasmpcm.js +++ b/src/wasmpcm.js @@ -91,6 +91,7 @@ export class WasmPcm { static async init(wasmFile, sampleRate) { if (sampleRate) { + console.log("Configuring AudioContext sampleRate = ", sampleRate); audioContext = new AudioContext({sampleRate:sampleRate}); } else { audioContext = new AudioContext(); @@ -113,7 +114,6 @@ export class WasmPcm { }).catch((err) => { console.log(err); }); - await audioContext.audioWorklet.addModule('pcm-processor.js'); @@ -135,6 +135,7 @@ export class WasmPcm { } if (globalInstance.exports.setSampleRate) { + console.log("Setting synth sampleRate = ", audioContext.sampleRate); globalInstance.exports.setSampleRate(audioContext.sampleRate); }