feat: release Find-Word v0.2.3
This commit is contained in:
+26
-14
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ENVIRONMENTS, LEVELS } from "../src/content";
|
||||
import { dbToGain, normalizeRms, synthesizeBackground } from "../src/audio/dsp";
|
||||
import { dbToGain, normalizeRms, mixingGains } from "../src/audio/dsp";
|
||||
|
||||
// 청감이나 실제 음압은 장치마다 다르므로 테스트 대상은 디지털 RMS와 gain
|
||||
// 비율이다. 배경·음성을 같은 기준으로 정규화해야 표기한 상대 dB가 성립한다.
|
||||
@@ -19,19 +19,31 @@ describe("상대 dB와 결정론적 배경 합성", () => {
|
||||
expect(output).not.toBe(input);
|
||||
expect(() => normalizeRms(new Float32Array(4))).toThrow("무음");
|
||||
});
|
||||
it("여덟 환경이 서로 다르고 같은 seed는 같은 안전 범위 신호를 만든다", () => {
|
||||
const signatures = new Set<string>();
|
||||
for (const preset of ENVIRONMENTS) {
|
||||
const signal = synthesizeBackground(preset, 16000, 1);
|
||||
expect(signal).toHaveLength(16000);
|
||||
expect(signal).toEqual(synthesizeBackground(preset, 16000, 1));
|
||||
expect(rms(signal)).toBeCloseTo(0.12, 5);
|
||||
expect(Math.max(...signal.map(Math.abs))).toBeLessThan(1);
|
||||
// 루프 경계에서 불연속 클릭이 생기지 않도록 양 끝을 0으로 감싼다.
|
||||
expect(signal[0]).toBe(0);
|
||||
expect(signal.at(-1)).toBe(0);
|
||||
signatures.add([...signal.slice(0, 100)].join(","));
|
||||
it("여덟 환경은 고유 same-origin WAV이며 절차적 합성 매개변수를 갖지 않는다", () => {
|
||||
expect(new Set(ENVIRONMENTS.map((e) => e.audioUrl)).size).toBe(8);
|
||||
for (const environment of ENVIRONMENTS) {
|
||||
const url = new URL(environment.audioUrl, "http://localhost");
|
||||
expect(url.origin).toBe("http://localhost");
|
||||
expect(url.pathname).toBe(`/ambience/${environment.id}.wav`);
|
||||
expect(environment).not.toHaveProperty("seed");
|
||||
}
|
||||
});
|
||||
it("피크가 큰 녹음도 공통 감쇠로 합성 peak 0.8을 넘지 않고 SNR 비율을 보존한다", () => {
|
||||
const voice = normalizeRms(
|
||||
new Float32Array([1, ...Array(999).fill(0)]),
|
||||
0.03,
|
||||
);
|
||||
const background = normalizeRms(new Float32Array([0.2, -0.2]), 0.03);
|
||||
for (const db of [-12, -6, 0, 6, 12]) {
|
||||
const gains = mixingGains(voice, background, voice, db);
|
||||
expect(20 * Math.log10(gains.voice / gains.background)).toBeCloseTo(
|
||||
db,
|
||||
10,
|
||||
);
|
||||
expect(
|
||||
Math.max(...voice) * (gains.voice + gains.intro) +
|
||||
0.03 * gains.background,
|
||||
).toBeLessThanOrEqual(0.800001);
|
||||
}
|
||||
expect(signatures.size).toBe(8);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user