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
559 void tLivingString2_free (tLivingString2* const);559 void tLivingString2_free (tLivingString2* const);
560 560
561 float tLivingString2_tick (tLivingString2* const, float input);561 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.
562 float tLivingString2_sample (tLivingString2* const);564 float tLivingString2_sample (tLivingString2* const);
563 void tLivingString2_setFreq (tLivingString2* const, float freq);565 void tLivingString2_setFreq (tLivingString2* const, float freq);
564 void tLivingString2_setWaveLength (tLivingString2* const, float waveLength); // in samples566 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
259 x->hopSize = period;259 x->hopSize = period;
260 x->blockSize = bs;260 x->blockSize = bs;
261 261
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;
263 for (i = 0; i < npoints; i++)263 for (i = 0; i < npoints; i++)
264 x->buf[i] = (1.0f - cosf((2 * PI * i) / npoints))/npoints;264 x->buf[i] = (1.0f - cosf((2.0f * PI * i) / npoints))/npoints;
265 for (; i < npoints+INITVSTAKEN; i++) x->buf[i] = 0;265 for (; i < npoints+INITVSTAKEN; i++) x->buf[i] = 0.0f;
266 266
267 x->x_f = 0;267 x->x_f = 0;
268 268
@@ -317,7 +317,7 @@ void tEnvPD_processBlock(tEnvPD* const xpd, float* in) · 48 unmodified lines
317 }317 }
318 *sump = sum;318 *sump = sum;
319 }319 }
320 sump[0] = 0;320 sump[0] = 0.0f;
321 x->x_phase -= n;321 x->x_phase -= n;
322 if (x->x_phase < 0)322 if (x->x_phase < 0)
323 {323 {
@@ -325,7 +325,7 @@ void tEnvPD_processBlock(tEnvPD* const xpd, float* in) · 1 unmodified line
325 for (count = x->x_realperiod, sump = x->x_sumbuf;325 for (count = x->x_realperiod, sump = x->x_sumbuf;
326 count < x->x_npoints; count += x->x_realperiod, sump++)326 count < x->x_npoints; count += x->x_realperiod, sump++)
327 sump[0] = sump[1];327 sump[0] = sump[1];
328 sump[0] = 0;328 sump[0] = 0.0f;
329 x->x_phase = x->x_realperiod - n;329 x->x_phase = x->x_realperiod - n;
330 }330 }
331}331}
leaf/Src/leaf-physical.c+81−0
@@ -1003,6 +1003,87 @@ float tLivingString2_tick(tLivingString2* const pl, float input) · 1002 unmodified lines
1003 return p->curr;1003 return p->curr;
1004}1004}
1005 1005
1006float 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
1068float 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
1006float tLivingString2_sample(tLivingString2* const pl)1087float tLivingString2_sample(tLivingString2* const pl)
1007{1088{
1008 _tLivingString2* p = *pl;1089 _tLivingString2* p = *pl;
leaf/leaf-config.h+1−1
@@ -59,7 +59,7 @@ · 58 unmodified lines
59#define LEAF_USE_CMSIS 059#define LEAF_USE_CMSIS 0
60 60
61//! 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.61//! 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 162#define LEAF_USE_DYNAMIC_ALLOCATION 0
63 63
64//==============================================================================64//==============================================================================
65 65

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