Repository navigation
Commit 8e53091
authored
[FIX] ASR: correct reconstruction dim count, blend seam, and RMS window rounding (#111)
Three independent fixes in the calibration/reconstruction path:
- **maxdims / keep-mask off-by-one in `asr_process`:** `maxdims` used
`np.fix` (truncate toward zero) instead of round-half-away, and the
keep-mask index term protected one component too many. The spec converts
the fractional `0.66` factor with round-half-away-from-zero, and its
1-based `(1:C) < (C - maxdims)` protects `C-maxdims-1` components, so
use `int(np.floor(0.66 * nc + 0.5))` and `np.arange(nc) < nc - maxdims -
1`. Together these made the code under-remove artifact dimensions.
- **Raised-cosine blend endpoint in `asr_process`:** `np.arange(ns)/ns`
never reaches 1, so the block's final sample kept a residual fraction of
the previous reconstruction. Shift the phase to `np.arange(1, ns +
1)/ns` so `blend[-1] = 1.0` and the last sample equals the new
reconstruction.
- **RMS window starts in `asr_calibrate`:** the step `N*(1-win_overlap)`
was rounded before building the window starts, drifting from the correct
positions for a non-integer step (biasing `mu`/`sig`/`T`). Extract a
`_rms_window_offsets` helper that rounds each start (matching
`clean_windows`).
### Testing
Adds a regression test for each. Full `tests/test_asr.py` passes; `ruff`
clean.1 parent 3b0c530 commit 8e53091
2 files changed
Lines changed: 77 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
420 | 429 | | |
421 | 430 | | |
422 | 431 | | |
| |||
524 | 533 | | |
525 | 534 | | |
526 | 535 | | |
527 | | - | |
| 536 | + | |
528 | 537 | | |
529 | 538 | | |
530 | 539 | | |
| |||
604 | 613 | | |
605 | 614 | | |
606 | 615 | | |
607 | | - | |
| 616 | + | |
608 | 617 | | |
609 | 618 | | |
610 | 619 | | |
| |||
618 | 627 | | |
619 | 628 | | |
620 | 629 | | |
621 | | - | |
| 630 | + | |
622 | 631 | | |
623 | 632 | | |
624 | 633 | | |
| |||
632 | 641 | | |
633 | 642 | | |
634 | 643 | | |
635 | | - | |
| 644 | + | |
636 | 645 | | |
637 | 646 | | |
638 | 647 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | 304 | | |
306 | 305 | | |
307 | 306 | | |
| |||
537 | 536 | | |
538 | 537 | | |
539 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
540 | 603 | | |
541 | 604 | | |
542 | 605 | | |
| |||
0 commit comments