/* Copyright 2026 Lotus Guild SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ import { describe, expect, it } from "vitest"; import { MicLevelQuantizer } from "./lotusMicLevel"; describe("MicLevelQuantizer", () => { it("maps RMS to 0–3 bars", () => { expect(new MicLevelQuantizer().push(0.001)).toBe(0); expect(new MicLevelQuantizer().push(0.008)).toBe(1); expect(new MicLevelQuantizer().push(0.02)).toBe(2); expect(new MicLevelQuantizer().push(0.2)).toBe(3); }); it("rises at once and falls one bar per sample", () => { const q = new MicLevelQuantizer(); expect(q.push(0.2)).toBe(3); expect(q.push(0)).toBe(2); expect(q.push(0)).toBe(1); expect(q.push(0.02)).toBe(2); expect(q.push(0)).toBe(1); expect(q.push(0)).toBe(0); expect(q.push(0)).toBe(0); }); it("reset drops straight to 0", () => { const q = new MicLevelQuantizer(); q.push(0.2); q.reset(); expect(q.push(0)).toBe(0); }); });