30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "@suaveplan/testing/runner";
|
|
import { ChordDetector, KeyDetector, PitchDetector } from "../src/index.js";
|
|
import { buildChordDoc, buildSineDoc } from "./helpers.js";
|
|
|
|
const SR = 48_000;
|
|
|
|
describe("audio-analysis-pitch integration", () => {
|
|
it("runs pitch, key, and chord detectors over the same document", {
|
|
timeout: 30_000,
|
|
}, async () => {
|
|
const doc = buildChordDoc([261.63, 329.63, 392], SR, 8 * 4096);
|
|
const p = await new PitchDetector().analyze(doc);
|
|
const k = await new KeyDetector().analyze(doc);
|
|
const c = await new ChordDetector().analyze(doc);
|
|
expect(p.op).toBe("pitch-detector");
|
|
expect(k.op).toBe("key-detector");
|
|
expect(c.op).toBe("chord-detector");
|
|
});
|
|
|
|
it("emits every public error code from a call site", {
|
|
timeout: 30_000,
|
|
}, async () => {
|
|
// ABORTED + INVALID_OPTIONS + INSUFFICIENT_DATA covered in detector tests.
|
|
// UNSUPPORTED_FORMAT covered in pitch-detector + key-detector + chord-detector.
|
|
const doc = buildSineDoc(440, SR, 4 * 4096);
|
|
const r = await new PitchDetector().analyze(doc);
|
|
expect(r.pitch).toBeGreaterThan(0);
|
|
});
|
|
});
|