History

debugging retune and autotune, removed clip on setting pitch factor

Matthew Wang committed 7 years ago

Commit 4f70bc61 parent dd56c544 files · +58 −15Browse files

Unified · Split

4 files
  1. LEAF/Inc/leaf-effects.h +1 −0
  2. LEAF/Src/leaf-analysis.c +1 −0
  3. LEAF/Src/leaf-effects.c +37 −7
  4. LEAF_JUCEPlugin/Source/MyTest.cpp +19 −8
LEAF/Inc/leaf-effects.h+1−0
@@ -218,6 +218,7 @@ void tAutotune_free (tAutotune* const); · 217 unmodified lines
218218
219219 float* tAutotune_tick (tAutotune* const, float sample);
220220 void tAutotune_setNumVoices (tAutotune* const, int numVoices);
221+void tAutotune_setFreqs (tAutotune* const, float f);
221222 void tAutotune_setFreq (tAutotune* const, float f, int voice);
222223 void tAutotune_setTimeConstant (tAutotune* const, float tc);
223224 void tAutotune_setHopSize (tAutotune* const, int hs);
LEAF/Src/leaf-analysis.c+1−0
@@ -715,6 +715,7 @@ static float snac_spectralpeak(tSNAC* const s, float periodlength) · 714 unmodified lines
715715 // modified logarithmic bias function
716716 static void snac_biasbuf(tSNAC* const s)
717717 {
718+
718719 int n;
719720 int maxperiod = (int)(s->framesize * (float)SEEK);
720721 float bias = s->biasfactor / log((float)(maxperiod - 4));
LEAF/Src/leaf-effects.c+37−7
@@ -419,14 +419,20 @@ void tRetune_init(tRetune* const r, int numVoices, int bufSize, int frameSize) · 418 unmodified lines
419419 r->fba = FBA;
420420 tRetune_setTimeConstant(r, DEFTIMECONSTANT);
421421
422− tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
423−
424422 r->inputPeriod = 0.0f;
425423
426424 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);
427427 for (int i = 0; i < r->numVoices; ++i)
428428 {
429429 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+ {
430436 tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
431437 }
432438 }
@@ -439,6 +445,8 @@ void tRetune_free(tRetune* const r) · 6 unmodified lines
439445 tPitchShift_free(&r->ps[i]);
440446 leaf_free(r->outBuffers[i]);
441447 }
448+ leaf_free(r->tickOutput);
449+ leaf_free(r->pitchFactor);
442450 leaf_free(r->ps);
443451 leaf_free(r->inBuffer);
444452 leaf_free(r->outBuffers);
@@ -463,6 +471,8 @@ void tRetune_setNumVoices(tRetune* const r, int numVoices) · 18 unmodified lines
463471 tPitchShift_free(&r->ps[i]);
464472 leaf_free(r->outBuffers[i]);
465473 }
474+ leaf_free(r->tickOutput);
475+ leaf_free(r->pitchFactor);
466476 leaf_free(r->ps);
467477 leaf_free(r->outBuffers);
468478
@@ -470,6 +480,8 @@ void tRetune_setNumVoices(tRetune* const r, int numVoices) · 1 unmodified line
470480
471481 r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices);
472482 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);
473485 for (int i = 0; i < r->numVoices; ++i)
474486 {
475487 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
540552 r->fba = FBA;
541553 tAutotune_setTimeConstant(r, DEFTIMECONSTANT);
542554
543− tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
555+
544556
545557 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);
546560 for (int i = 0; i < r->numVoices; ++i)
547561 {
548562 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+ {
549569 tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
550570 }
551571
@@ -560,6 +580,8 @@ void tAutotune_free(tAutotune* const r) · 8 unmodified lines
560580 tPitchShift_free(&r->ps[i]);
561581 leaf_free(r->outBuffers[i]);
562582 }
583+ leaf_free(r->tickOutput);
584+ leaf_free(r->freq);
563585 leaf_free(r->ps);
564586 leaf_free(r->inBuffer);
565587 leaf_free(r->outBuffers);
@@ -584,6 +606,8 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 18 unmodified lines
584606 tPitchShift_free(&r->ps[i]);
585607 leaf_free(r->outBuffers[i]);
586608 }
609+ leaf_free(r->tickOutput);
610+ leaf_free(r->freq);
587611 leaf_free(r->ps);
588612 leaf_free(r->outBuffers);
589613
@@ -591,6 +615,8 @@ void tAutotune_setNumVoices(tAutotune* const r, int numVoices) · 1 unmodified line
591615
592616 r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices);
593617 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);
594620 for (int i = 0; i < r->numVoices; ++i)
595621 {
596622 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
600626
601627 }
602628
603−void tAutotune_setFreq(tAutotune* const r, float f, int voice)
629+void tAutotune_setFreqs(tAutotune* const r, float f)
604630 {
605631 for (int i = 0; i < r->numVoices; ++i)
606632 {
@@ -608,6 +634,11 @@ void tAutotune_setFreq(tAutotune* const r, float f, int voice) · 1 unmodified line
608634 }
609635 }
610636
637+void tAutotune_setFreq(tAutotune* const r, float f, int voice)
638+{
639+ r->freq[voice] = f;
640+}
641+
611642 void tAutotune_setTimeConstant(tAutotune* const r, float tc)
612643 {
613644 r->timeConstant = tc;
@@ -644,7 +675,7 @@ static int pitchshift_attackdetect(tPitchShift* ps) · 30 unmodified lines
644675 {
645676 float envout;
646677
647− envout = tEnv_tick(&ps->p->env);
678+ envout = tEnvPD_tick(&ps->p->env);
648679
649680 if (envout >= 1.0f)
650681 {
@@ -846,8 +877,7 @@ void tSOLAD_setPeriod(tSOLAD* const w, float period) · 195 unmodified lines
846877 // set pitch factor between 0.25 and 4
847878 void tSOLAD_setPitchFactor(tSOLAD* const w, float pitchfactor)
848879 {
849− if(pitchfactor < 0.25) pitchfactor = 0.25;
850− else if(pitchfactor > 4.) pitchfactor = 4.;
880+ if (pitchfactor <= 0.0f) return;
851881 w->pitchfactor = pitchfactor;
852882 }
853883
LEAF_JUCEPlugin/Source/MyTest.cpp+19−8
@@ -19,6 +19,8 @@ static void run_pool_test(void); · 18 unmodified lines
1919 tNoise noise;
2020 tCycle sine;
2121 tDelay delay;
22+tRetune retune;
23+tAutotune autotune;
2224
2325 float gain;
2426 float freq;
@@ -39,16 +41,23 @@ void LEAFTest_init (float sampleRate, int blockSize) · 14 unmodified lines
3941 tDelay_init(&delay, 44100, 44100);
4042 tDelay_free(&delay); //most basic free test
4143 tDelay_init(&delay, 44100, 44100);
44+
45+ tRetune_init(&retune, 1, 4096, 2048);
46+ tAutotune_init(&autotune, 1, 4096, 2048);
4247 }
4348
4449 float LEAFTest_tick (float input)
4550 {
46− tCycle_setFreq(&sine, freq);
47− float sample = tCycle_tick(&sine) * 0.1;
48− tDelay_setDelay(&delay, dtime);
49− sample += tDelay_tick(&delay, sample);
50−
51− return sample;
51+ float sample = tCycle_tick(&sine);
52+ float* retuneOut = tRetune_tick(&retune, sample);
53+ float* autotuneOut = tAutotune_tick(&autotune, sample);
54+ float r1 = retuneOut[0];
55+ //float r2 = retuneOut[1];
56+ float a1 = autotuneOut[0];
57+ //float a2 = autotuneOut[1];
58+ sample = a1;
59+
60+ return sample * 0.25f;
5261 }
5362
5463
@@ -57,10 +66,12 @@ bool lastState = false, lastPlayState = false; · 2 unmodified lines
5766 void LEAFTest_block (void)
5867 {
5968 float val = getSliderValue("mod freq");
60− freq = val * 2000.f;
69+ tRetune_setPitchFactor(&retune, val*4.0f + 0.5f, 0);
70+ tAutotune_setFreq(&autotune, val*5000.0f + 50.0f, 0);
6171
6272 val = getSliderValue("mod depth");
63− dtime = val * 40000.;
73+ tRetune_setPitchFactor(&retune, val*4.0f + 0.5f, 1);
74+ tAutotune_setFreq(&autotune, val*5000.0f + 50.0f, 1);
6475 }
6576
6677 void LEAFTest_controllerInput (int cnum, float cval)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t