History

merged with latest leaf. may have messed up some initToPools by adding unecessary additional arguments of leaf consts

spiricom committed 6 years ago

Commit 27cbc032 parents 23faeb0 a3ef3e02 files · +35 −25Browse files

Unified · Split

2 files
  1. leaf/Src/leaf-effects.c +33 −24
  2. leaf/Src/leaf-mempool.c +2 −1
leaf/Src/leaf-effects.c+33−24
@@ -89,14 +89,18 @@ void tTalkbox_update(tTalkbox* const voc) ///update internal parameters... · 88 unmodified lines
8989 LEAF* leaf = v->mempool->leaf;
9090
9191 float fs = leaf->sampleRate;
92− if(fs < 8000.0f) fs = 8000.0f;
93− if(fs > 96000.0f) fs = 96000.0f;
92+// if(fs < 8000.0f) fs = 8000.0f;
93+// if(fs > 96000.0f) fs = 96000.0f;
9494
9595 int32_t n = (int32_t)(0.01633f * fs); //this sets the window time to 16ms if the buffer is large enough. Buffer needs to be at least 784 samples at 48000
9696 if(n > v->bufsize) n = v->bufsize;
9797
9898 //O = (VstInt32)(0.0005f * fs);
9999 v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * fs);
100+ if (v->O >= ORD_MAX)
101+ {
102+ v->O = ORD_MAX-1;
103+ }
100104
101105 if(n != v->N) //recalc hanning window
102106 {
@@ -261,7 +265,6 @@ void tTalkbox_lpc(float *buf, float *car, double* dl, double* Rt, int32_t n, int · 158 unmodified lines
261265 float z[ORD_MAX], r[ORD_MAX], x;
262266 int32_t i, j, nn=n;
263267
264−
265268 if (warpOn == 0)
266269 {
267270 for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
@@ -286,11 +289,11 @@ void tTalkbox_lpc(float *buf, float *car, double* dl, double* Rt, int32_t n, int · 18 unmodified lines
286289 {
287290 if(r[0] < min)
288291 {
289−// for(i=0; i<n; i++)
290−// {
291− buf[0] = 0.0f;
292− return;
293−// }
292+ for(i=0; i<n; i++)
293+ {
294+ buf[i] = 0.0f;
295+ }
296+ return;
294297 }
295298
296299 tTalkbox_lpcDurbin(r, o, k, G); //calc reflection coeffs
@@ -418,14 +421,18 @@ void tTalkboxFloat_update(tTalkboxFloat* const voc) ///update internal parameter · 121 unmodified lines
418421 LEAF* leaf = v->mempool->leaf;
419422
420423 float fs = leaf->sampleRate;
421− if(fs < 8000.0f) fs = 8000.0f;
422− if(fs > 96000.0f) fs = 96000.0f;
424+// if(fs < 8000.0f) fs = 8000.0f;
425+// if(fs > 96000.0f) fs = 96000.0f;
423426
424427 int32_t n = (int32_t)(0.01633f * fs); //this sets the window time to 16ms if the buffer is large enough. Buffer needs to be at least 784 samples at 48000
425428 if(n > v->bufsize) n = v->bufsize;
426429
427430 //O = (VstInt32)(0.0005f * fs);
428431 v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * fs);
432+ if (v->O >= ORD_MAX)
433+ {
434+ v->O = ORD_MAX-1;
435+ }
429436
430437 if(n != v->N) //recalc hanning window
431438 {
@@ -589,20 +596,20 @@ float tTalkboxFloat_tick(tTalkboxFloat* const voc, float synth, float voice) · 157 unmodified lines
589596 void tTalkboxFloat_lpc(float *buf, float *car, float* dl, float* Rt, int32_t n, int32_t o, float warp, int warpOn, float *k, int freeze, float *G)
590597 {
591598 float z[ORD_MAX], r[ORD_MAX], x;
592− int32_t i, j, nn=n;
593−
594−
599+
595600 if (warpOn == 0)
596601 {
597− for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
602+ int nn = n;
603+ for(int j = 0; j <= o; j++, nn--) //buf[] is already emphasized and windowed
598604 {
599605 z[j] = r[j] = 0.0f;
600− for(i=0; i<nn; i++) r[j] += buf[i] * buf[i+j]; //autocorrelation
606+ for(int i = 0; i < nn; i++) r[j] += buf[i] * buf[i+j]; //autocorrelation
601607 }
602608 }
603609 else
604610 {
605− for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
611+ int nn = n;
612+ for(int j = 0; j <= o; j++, nn--) //buf[] is already emphasized and windowed
606613 {
607614 z[j] = r[j] = 0.0f;
608615 }
@@ -616,26 +623,28 @@ void tTalkboxFloat_lpc(float *buf, float *car, float* dl, float* Rt, int32_t n, · 7 unmodified lines
616623 {
617624 if(r[0] < min)
618625 {
619−// for(i=0; i<n; i++)
620−// {
621− buf[0] = 0.0f;
622− return;
623−// }
626+
627+ for(int i = 0; i < n; i++)
628+ {
629+ buf[i] = 0.0f;
630+ }
631+ return;
632+
624633 }
625634
626635 tTalkbox_lpcDurbin(r, o, k, G); //calc reflection coeffs
627636
628637 //this is for stability to keep reflection coefficients inside the unit circle
629638 //but in Harma's papers I've seen 0.998. just needs to be less than 1 it seems but maybe some wiggle room to avoid instability from floating point precision -JS
630− for(i=0; i<=o; i++)
639+ for(int i = 0; i <= o; i++)
631640 {
632641 if(k[i] > 0.998f) k[i] = 0.998f; else if(k[i] < -0.998f) k[i] = -.998f;
633642 }
634643 }
635− for(i=0; i<n; i++)
644+ for(int i = 0; i < n; i++)
636645 {
637646 x = G[0] * car[i];
638− for(j=o; j>0; j--) //lattice filter
647+ for(int j = o; j > 0; j--) //lattice filter
639648 {
640649 x -= k[j] * z[j-1];
641650 z[j] = z[j-1] + k[j] * x;
leaf/Src/leaf-mempool.c+2−1
@@ -424,7 +424,8 @@ void tMempool_initToPool (tMempool* const mp, char* memory, size_t size, · 423 unmodified lines
424424 {
425425 _tMempool* mm = *mem;
426426 _tMempool* m = *mp = (_tMempool*) mpool_alloc(sizeof(_tMempool), mm);
427− m->leaf = leaf;
427+ m->leaf = mm->leaf;
428+
428429 mpool_create (memory, size, m);
429430 }
430431

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