···524524525525The profiling code has been added to measure actual performance on each platform.
526526527527+## Current CQT Implementation Status (December 2024)
528528+529529+### What's Working:
530530+- **16K FFT implemented** - provides excellent low-frequency resolution
531531+- **cqt(bin)** function working correctly - returns raw CQT magnitude for bin 0-119
532532+- **Frequency detection accurate** - 440Hz correctly maps to bin 54, etc.
533533+- **Kernels properly generated** - sparse storage working, good frequency selectivity
534534+- **Performance excellent** - Runtime on M1 Pro: 0.368ms total (0.255ms FFT + 0.113ms kernels)
535535+536536+### Runtime Performance Expectations:
537537+- **M1 Pro MacBook**: 0.368ms total CQT processing (~2.2% of frame budget)
538538+- **ThinkPad i5-1130G7 (extrapolated)**:
539539+ - Performance mode: ~0.426ms (2.6% of frame budget)
540540+ - Power save mode: ~1.273ms (7.6% of frame budget)
541541+- Runtime is ~3.8x slower than synthetic benchmarks due to real audio data, cache effects
542542+543543+### Critical Implementation Details:
544544+1. **FFT_SIZE temporarily changed** in fftdata.h from 1024 to 8192 to support CQT
545545+ - This breaks FFT resolution but enables CQT
546546+ - Must be reverted when separate audio buffer is implemented
547547+548548+2. **Key fixes that were essential**:
549549+ - Kernel phase calculation must use full FFT position: `2π * (f/fs) * (idx - N/2)`
550550+ - NO scaling factor after kernel FFT - this was critical!
551551+ - Normalization by windowLength before FFT
552552+553553+3. **Test scripts created**:
554554+ - `test_cqt_spectrum_v2.lua` - visual spectrum analyzer
555555+ - `test_cqt_a4.lua` - 440Hz tone generator
556556+ - `test_cqt_stable.lua` - controlled testing
557557+558558+### Resolution Characteristics with 16K FFT:
559559+- **20Hz**: Q≈7.4 (window truncated to 16384 samples, but much better than 6K's Q≈1.86)
560560+- **30Hz**: Q≈11.2 (good resolution)
561561+- **45Hz+**: Full Q≈17 (perfect - no truncation)
562562+527563## Phase 3: Next Steps
5285641. ~~Implement 16K FFT based on benchmark results~~ (COMPLETE)
5295652. Add remaining API functions: `cqts()`, `cqto()`, `cqtos()`