| @@ -419,14 +419,20 @@ void tRetune_init(tRetune* const r, int numVoices, int bufSize, int frameSize) · 418 unmodified lines |
| 419 | r->fba = FBA; | 419 | r->fba = FBA; |
| 420 | tRetune_setTimeConstant(r, DEFTIMECONSTANT); | 420 | tRetune_setTimeConstant(r, DEFTIMECONSTANT); |
| 421 | | 421 | |
| 422 | tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); | | |
| 423 | | | |
| 424 | r->inputPeriod = 0.0f; | 422 | r->inputPeriod = 0.0f; |
| 425 | | 423 | |
| 426 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); | 424 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| | 425 | r->pitchFactor = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| | 426 | r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 427 | for (int i = 0; i < r->numVoices; ++i) | 427 | for (int i = 0; i < r->numVoices; ++i) |
| 428 | { | 428 | { |
| 429 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); | 429 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| | 430 | } |
| | 431 | |
| | 432 | tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); |
| | 433 | |
| | 434 | for (int i = 0; i < r->numVoices; ++i) |
| | 435 | { |
| 430 | tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize); | 436 | tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize); |
| 431 | } | 437 | } |
| 432 | } | 438 | } |
| @@ -439,6 +445,8 @@ void tRetune_free(tRetune* const r) · 6 unmodified lines |
| 439 | tPitchShift_free(&r->ps[i]); | 445 | tPitchShift_free(&r->ps[i]); |
| 440 | leaf_free(r->outBuffers[i]); | 446 | leaf_free(r->outBuffers[i]); |
| 441 | } | 447 | } |
| | 448 | leaf_free(r->tickOutput); |
| | 449 | leaf_free(r->pitchFactor); |
| 442 | leaf_free(r->ps); | 450 | leaf_free(r->ps); |
| 443 | leaf_free(r->inBuffer); | 451 | leaf_free(r->inBuffer); |
| 444 | leaf_free(r->outBuffers); | 452 | leaf_free(r->outBuffers); |
| @@ -463,6 +471,8 @@ void tRetune_setNumVoices(tRetune* const r, int numVoices) · 18 unmodified lines |
| 463 | tPitchShift_free(&r->ps[i]); | 471 | tPitchShift_free(&r->ps[i]); |
| 464 | leaf_free(r->outBuffers[i]); | 472 | leaf_free(r->outBuffers[i]); |
| 465 | } | 473 | } |
| | 474 | leaf_free(r->tickOutput); |
| | 475 | leaf_free(r->pitchFactor); |
| 466 | leaf_free(r->ps); | 476 | leaf_free(r->ps); |
| 467 | leaf_free(r->outBuffers); | 477 | leaf_free(r->outBuffers); |
| 468 | | 478 | |
| @@ -470,6 +480,8 @@ void tRetune_setNumVoices(tRetune* const r, int numVoices) · 1 unmodified line |
| 470 | | 480 | |
| 471 | r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices); | 481 | r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices); |
| 472 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); | 482 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| | 483 | r->pitchFactor = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| | 484 | r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 473 | for (int i = 0; i < r->numVoices; ++i) | 485 | for (int i = 0; i < r->numVoices; ++i) |
| 474 | { | 486 | { |
| 475 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); | 487 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| @@ -540,12 +552,20 @@ void tAutotune_init(tAutotune* const r, int numVoices, int bufSize, int frameSiz · 64 unmodified lines |
| 540 | r->fba = FBA; | 552 | r->fba = FBA; |
| 541 | tAutotune_setTimeConstant(r, DEFTIMECONSTANT); | 553 | tAutotune_setTimeConstant(r, DEFTIMECONSTANT); |
| 542 | | 554 | |
| 543 | tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); | 555 | |
| 544 | | 556 | |
| 545 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); | 557 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| | 558 | r->freq = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| | 559 | r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 546 | for (int i = 0; i < r->numVoices; ++i) | 560 | for (int i = 0; i < r->numVoices; ++i) |
| 547 | { | 561 | { |
| 548 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); | 562 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| | 563 | } |
| | 564 | |
| | 565 | tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize); |
| | 566 | |
| | 567 | for (int i = 0; i < r->numVoices; ++i) |
| | 568 | { |
| 549 | tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize); | 569 | tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize); |
| 550 | } | 570 | } |
| 551 | | 571 | |
| @@ -560,6 +580,8 @@ void tAutotune_free(tAutotune* const r) · 8 unmodified lines |
| 560 | tPitchShift_free(&r->ps[i]); | 580 | tPitchShift_free(&r->ps[i]); |
| 561 | leaf_free(r->outBuffers[i]); | 581 | leaf_free(r->outBuffers[i]); |
| 562 | } | 582 | } |
| | 583 | leaf_free(r->tickOutput); |
| | 584 | leaf_free(r->freq); |
| 563 | leaf_free(r->ps); | 585 | leaf_free(r->ps); |
| 564 | leaf_free(r->inBuffer); | 586 | leaf_free(r->inBuffer); |
| 565 | leaf_free(r->outBuffers); | 587 | leaf_free(r->outBuffers); |
| @@ -584,6 +606,8 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 18 unmodified lines |
| 584 | tPitchShift_free(&r->ps[i]); | 606 | tPitchShift_free(&r->ps[i]); |
| 585 | leaf_free(r->outBuffers[i]); | 607 | leaf_free(r->outBuffers[i]); |
| 586 | } | 608 | } |
| | 609 | leaf_free(r->tickOutput); |
| | 610 | leaf_free(r->freq); |
| 587 | leaf_free(r->ps); | 611 | leaf_free(r->ps); |
| 588 | leaf_free(r->outBuffers); | 612 | leaf_free(r->outBuffers); |
| 589 | | 613 | |
| @@ -591,6 +615,8 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 1 unmodified line |
| 591 | | 615 | |
| 592 | r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices); | 616 | r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices); |
| 593 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); | 617 | r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices); |
| | 618 | r->freq = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| | 619 | r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices); |
| 594 | for (int i = 0; i < r->numVoices; ++i) | 620 | for (int i = 0; i < r->numVoices; ++i) |
| 595 | { | 621 | { |
| 596 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); | 622 | r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize); |
| @@ -600,7 +626,7 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 3 unmodified lines |
| 600 | | 626 | |
| 601 | } | 627 | } |
| 602 | | 628 | |
| 603 | void tAutotune_setFreq(tAutotune* const r, float f, int voice) | 629 | void tAutotune_setFreqs(tAutotune* const r, float f) |
| 604 | { | 630 | { |
| 605 | for (int i = 0; i < r->numVoices; ++i) | 631 | for (int i = 0; i < r->numVoices; ++i) |
| 606 | { | 632 | { |
| @@ -608,6 +634,11 @@ void tAutotune_setFreq(tAutotune* const r, float f, int voice) · 1 unmodified line |
| 608 | } | 634 | } |
| 609 | } | 635 | } |
| 610 | | 636 | |
| | 637 | void tAutotune_setFreq(tAutotune* const r, float f, int voice) |
| | 638 | { |
| | 639 | r->freq[voice] = f; |
| | 640 | } |
| | 641 | |
| 611 | void tAutotune_setTimeConstant(tAutotune* const r, float tc) | 642 | void tAutotune_setTimeConstant(tAutotune* const r, float tc) |
| 612 | { | 643 | { |
| 613 | r->timeConstant = tc; | 644 | r->timeConstant = tc; |
| @@ -644,7 +675,7 @@ static int pitchshift_attackdetect(tPitchShift* ps) · 30 unmodified lines |
| 644 | { | 675 | { |
| 645 | float envout; | 676 | float envout; |
| 646 | | 677 | |
| 647 | envout = tEnv_tick(&ps->p->env); | 678 | envout = tEnvPD_tick(&ps->p->env); |
| 648 | | 679 | |
| 649 | if (envout >= 1.0f) | 680 | if (envout >= 1.0f) |
| 650 | { | 681 | { |
| @@ -846,8 +877,7 @@ void tSOLAD_setPeriod(tSOLAD* const w, float period) · 195 unmodified lines |
| 846 | // set pitch factor between 0.25 and 4 | 877 | // set pitch factor between 0.25 and 4 |
| 847 | void tSOLAD_setPitchFactor(tSOLAD* const w, float pitchfactor) | 878 | void tSOLAD_setPitchFactor(tSOLAD* const w, float pitchfactor) |
| 848 | { | 879 | { |
| 849 | if(pitchfactor < 0.25) pitchfactor = 0.25; | 880 | if (pitchfactor <= 0.0f) return; |
| 850 | else if(pitchfactor > 4.) pitchfactor = 4.; | | |
| 851 | w->pitchfactor = pitchfactor; | 881 | w->pitchfactor = pitchfactor; |
| 852 | } | 882 | } |
| 853 | | 883 | |