Commit 2ff331d
committed
feat(streaming): Add chord progression pattern detection and improve bar chord accuracy
Enhance streaming chord analysis with known pattern recognition and voting-based bar detection:
Chord Pattern Detection:
- Add library of known progressions (Royal Road, Komuro, Canon, Just the Two of Us, etc.)
- Compute voted pattern by aggregating chords across pattern repetitions
- Score detected progression against known patterns with weighted similarity
- Return all pattern scores sorted by confidence
Bar Chord Improvements:
- Replace chroma averaging with frame-by-frame chord voting for more accurate detection
- Add retroactive bar chord detection using stored chroma history
- Store full chroma history (up to ~35s) for analysis when BPM stabilizes
- Compute bar chords from the start of audio retroactively
API Changes:
- Add votedPattern, patternLength, detectedPatternName, detectedPatternScore, allPatternScores to ProgressiveEstimate
- Add sampleRate() method to StreamAnalyzer
- Change stats() to non-const (triggers final pattern computation)
Testing:
- Add tests for C-G-Am-F progression detection
- Add tests for voted pattern structure and values
- Add tests for pattern detection fields
- Add tests for allPatternScores ordering
- Add tests for reset behavior1 parent 591ce91 commit 2ff331d
8 files changed
Lines changed: 2071 additions & 25 deletions
File tree
- js
- src
- streaming
- wasm
- tests/wasm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
| |||
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
189 | 199 | | |
190 | 200 | | |
191 | 201 | | |
| |||
223 | 233 | | |
224 | 234 | | |
225 | 235 | | |
| 236 | + | |
226 | 237 | | |
227 | 238 | | |
228 | 239 | | |
| |||
1390 | 1401 | | |
1391 | 1402 | | |
1392 | 1403 | | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
1393 | 1412 | | |
1394 | 1413 | | |
1395 | 1414 | | |
| |||
1407 | 1426 | | |
1408 | 1427 | | |
1409 | 1428 | | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
1410 | 1434 | | |
1411 | 1435 | | |
1412 | 1436 | | |
| |||
1583 | 1607 | | |
1584 | 1608 | | |
1585 | 1609 | | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
1586 | 1624 | | |
1587 | 1625 | | |
1588 | 1626 | | |
| |||
1604 | 1642 | | |
1605 | 1643 | | |
1606 | 1644 | | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
1607 | 1652 | | |
1608 | 1653 | | |
1609 | 1654 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
350 | 355 | | |
351 | 356 | | |
352 | 357 | | |
| |||
361 | 366 | | |
362 | 367 | | |
363 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
364 | 374 | | |
365 | 375 | | |
366 | 376 | | |
| |||
398 | 408 | | |
399 | 409 | | |
400 | 410 | | |
| 411 | + | |
401 | 412 | | |
402 | 413 | | |
403 | 414 | | |
| |||
0 commit comments