3.4 KiB
3.4 KiB
Tasks: enterprise-audio-analysis-pitch
Change ID: enterprise-audio-analysis-pitch
Package: @suaveplan/audio-analysis-pitch
Target path: packages/media/audio/audio-analysis-pitch
Prerequisite packages on Verdaccio: @suaveplan/audio-core, @suaveplan/error, @suaveplan/types
1. Scaffold
- Create directory
packages/media/audio/audio-analysis-pitch/withsrc/,tests/,src/__benchmarks__/, and all feature subdirectories per the layout inproposal.md. - Write
package.jsonat version0.1.0with"type": "module","sideEffects": false, fullexportsmap, deps:@suaveplan/audio-core workspace:^,@suaveplan/error workspace:^,@suaveplan/types workspace:^,@suaveplan/opentelemetry workspace:^,zod catalog:forms. - Write
tsconfig.jsonextending@suaveplan/typescript-config/library.json. - Write
vitest.config.tsusingcreateTestConfig()from@suaveplan/testing/config. - Add
lint,typecheck,test,test:coverage,build,docs:checkscripts.
2. Types + errors
- Write
src/error-codes.ts—PITCHErrorCode,AUDIO_ANALYSIS_PITCH_ERROR_METADATA,registerAudioAnalysisErrorCodes(). - Write Zod schemas:
PitchDetectorOptionsSchema,PitchResultSchema,KeyDetectorOptionsSchema,KeyResultSchema,ChordResultSchema.
3. Algorithms
- Implement
yin.ts— YIN pitch detection algorithm. - Write
yin.test.tsandyin.md(≥200 words). - Implement
chromagram.ts— 12-bin pitch class profile from magnitude spectrum. - Write
chromagram.test.tsandchromagram.md(≥200 words). - Implement
key-finding.ts— Krumhansl-Schmuckler and Temperley key profiles. - Write
key-finding.test.tsandkey-finding.md(≥200 words). - Implement
chord-matching.ts— template matching for chord recognition. - Write
chord-matching.test.tsandchord-matching.md(≥200 words).
4. Detectors
- Implement
PitchDetectorclass withanalyze(),analyzeStream(),analyzeBlock(). - Write
pitch-detector.test.tsandpitch-detector.md(≥200 words). - Implement
KeyDetectorclass withanalyze(),analyzeStream(). - Write
key-detector.test.tsandkey-detector.md(≥200 words). - Implement
ChordDetectorclass withanalyze(),analyzeStream(). - Write
chord-detector.test.tsandchord-detector.md(≥200 words). - Wire OTel: spans, counters, histograms per detector.
5. Benchmarks
- Write
src/__benchmarks__/pitch.bench.ts— pitch detect 1-minute track, key detect 1-minute track.
6. Tests
- Write
tests/integration.test.ts— full pitch/key/chord round-trip on real audio fixture. - Write
tests/property.test.ts(fast-check) — sine wave frequency → exact pitch, confidence in [0,1].
7. Docs + verify + publish
- All co-located
.mdfiles (≥200 words each). - Write
README.mdat package root. bunx turbo lint typecheck test --filter=@suaveplan/audio-analysis-pitch— green.bunx turbo test:coverage --filter=@suaveplan/audio-analysis-pitch— 100%.bun scripts/publish.ts --package @suaveplan/audio-analysis-pitch.- Fold
specs/audio-analysis-pitch/spec.mdintoopenspec/specs/audio-analysis-pitch/spec.md. - Archive to
openspec/archive/2026-05-14-enterprise-audio-analysis-pitch/.