History

added tickEfficient for string2;

spiricom committed 5 years ago

Commit daea60c1 parent 54e3a794 files · +89 −6Browse files

Unified · Split

4 files
  1. leaf/Inc/leaf-physical.h +2 −0
  2. leaf/Src/leaf-analysis.c +5 −5
  3. leaf/Src/leaf-physical.c +81 −0
  4. leaf/leaf-config.h +1 −1
leaf/Inc/leaf-physical.h+2−0
@@ -559,6 +559,8 @@ extern "C" { · 558 unmodified lines
559559 void tLivingString2_free (tLivingString2* const);
560560
561561 float tLivingString2_tick (tLivingString2* const, float input);
562+ float tLivingString2_tickEfficient (tLivingString2* const, float input);
563+ float tLivingString2_udpateDelays(tLivingString2* const pl); //necessary if using tickEfficient (so that parameter setting can be put in a slower process). included in standard tick.
562564 float tLivingString2_sample (tLivingString2* const);
563565 void tLivingString2_setFreq (tLivingString2* const, float freq);
564566 void tLivingString2_setWaveLength (tLivingString2* const, float waveLength); // in samples
leaf/Src/leaf-analysis.c+5−5
@@ -259,10 +259,10 @@ void tEnvPD_initToPool (tEnvPD* const xpd, int ws, int hs, int bs, tMem · 258 unmodified lines
259259 x->hopSize = period;
260260 x->blockSize = bs;
261261
262− for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
262+ for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0.0f;
263263 for (i = 0; i < npoints; i++)
264− x->buf[i] = (1.0f - cosf((2 * PI * i) / npoints))/npoints;
265− for (; i < npoints+INITVSTAKEN; i++) x->buf[i] = 0;
264+ x->buf[i] = (1.0f - cosf((2.0f * PI * i) / npoints))/npoints;
265+ for (; i < npoints+INITVSTAKEN; i++) x->buf[i] = 0.0f;
266266
267267 x->x_f = 0;
268268
@@ -317,7 +317,7 @@ void tEnvPD_processBlock(tEnvPD* const xpd, float* in) · 48 unmodified lines
317317 }
318318 *sump = sum;
319319 }
320− sump[0] = 0;
320+ sump[0] = 0.0f;
321321 x->x_phase -= n;
322322 if (x->x_phase < 0)
323323 {
@@ -325,7 +325,7 @@ void tEnvPD_processBlock(tEnvPD* const xpd, float* in) · 1 unmodified line
325325 for (count = x->x_realperiod, sump = x->x_sumbuf;
326326 count < x->x_npoints; count += x->x_realperiod, sump++)
327327 sump[0] = sump[1];
328− sump[0] = 0;
328+ sump[0] = 0.0f;
329329 x->x_phase = x->x_realperiod - n;
330330 }
331331 }
leaf/Src/leaf-physical.c+81−0
@@ -1003,6 +1003,87 @@ float tLivingString2_tick(tLivingString2* const pl, float input) · 1002 unmodified lines
10031003 return p->curr;
10041004 }
10051005
1006+float tLivingString2_tickEfficient(tLivingString2* const pl, float input)
1007+{
1008+ _tLivingString2* p = *pl;
1009+
1010+ input = input * 0.5f; // drop gain by half since we'll be equally adding it at half amplitude to forward and backward waveguides
1011+ // from prepPos upwards=forwards
1012+ //float pickupPos=tExpSmooth_tick(&p->puSmooth);
1013+ float wLen = p->wlSmooth->dest;
1014+
1015+ float pickP = p->ppSmooth->dest;
1016+
1017+ //need to determine which delay line to put it into (should be half amplitude into forward and backward lines for the correct portion of string)
1018+ float prepP = p->prpSmooth->dest;
1019+ float lowLen=p->prpSmooth->dest*p->wlSmooth->dest;
1020+ float upLen=(1.0f-p->prpSmooth->dest)*p->wlSmooth->dest;
1021+ uint32_t pickPInt;
1022+ if (pickP > prepP)
1023+ {
1024+ float fullPickPoint = ((pickP*wLen) - lowLen);
1025+ pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point
1026+
1027+ tHermiteDelay_addTo(&p->delUF, input, pickPInt);
1028+ tHermiteDelay_addTo(&p->delUB, input, (uint32_t) (upLen - pickPInt));
1029+ }
1030+ else
1031+ {
1032+ float fullPickPoint = pickP * wLen;
1033+ pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point
1034+
1035+ tHermiteDelay_addTo(&p->delLF, input, pickPInt);
1036+ tHermiteDelay_addTo(&p->delLB, input, (uint32_t) (lowLen - pickPInt));
1037+ }
1038+ float fromLF=tHermiteDelay_tickOut(&p->delLF);
1039+ float fromUF=tHermiteDelay_tickOut(&p->delUF);
1040+ float fromUB=tHermiteDelay_tickOut(&p->delUB);
1041+ float fromLB=tHermiteDelay_tickOut(&p->delLB);
1042+ // into upper half of string, from bridge, going backwards
1043+ //float fromBridge=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF)));
1044+ float fromBridge=-tFeedbackLeveler_tick(&p->fbLevU,tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF)));
1045+ tHermiteDelay_tickIn(&p->delUB, fromBridge);
1046+ // into lower half of string, from prepPoint, going backwards
1047+ float fromLowerPrep=-tTwoZero_tick(&p->prepFilterL, fromLF);
1048+ float intoLower=(p->prepIndex*fromLowerPrep)+((1.0f - p->prepIndex)*fromUB); //used to add input here
1049+ tHermiteDelay_tickIn(&p->delLB, intoLower);
1050+ // into lower half of string, from nut
1051+ //float fromNut=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB)));
1052+ float fromNut=-tFeedbackLeveler_tick(&p->fbLevL,tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB)));
1053+ tHermiteDelay_tickIn(&p->delLF, fromNut);
1054+ // into upper half of string, from prepPoint, going forwards/upwards
1055+ float fromUpperPrep=-tTwoZero_tick(&p->prepFilterU, fromUB);
1056+ float intoUpper=(p->prepIndex*fromUpperPrep)+((1.0f - p->prepIndex)*fromLF);
1057+ tHermiteDelay_tickIn(&p->delUF, intoUpper);
1058+ // update all delay lengths
1059+
1060+ p->curr = fromBridge;
1061+
1062+ //p->curr = fromBridge;
1063+ //p->curr += fromNut;
1064+
1065+ return p->curr;
1066+}
1067+
1068+float tLivingString2_udpateDelays(tLivingString2* const pl)
1069+{
1070+ _tLivingString2* p = *pl;
1071+
1072+
1073+
1074+ //need to determine which delay line to put it into (should be half amplitude into forward and backward lines for the correct portion of string)
1075+
1076+ float lowLen=p->prpSmooth->dest*p->wlSmooth->dest;
1077+ float upLen=(1.0f-p->prpSmooth->dest)*p->wlSmooth->dest;
1078+
1079+
1080+
1081+ tHermiteDelay_setDelay(&p->delLF, lowLen);
1082+ tHermiteDelay_setDelay(&p->delLB, lowLen);
1083+ tHermiteDelay_setDelay(&p->delUF, upLen);
1084+ tHermiteDelay_setDelay(&p->delUB, upLen);
1085+}
1086+
10061087 float tLivingString2_sample(tLivingString2* const pl)
10071088 {
10081089 _tLivingString2* p = *pl;
leaf/leaf-config.h+1−1
@@ -59,7 +59,7 @@ · 58 unmodified lines
5959 #define LEAF_USE_CMSIS 0
6060
6161 //! Use stdlib malloc() and free() internally instead of LEAF's normal mempool behavior for when you want to avoid being limited to and managing mempool a fixed mempool size. Usage of all object remains essentially the same.
62−#define LEAF_USE_DYNAMIC_ALLOCATION 1
62+#define LEAF_USE_DYNAMIC_ALLOCATION 0
6363
6464 //==============================================================================
6565

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