From 86d8e3b5c4ade3e1151df932a3d433528d98d335 Mon Sep 17 00:00:00 2001 From: Osei Fortune Date: Thu, 12 Nov 2026 09:17:58 -0400 Subject: [PATCH] test(audio): expect the spec-normalized square level from web-audio-api 1.8.0 web-audio-api 1.8.0 scales the built-in square and sawtooth to the spec's normalized PeriodicWave (1.43 dB quieter), as Chrome does. Cargo.lock is not committed, so CI picked it up and the offline oscillator test, which still expected the old level, failed on Linux and Windows. Require 1.8.0 and expect its level. --- crates/audio-context-napi/Cargo.toml | 2 +- crates/audio-context-napi/__test__/audio.test.mjs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/audio-context-napi/Cargo.toml b/crates/audio-context-napi/Cargo.toml index e9b6f85e..b9adc2d3 100644 --- a/crates/audio-context-napi/Cargo.toml +++ b/crates/audio-context-napi/Cargo.toml @@ -17,7 +17,7 @@ napi7 = ["napi/napi7"] [dependencies] napi = { version = "3.13.0", default-features = false, features = ["dyn-symbols"] } napi-derive = "3.6.9" -web-audio-api = "1.7.0" +web-audio-api = "1.8.0" base64 = "0.22.1" [build-dependencies] diff --git a/crates/audio-context-napi/__test__/audio.test.mjs b/crates/audio-context-napi/__test__/audio.test.mjs index 9e7f4173..0420b62b 100644 --- a/crates/audio-context-napi/__test__/audio.test.mjs +++ b/crates/audio-context-napi/__test__/audio.test.mjs @@ -39,7 +39,9 @@ test('renders an oscillator through a gain offline', async () => { assert.equal(rendered.length, 4800); assert.equal(rendered.numberOfChannels, 1); const samples = rendered.channelData(0); - assert.ok(Math.abs(rms(samples.subarray(480)) - 0.5) < 0.02, `rms ${rms(samples)}`); + // The square is the spec's normalized PeriodicWave (peak 1, RMS about 0.83), as in Chrome. + const level = rms(samples.subarray(480)); + assert.ok(Math.abs(level - 0.415) < 0.01, `rms ${level}`); assert.equal(context.state, 'closed'); await assert.rejects(async () => context.startRendering(), /InvalidStateError/); });