Unified · Split
| @@ -69,15 +69,15 @@ · 68 unmodified lines | |||
| 69 | #if defined(GOOD_TRIG) | 69 | #if defined(GOOD_TRIG) |
| 70 | #define FHT_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);} | 70 | #define FHT_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);} |
| 71 | #define TRIG_VARS \ | 71 | #define TRIG_VARS \ |
| 72 | int t_lam=0; | 72 | int t_lam=0; USED(t_lam); |
| 73 | #define TRIG_INIT(k,c,s) \ | 73 | #define TRIG_INIT(k,c,s) \ |
| 74 | { \ | 74 | { \ |
| 75 | int i; \ | 75 | int i; \ |
| 76 | for (i=2 ; i<=k ; i++) \ | 76 | for (i=2 ; i<=k ; i++) \ |
| 77 | {coswrk[i]=costab[i];sinwrk[i]=sintab[i];} \ | 77 | {coswrk[i]=costab[i];sinwrk[i]=sintab[i];} \ |
| 78 | t_lam = 0; \ | 78 | t_lam = 0; \ |
| 79 | c = 1; \ | 79 | c = 1; USED(c); \ |
| 80 | s = 0; \ | 80 | s = 0; USED(s); \ |
| 81 | } | 81 | } |
| 82 | #define TRIG_NEXT(k,c,s) \ | 82 | #define TRIG_NEXT(k,c,s) \ |
| 83 | { \ | 83 | { \ |
Empty file added.
Empty file added.
| @@ -0,0 +1,73 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | |||
| 3 | int | ||
| 4 | isinf(double d) | ||
| 5 | { | ||
| 6 | if(isInf(d, 0) == 0) | ||
| 7 | return 0; | ||
| 8 | |||
| 9 | return isInf(d, -1) ? -1 : 1; | ||
| 10 | } | ||
| 11 | |||
| 12 | int | ||
| 13 | lrintf(float f) | ||
| 14 | { | ||
| 15 | int i; | ||
| 16 | |||
| 17 | *((float*)&i) = f + 12582912.0f; | ||
| 18 | |||
| 19 | return (i & 0x7fffff) - 0x400000; | ||
| 20 | } | ||
| 21 | |||
| 22 | #define ln2o1 1.4426950408889634073599 | ||
| 23 | #define hugeF 3.4028234e+38 | ||
| 24 | #define hugeD 1.79769313486231e+308 | ||
| 25 | |||
| 26 | double | ||
| 27 | log2(double x) | ||
| 28 | { | ||
| 29 | if(x == 0) | ||
| 30 | return -hugeD; | ||
| 31 | if(x < 0 || isNaN(x)) | ||
| 32 | return NaN(); | ||
| 33 | |||
| 34 | return log(x)*ln2o1; | ||
| 35 | } | ||
| 36 | |||
| 37 | float | ||
| 38 | log2f(float x) | ||
| 39 | { | ||
| 40 | if(x == 0) | ||
| 41 | return -hugeF; | ||
| 42 | |||
| 43 | return log2(x); | ||
| 44 | } | ||
| 45 | |||
| 46 | /* taken from musl */ | ||
| 47 | #define dbleps 2.2204460492503131e-16 | ||
| 48 | static double toint = 1.0/dbleps; | ||
| 49 | double | ||
| 50 | round(double x) | ||
| 51 | { | ||
| 52 | union {double f; u64int i;} u = {x}; | ||
| 53 | int e = u.i >> 52 & 0x7ff; | ||
| 54 | double y; | ||
| 55 | |||
| 56 | if(e >= 0x3ff+52) | ||
| 57 | return x; | ||
| 58 | if(u.i >> 63) | ||
| 59 | x = -x; | ||
| 60 | if(e < 0x3ff-1) | ||
| 61 | return 0*u.f; | ||
| 62 | y = x + toint - toint - x; | ||
| 63 | if(y > 0.5) | ||
| 64 | y = y + x - 1; | ||
| 65 | else if(y <= -0.5) | ||
| 66 | y = y + x + 1; | ||
| 67 | else | ||
| 68 | y = y + x; | ||
| 69 | if(u.i >> 63) | ||
| 70 | y = -y; | ||
| 71 | |||
| 72 | return y; | ||
| 73 | } | ||
Empty file added.
Empty file added.
| @@ -0,0 +1,55 @@ | |||
| 1 | #ifndef _plan9_stdio_h_ | ||
| 2 | #define _plan9_stdio_h_ | ||
| 3 | |||
| 4 | #include <u.h> | ||
| 5 | #include <libc.h> | ||
| 6 | #include </sys/include/stdio.h> | ||
| 7 | |||
| 8 | #define cosf cos | ||
| 9 | #define sinf sin | ||
| 10 | #define expf exp | ||
| 11 | #define logf log | ||
| 12 | #define powf pow | ||
| 13 | #define tanf tan | ||
| 14 | #define fmodf fmod | ||
| 15 | #define sqrtf sqrt | ||
| 16 | #define isnan isNaN | ||
| 17 | #define acosf acos | ||
| 18 | #define atanf atan | ||
| 19 | #define atan2f atan2 | ||
| 20 | #define tanhf tanh | ||
| 21 | #define fabsf fabs | ||
| 22 | #define roundf round | ||
| 23 | #define frexpf frexp | ||
| 24 | #define log10f log10 | ||
| 25 | |||
| 26 | #define fmax(a,b) ((a)>(b)?(a):(b)) | ||
| 27 | #define fmin(a,b) ((a)<(b)?(a):(b)) | ||
| 28 | #define fmaxf fmax | ||
| 29 | #define fminf fmin | ||
| 30 | |||
| 31 | #define isfinite(x) (!isinf(x)) | ||
| 32 | |||
| 33 | typedef usize size_t; | ||
| 34 | typedef u8int uint8_t; | ||
| 35 | typedef s8int int8_t; | ||
| 36 | typedef u16int uint16_t; | ||
| 37 | typedef s16int int16_t; | ||
| 38 | typedef u32int uint32_t; | ||
| 39 | typedef s32int int32_t; | ||
| 40 | typedef u64int uint64_t; | ||
| 41 | typedef uintptr uintptr_t; | ||
| 42 | |||
| 43 | #define CHAR_BIT 8 | ||
| 44 | #define INT_MAX 0x7fffffff | ||
| 45 | #define INT_MIN (-INT_MAX-1) | ||
| 46 | #define UINT_MAX 0xffffffffU | ||
| 47 | #define UINT16_MAX 0xffff | ||
| 48 | |||
| 49 | int isinf(double d); | ||
| 50 | int lrintf(float f); | ||
| 51 | double log2(double x); | ||
| 52 | float log2f(float x); | ||
| 53 | double round(double x); | ||
| 54 | |||
| 55 | #endif | ||
Empty file added.
Empty file added.
| @@ -36,7 +36,9 @@ extern "C" { · 35 unmodified lines | |||
| 36 | #define SQRT8 2.82842712475f | 36 | #define SQRT8 2.82842712475f |
| 37 | #define LEAF_SQRT2 1.41421356237f | 37 | #define LEAF_SQRT2 1.41421356237f |
| 38 | #define WSCALE 1.30612244898f | 38 | #define WSCALE 1.30612244898f |
| 39 | #ifndef PI | ||
| 39 | #define PI (3.14159265358979f) | 40 | #define PI (3.14159265358979f) |
| 41 | #endif | ||
| 40 | #define TWO_PI (6.28318530717958f) | 42 | #define TWO_PI (6.28318530717958f) |
| 41 | #define HALF_PI (1.570796326794897f) | 43 | #define HALF_PI (1.570796326794897f) |
| 42 | 44 | ||
| @@ -124,7 +124,7 @@ float tZeroCrossingCounter_tick (tZeroCrossingCounter* const zc, float · 123 unmodified lines | |||
| 124 | 124 | ||
| 125 | z->inBuffer[z->position] = input; | 125 | z->inBuffer[z->position] = input; |
| 126 | int futurePosition = ((z->position + 1) % z->currentWindowSize); | 126 | int futurePosition = ((z->position + 1) % z->currentWindowSize); |
| 127 | float output = 0.0f; | 127 | float output; |
| 128 | 128 | ||
| 129 | //add new value to count | 129 | //add new value to count |
| 130 | if ((z->inBuffer[z->position] * z->inBuffer[z->prevPosition]) < 0.0f) | 130 | if ((z->inBuffer[z->position] * z->inBuffer[z->prevPosition]) < 0.0f) |
| @@ -438,7 +438,7 @@ static void atkdtk_envelope(tAttackDetection* const ad, float *in) · 307 unmodified lines | |||
| 438 | { | 438 | { |
| 439 | _tAttackDetection* a = *ad; | 439 | _tAttackDetection* a = *ad; |
| 440 | 440 | ||
| 441 | int i = 0; | 441 | int i; |
| 442 | float tmp; | 442 | float tmp; |
| 443 | for(i = 0; i < a->blockSize; ++i){ | 443 | for(i = 0; i < a->blockSize; ++i){ |
| 444 | tmp = fastabsf(in[i]); | 444 | tmp = fastabsf(in[i]); |
| @@ -1124,7 +1124,7 @@ int tZeroCrossingCollector_getState(tZeroCrossingCollector* const zc) · 679 unmodified lines | |||
| 1124 | return z->_state; | 1124 | return z->_state; |
| 1125 | } | 1125 | } |
| 1126 | 1126 | ||
| 1127 | tZeroCrossingInfo const tZeroCrossingCollector_getCrossing(tZeroCrossingCollector* const zc, int index) | 1127 | tZeroCrossingInfo tZeroCrossingCollector_getCrossing(tZeroCrossingCollector* const zc, int index) |
| 1128 | { | 1128 | { |
| 1129 | _tZeroCrossingCollector* z = *zc; | 1129 | _tZeroCrossingCollector* z = *zc; |
| 1130 | 1130 | ||
| @@ -1487,7 +1487,7 @@ int tBACF_getCorrelation (tBACF* const bacf, int pos) · 356 unmodified lines | |||
| 1487 | #elif _MSC_VER | 1487 | #elif _MSC_VER |
| 1488 | count += __popcnt(*p1++ ^ v++); | 1488 | count += __popcnt(*p1++ ^ v++); |
| 1489 | #else | 1489 | #else |
| 1490 | count += popcount(*p1++ ^ v++); | 1490 | count += popcount(*p1++ ^ v++); USED(count); USED(v); |
| 1491 | #endif | 1491 | #endif |
| 1492 | } | 1492 | } |
| 1493 | } | 1493 | } |
| @@ -1675,7 +1675,7 @@ void tPeriodDetector_setHysteresis (tPeriodDetector* const detector, float · 181 unmodified lines | |||
| 1675 | { | 1675 | { |
| 1676 | _tPeriodDetector* p = *detector; | 1676 | _tPeriodDetector* p = *detector; |
| 1677 | 1677 | ||
| 1678 | return tZeroCrossingCollector_setHysteresis(&p->_zc, hysteresis); | 1678 | tZeroCrossingCollector_setHysteresis(&p->_zc, hysteresis); |
| 1679 | } | 1679 | } |
| 1680 | 1680 | ||
| 1681 | void tPeriodDetector_setSampleRate (tPeriodDetector* const detector, float sr) | 1681 | void tPeriodDetector_setSampleRate (tPeriodDetector* const detector, float sr) |
| @@ -2196,7 +2196,7 @@ int tDualPitchDetector_tick (tDualPitchDetector* const detector, float sa · 514 unmodified lines | |||
| 2196 | if (ready) | 2196 | if (ready) |
| 2197 | { | 2197 | { |
| 2198 | int pd2_indeterminate = tPitchDetector_indeterminate(&p->_pd2); | 2198 | int pd2_indeterminate = tPitchDetector_indeterminate(&p->_pd2); |
| 2199 | int disagreement = 0; | 2199 | int disagreement; |
| 2200 | float period = tPeriodDetection_getPeriod(&p->_pd1); | 2200 | float period = tPeriodDetection_getPeriod(&p->_pd1); |
| 2201 | if (!pd2_indeterminate && period != 0.0f) | 2201 | if (!pd2_indeterminate && period != 0.0f) |
| 2202 | { | 2202 | { |
| @@ -513,7 +513,7 @@ float tLockhartWavefolder_tick(tLockhartWavefolder* const wf, float in) · 512 unmodified lines | |||
| 513 | { | 513 | { |
| 514 | _tLockhartWavefolder* w = *wf; | 514 | _tLockhartWavefolder* w = *wf; |
| 515 | 515 | ||
| 516 | float out = 0.0f; | 516 | float out; |
| 517 | 517 | ||
| 518 | // Compute Antiderivative | 518 | // Compute Antiderivative |
| 519 | w->l = (in > 0.0) - (in < 0.0); | 519 | w->l = (in > 0.0) - (in < 0.0); |
| @@ -86,7 +86,7 @@ float tCompressor_tick(tCompressor* const comp, float in) · 85 unmodified lines | |||
| 86 | float slope, overshoot; | 86 | float slope, overshoot; |
| 87 | 87 | ||
| 88 | float in_db = LEAF_clip(-90.0f, fasteratodb(fastabsf(in)), 0.0f); | 88 | float in_db = LEAF_clip(-90.0f, fasteratodb(fastabsf(in)), 0.0f); |
| 89 | float out_db = 0.0f; | 89 | float out_db; |
| 90 | 90 | ||
| 91 | c->y_T[1] = c->y_T[0]; | 91 | c->y_T[1] = c->y_T[0]; |
| 92 | 92 | ||
| @@ -149,7 +149,6 @@ void tTalkbox_warpedAutocorrelate(float * x, double* dl, double* Rt, unsigned in · 148 unmodified lines | |||
| 149 | Rt[0]=0; | 149 | Rt[0]=0; |
| 150 | r1=0; | 150 | r1=0; |
| 151 | r2=0; | 151 | r2=0; |
| 152 | r1t=0; | ||
| 153 | for(uint32_t m=0; m<L;m++) | 152 | for(uint32_t m=0; m<L;m++) |
| 154 | { | 153 | { |
| 155 | Rt[0] += (double)(x[m]) * (double)(x[m]); | 154 | Rt[0] += (double)(x[m]) * (double)(x[m]); |
| @@ -243,7 +242,7 @@ float tTalkbox_tick(tTalkbox* const voc, float synth, float voice) · 87 unmodified lines | |||
| 243 | if(++p0 >= v->N) { tTalkbox_lpc(v->buf0, v->car0, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); p0 = 0; } | 242 | if(++p0 >= v->N) { tTalkbox_lpc(v->buf0, v->car0, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); p0 = 0; } |
| 244 | 243 | ||
| 245 | w = 1.0f - w; fx += v->buf1[p1] * w; v->buf1[p1] = x * w; | 244 | w = 1.0f - w; fx += v->buf1[p1] * w; v->buf1[p1] = x * w; |
| 246 | if(++p1 >= v->N) { tTalkbox_lpc(v->buf1, v->car1, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); p1 = 0; } | 245 | if(++p1 >= v->N) { tTalkbox_lpc(v->buf1, v->car1, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); } |
| 247 | } | 246 | } |
| 248 | 247 | ||
| 249 | p = v->u0 + h0 * fx; v->u0 = v->u1; v->u1 = fx - h0 * p; | 248 | p = v->u0 + h0 * fx; v->u0 = v->u1; v->u1 = fx - h0 * p; |
| @@ -487,7 +486,6 @@ void tTalkboxFloat_warpedAutocorrelate(float * x, float* dl, float* Rt, unsigned · 237 unmodified lines | |||
| 487 | Rt[0]=0; | 486 | Rt[0]=0; |
| 488 | r1=0; | 487 | r1=0; |
| 489 | r2=0; | 488 | r2=0; |
| 490 | r1t=0; | ||
| 491 | for(uint32_t m=0; m<L;m++) | 489 | for(uint32_t m=0; m<L;m++) |
| 492 | { | 490 | { |
| 493 | Rt[0] += (x[m]) * (x[m]); | 491 | Rt[0] += (x[m]) * (x[m]); |
| @@ -582,7 +580,7 @@ float tTalkboxFloat_tick(tTalkboxFloat* const voc, float synth, float voice) · 88 unmodified lines | |||
| 582 | if(++p0 >= v->N) { tTalkboxFloat_lpc(v->buf0, v->car0, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); p0 = 0; } | 580 | if(++p0 >= v->N) { tTalkboxFloat_lpc(v->buf0, v->car0, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); p0 = 0; } |
| 583 | 581 | ||
| 584 | w = 1.0f - w; fx += v->buf1[p1] * w; v->buf1[p1] = x * w; | 582 | w = 1.0f - w; fx += v->buf1[p1] * w; v->buf1[p1] = x * w; |
| 585 | if(++p1 >= v->N) { tTalkboxFloat_lpc(v->buf1, v->car1, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); p1 = 0; } | 583 | if(++p1 >= v->N) { tTalkboxFloat_lpc(v->buf1, v->car1, v->dl, v->Rt, v->N, v->O, v->warpFactor, v->warpOn, v->k, v->freeze, &v->G); } |
| 586 | } | 584 | } |
| 587 | 585 | ||
| 588 | p = v->u0 + h0 * fx; v->u0 = v->u1; v->u1 = fx - h0 * p; | 586 | p = v->u0 + h0 * fx; v->u0 = v->u1; v->u1 = fx - h0 * p; |
| @@ -826,7 +824,7 @@ float tVocoder_tick (tVocoder* const voc, float synth, float voice) · 237 unmodified lines | |||
| 826 | { | 824 | { |
| 827 | _tVocoder* v = *voc; | 825 | _tVocoder* v = *voc; |
| 828 | 826 | ||
| 829 | float a, b, o=0.0f, aa, bb, oo = v->kout, g = v->gain, ht = v->thru, hh = v->high, tmp; | 827 | float a, b, o, aa, bb, oo = v->kout, g = v->gain, ht = v->thru, hh = v->high, tmp; |
| 830 | uint32_t i, k = v->kval, nb = v->nbnd; | 828 | uint32_t i, k = v->kval, nb = v->nbnd; |
| 831 | 829 | ||
| 832 | a = voice; //speech | 830 | a = voice; //speech |
| @@ -940,7 +938,7 @@ float tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse* const gp) · 107 unmodified lines | |||
| 940 | { | 938 | { |
| 941 | _tRosenbergGlottalPulse* g = *gp; | 939 | _tRosenbergGlottalPulse* g = *gp; |
| 942 | 940 | ||
| 943 | float output = 0.0f; | 941 | float output; |
| 944 | 942 | ||
| 945 | // Phasor increment | 943 | // Phasor increment |
| 946 | g->phase += g->inc; | 944 | g->phase += g->inc; |
| @@ -969,7 +967,7 @@ float tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse* const g · 22 unmodified lines | |||
| 969 | { | 967 | { |
| 970 | _tRosenbergGlottalPulse* g = *gp; | 968 | _tRosenbergGlottalPulse* g = *gp; |
| 971 | 969 | ||
| 972 | float output = 0.0f; | 970 | float output; |
| 973 | 971 | ||
| 974 | // Phasor increment | 972 | // Phasor increment |
| 975 | g->phase += g->inc; | 973 | g->phase += g->inc; |
| @@ -1518,7 +1516,7 @@ void tSimpleRetune_initToPool (tSimpleRetune* const rt, int numVoices, float min · 542 unmodified lines | |||
| 1518 | tPitchShift_initToPool(&r->ps[i], &r->dp, r->bufSize, mp); | 1516 | tPitchShift_initToPool(&r->ps[i], &r->dp, r->bufSize, mp); |
| 1519 | } | 1517 | } |
| 1520 | 1518 | ||
| 1521 | r->shiftFunction = &tPitchShift_shiftBy; | 1519 | r->shiftFunction = tPitchShift_shiftBy; |
| 1522 | } | 1520 | } |
| 1523 | 1521 | ||
| 1524 | void tSimpleRetune_free (tSimpleRetune* const rt) | 1522 | void tSimpleRetune_free (tSimpleRetune* const rt) |
| @@ -1564,8 +1562,8 @@ void tSimpleRetune_setMode (tSimpleRetune* const rt, int mode) · 39 unmodified lines | |||
| 1564 | { | 1562 | { |
| 1565 | _tSimpleRetune* r = *rt; | 1563 | _tSimpleRetune* r = *rt; |
| 1566 | 1564 | ||
| 1567 | if (mode > 0) r->shiftFunction = &tPitchShift_shiftTo; | 1565 | if (mode > 0) r->shiftFunction = tPitchShift_shiftTo; |
| 1568 | else r->shiftFunction = &tPitchShift_shiftBy; | 1566 | else r->shiftFunction = tPitchShift_shiftBy; |
| 1569 | } | 1567 | } |
| 1570 | 1568 | ||
| 1571 | void tSimpleRetune_setNumVoices(tSimpleRetune* const rt, int numVoices) | 1569 | void tSimpleRetune_setNumVoices(tSimpleRetune* const rt, int numVoices) |
| @@ -1663,7 +1661,7 @@ void tRetune_initToPool (tRetune* const rt, int numVoices, float minInputFreq, f · 91 unmodified lines | |||
| 1663 | r->outBuffers[i] = (float*) mpool_calloc(sizeof(float) * r->bufSize, m); | 1661 | r->outBuffers[i] = (float*) mpool_calloc(sizeof(float) * r->bufSize, m); |
| 1664 | } | 1662 | } |
| 1665 | 1663 | ||
| 1666 | r->shiftFunction = &tPitchShift_shiftBy; | 1664 | r->shiftFunction = tPitchShift_shiftBy; |
| 1667 | } | 1665 | } |
| 1668 | 1666 | ||
| 1669 | void tRetune_free (tRetune* const rt) | 1667 | void tRetune_free (tRetune* const rt) |
| @@ -1715,8 +1713,8 @@ void tRetune_setMode (tRetune* const rt, int mode) · 45 unmodified lines | |||
| 1715 | { | 1713 | { |
| 1716 | _tRetune* r = *rt; | 1714 | _tRetune* r = *rt; |
| 1717 | 1715 | ||
| 1718 | if (mode > 0) r->shiftFunction = &tPitchShift_shiftTo; | 1716 | if (mode > 0) r->shiftFunction = tPitchShift_shiftTo; |
| 1719 | else r->shiftFunction = &tPitchShift_shiftBy; | 1717 | else r->shiftFunction = tPitchShift_shiftBy; |
| 1720 | } | 1718 | } |
| 1721 | 1719 | ||
| 1722 | void tRetune_setPickiness (tRetune* const rt, float p) | 1720 | void tRetune_setPickiness (tRetune* const rt, float p) |
| @@ -71,45 +71,45 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, float value, tWDF* · 70 unmodified lines | |||
| 71 | r->port_resistance_up = r->value; | 71 | r->port_resistance_up = r->value; |
| 72 | r->port_conductance_up = 1.0f / r->value; | 72 | r->port_conductance_up = 1.0f / r->value; |
| 73 | 73 | ||
| 74 | r->get_port_resistance = &get_port_resistance_for_resistor; | 74 | r->get_port_resistance = get_port_resistance_for_resistor; |
| 75 | r->get_reflected_wave_up = &get_reflected_wave_for_resistor; | 75 | r->get_reflected_wave_up = get_reflected_wave_for_resistor; |
| 76 | r->set_incident_wave = &set_incident_wave_for_leaf; | 76 | r->set_incident_wave = set_incident_wave_for_leaf; |
| 77 | } | 77 | } |
| 78 | else if (r->type == Capacitor) | 78 | else if (r->type == Capacitor) |
| 79 | { | 79 | { |
| 80 | r->port_conductance_up = r->sample_rate * 2.0f * r->value; | 80 | r->port_conductance_up = r->sample_rate * 2.0f * r->value; |
| 81 | r->port_resistance_up = 1.0f / r->port_conductance_up; //based on trapezoidal discretization | 81 | r->port_resistance_up = 1.0f / r->port_conductance_up; //based on trapezoidal discretization |
| 82 | 82 | ||
| 83 | r->get_port_resistance = &get_port_resistance_for_capacitor; | 83 | r->get_port_resistance = get_port_resistance_for_capacitor; |
| 84 | r->get_reflected_wave_up = &get_reflected_wave_for_capacitor; | 84 | r->get_reflected_wave_up = get_reflected_wave_for_capacitor; |
| 85 | r->set_incident_wave = &set_incident_wave_for_leaf; | 85 | r->set_incident_wave = set_incident_wave_for_leaf; |
| 86 | } | 86 | } |
| 87 | else if (r->type == Inductor) | 87 | else if (r->type == Inductor) |
| 88 | { | 88 | { |
| 89 | r->port_resistance_up = r->sample_rate * 2.0f * r->value; //based on trapezoidal discretization | 89 | r->port_resistance_up = r->sample_rate * 2.0f * r->value; //based on trapezoidal discretization |
| 90 | r->port_conductance_up = 1.0f / r->port_resistance_up; | 90 | r->port_conductance_up = 1.0f / r->port_resistance_up; |
| 91 | 91 | ||
| 92 | r->get_port_resistance = &get_port_resistance_for_inductor; | 92 | r->get_port_resistance = get_port_resistance_for_inductor; |
| 93 | r->get_reflected_wave_up = &get_reflected_wave_for_capacitor; // same as capacitor | 93 | r->get_reflected_wave_up = get_reflected_wave_for_capacitor; // same as capacitor |
| 94 | r->set_incident_wave = &set_incident_wave_for_leaf_inverted; | 94 | r->set_incident_wave = set_incident_wave_for_leaf_inverted; |
| 95 | } | 95 | } |
| 96 | else if (r->type == ResistiveSource) | 96 | else if (r->type == ResistiveSource) |
| 97 | { | 97 | { |
| 98 | r->port_resistance_up = r->value; | 98 | r->port_resistance_up = r->value; |
| 99 | r->port_conductance_up = 1.0f / r->port_resistance_up; | 99 | r->port_conductance_up = 1.0f / r->port_resistance_up; |
| 100 | 100 | ||
| 101 | r->get_port_resistance = &get_port_resistance_for_resistive; | 101 | r->get_port_resistance = get_port_resistance_for_resistive; |
| 102 | r->get_reflected_wave_up = &get_reflected_wave_for_resistive; | 102 | r->get_reflected_wave_up = get_reflected_wave_for_resistive; |
| 103 | r->set_incident_wave = &set_incident_wave_for_leaf; | 103 | r->set_incident_wave = set_incident_wave_for_leaf; |
| 104 | } | 104 | } |
| 105 | else if (r->type == Inverter) | 105 | else if (r->type == Inverter) |
| 106 | { | 106 | { |
| 107 | r->port_resistance_up = tWDF_getPortResistance(r->child_left); | 107 | r->port_resistance_up = tWDF_getPortResistance(r->child_left); |
| 108 | r->port_conductance_up = 1.0f / r->port_resistance_up; | 108 | r->port_conductance_up = 1.0f / r->port_resistance_up; |
| 109 | 109 | ||
| 110 | r->get_port_resistance = &get_port_resistance_for_inverter; | 110 | r->get_port_resistance = get_port_resistance_for_inverter; |
| 111 | r->get_reflected_wave_up = &get_reflected_wave_for_inverter; | 111 | r->get_reflected_wave_up = get_reflected_wave_for_inverter; |
| 112 | r->set_incident_wave = &set_incident_wave_for_inverter; | 112 | r->set_incident_wave = set_incident_wave_for_inverter; |
| 113 | } | 113 | } |
| 114 | else if (r->type == SeriesAdaptor) | 114 | else if (r->type == SeriesAdaptor) |
| 115 | { | 115 | { |
| @@ -121,9 +121,9 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, float value, tWDF* · 5 unmodified lines | |||
| 121 | r->port_conductance_right = 1.0f / r->port_resistance_right; | 121 | r->port_conductance_right = 1.0f / r->port_resistance_right; |
| 122 | r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left); | 122 | r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left); |
| 123 | 123 | ||
| 124 | r->get_port_resistance = &get_port_resistance_for_series; | 124 | r->get_port_resistance = get_port_resistance_for_series; |
| 125 | r->get_reflected_wave_up = &get_reflected_wave_for_series; | 125 | r->get_reflected_wave_up = get_reflected_wave_for_series; |
| 126 | r->set_incident_wave = &set_incident_wave_for_series; | 126 | r->set_incident_wave = set_incident_wave_for_series; |
| 127 | } | 127 | } |
| 128 | else if (r->type == ParallelAdaptor) | 128 | else if (r->type == ParallelAdaptor) |
| 129 | { | 129 | { |
| @@ -135,33 +135,33 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, float value, tWDF* · 5 unmodified lines | |||
| 135 | r->port_conductance_right = 1.0f / r->port_resistance_right; | 135 | r->port_conductance_right = 1.0f / r->port_resistance_right; |
| 136 | r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left); | 136 | r->gamma_zero = 1.0f / (r->port_resistance_right + r->port_resistance_left); |
| 137 | 137 | ||
| 138 | r->get_port_resistance = &get_port_resistance_for_parallel; | 138 | r->get_port_resistance = get_port_resistance_for_parallel; |
| 139 | r->get_reflected_wave_up = &get_reflected_wave_for_parallel; | 139 | r->get_reflected_wave_up = get_reflected_wave_for_parallel; |
| 140 | r->set_incident_wave = &set_incident_wave_for_parallel; | 140 | r->set_incident_wave = set_incident_wave_for_parallel; |
| 141 | } | 141 | } |
| 142 | else if (r->type == IdealSource) | 142 | else if (r->type == IdealSource) |
| 143 | { | 143 | { |
| 144 | r->port_resistance_up = tWDF_getPortResistance(child); | 144 | r->port_resistance_up = tWDF_getPortResistance(child); |
| 145 | r->port_conductance_up = 1.0f / r->port_resistance_up; | 145 | r->port_conductance_up = 1.0f / r->port_resistance_up; |
| 146 | 146 | ||
| 147 | r->get_reflected_wave_down = &get_reflected_wave_for_ideal; | 147 | r->get_reflected_wave_down = get_reflected_wave_for_ideal; |
| 148 | r->get_port_resistance = &get_port_resistance_for_root; | 148 | r->get_port_resistance = get_port_resistance_for_root; |
| 149 | } | 149 | } |
| 150 | else if (r->type == Diode) | 150 | else if (r->type == Diode) |
| 151 | { | 151 | { |
| 152 | r->port_resistance_up = tWDF_getPortResistance(child); | 152 | r->port_resistance_up = tWDF_getPortResistance(child); |
| 153 | r->port_conductance_up = 1.0f / r->port_resistance_up; | 153 | r->port_conductance_up = 1.0f / r->port_resistance_up; |
| 154 | 154 | ||
| 155 | r->get_reflected_wave_down = &get_reflected_wave_for_diode; | 155 | r->get_reflected_wave_down = get_reflected_wave_for_diode; |
| 156 | r->get_port_resistance = &get_port_resistance_for_root; | 156 | r->get_port_resistance = get_port_resistance_for_root; |
| 157 | } | 157 | } |
| 158 | else if (r->type == DiodePair) | 158 | else if (r->type == DiodePair) |
| 159 | { | 159 | { |
| 160 | r->port_resistance_up = tWDF_getPortResistance(child); | 160 | r->port_resistance_up = tWDF_getPortResistance(child); |
| 161 | r->port_conductance_up = 1.0f / r->port_resistance_up; | 161 | r->port_conductance_up = 1.0f / r->port_resistance_up; |
| 162 | 162 | ||
| 163 | r->get_reflected_wave_down = &get_reflected_wave_for_diode_pair; | 163 | r->get_reflected_wave_down = get_reflected_wave_for_diode_pair; |
| 164 | r->get_port_resistance = &get_port_resistance_for_root; | 164 | r->get_port_resistance = get_port_resistance_for_root; |
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | //WDF | 167 | //WDF |
| @@ -381,12 +381,14 @@ static float get_port_resistance_for_root(tWDF* const wdf) · 213 unmodified lines | |||
| 381 | static void set_incident_wave_for_leaf(tWDF* const wdf, float incident_wave, float input) | 381 | static void set_incident_wave_for_leaf(tWDF* const wdf, float incident_wave, float input) |
| 382 | { | 382 | { |
| 383 | _tWDF* r = *wdf; | 383 | _tWDF* r = *wdf; |
| 384 | USED(input); | ||
| 384 | r->incident_wave_up = incident_wave; | 385 | r->incident_wave_up = incident_wave; |
| 385 | } | 386 | } |
| 386 | 387 | ||
| 387 | static void set_incident_wave_for_leaf_inverted(tWDF* const wdf, float incident_wave, float input) | 388 | static void set_incident_wave_for_leaf_inverted(tWDF* const wdf, float incident_wave, float input) |
| 388 | { | 389 | { |
| 389 | _tWDF* r = *wdf; | 390 | _tWDF* r = *wdf; |
| 391 | USED(input); | ||
| 390 | r->incident_wave_up = -1.0f * incident_wave; | 392 | r->incident_wave_up = -1.0f * incident_wave; |
| 391 | } | 393 | } |
| 392 | 394 | ||
| @@ -438,6 +440,7 @@ static float get_reflected_wave_for_resistor(tWDF* const wdf, float input) · 45 unmodified lines | |||
| 438 | { | 440 | { |
| 439 | _tWDF* r = *wdf; | 441 | _tWDF* r = *wdf; |
| 440 | r->reflected_wave_up = 0.0f; | 442 | r->reflected_wave_up = 0.0f; |
| 443 | USED(input); | ||
| 441 | return r->reflected_wave_up; | 444 | return r->reflected_wave_up; |
| 442 | } | 445 | } |
| 443 | 446 | ||
| @@ -445,6 +448,7 @@ static float get_reflected_wave_for_capacitor(tWDF* const wdf, float input) · 1 unmodified line | |||
| 445 | { | 448 | { |
| 446 | _tWDF* r = *wdf; | 449 | _tWDF* r = *wdf; |
| 447 | r->reflected_wave_up = r->incident_wave_up; | 450 | r->reflected_wave_up = r->incident_wave_up; |
| 451 | USED(input); | ||
| 448 | return r->reflected_wave_up; | 452 | return r->reflected_wave_up; |
| 449 | } | 453 | } |
| 450 | 454 | ||
| @@ -483,6 +487,7 @@ static float get_reflected_wave_for_parallel(tWDF* const wdf, float input) · 32 unmodified lines | |||
| 483 | 487 | ||
| 484 | static float get_reflected_wave_for_ideal(tWDF* const wdf, float input, float incident_wave) | 488 | static float get_reflected_wave_for_ideal(tWDF* const wdf, float input, float incident_wave) |
| 485 | { | 489 | { |
| 490 | USED(wdf); USED(input); | ||
| 486 | return (2.0f * input) - incident_wave; | 491 | return (2.0f * input) - incident_wave; |
| 487 | } | 492 | } |
| 488 | 493 | ||
| @@ -528,6 +533,7 @@ static float get_reflected_wave_for_diode(tWDF* const wdf, float input, float in · 39 unmodified lines | |||
| 528 | 533 | ||
| 529 | float a = incident_wave; | 534 | float a = incident_wave; |
| 530 | float r = n->port_resistance_up; | 535 | float r = n->port_resistance_up; |
| 536 | USED(input); | ||
| 531 | return a + 2.0f*r*Is_DIODE - 2.0f*VT_DIODE*lambertW(a, r, Is_DIODE, 1.0f/VT_DIODE); | 537 | return a + 2.0f*r*Is_DIODE - 2.0f*VT_DIODE*lambertW(a, r, Is_DIODE, 1.0f/VT_DIODE); |
| 532 | } | 538 | } |
| 533 | 539 | ||
| @@ -537,6 +543,7 @@ static float get_reflected_wave_for_diode_pair(tWDF* const wdf, float input, flo · 3 unmodified lines | |||
| 537 | 543 | ||
| 538 | float a = incident_wave; | 544 | float a = incident_wave; |
| 539 | float sgn = 0.0f; | 545 | float sgn = 0.0f; |
| 546 | USED(input); | ||
| 540 | if (a > 0.0f) sgn = 1.0f; | 547 | if (a > 0.0f) sgn = 1.0f; |
| 541 | else if (a < 0.0f) sgn = -1.0f; | 548 | else if (a < 0.0f) sgn = -1.0f; |
| 542 | float r = n->port_resistance_up; | 549 | float r = n->port_resistance_up; |
| @@ -84,7 +84,7 @@ float t808Cowbell_tick(t808Cowbell* const cowbellInst) · 83 unmodified lines | |||
| 84 | { | 84 | { |
| 85 | _t808Cowbell* cowbell = *cowbellInst; | 85 | _t808Cowbell* cowbell = *cowbellInst; |
| 86 | 86 | ||
| 87 | float sample = 0.0f; | 87 | float sample; |
| 88 | 88 | ||
| 89 | // Mix oscillators. | 89 | // Mix oscillators. |
| 90 | sample = (cowbell->oscMix * tSquare_tick(&cowbell->p[0])) + ((1.0f-cowbell->oscMix) * tSquare_tick(&cowbell->p[1])); | 90 | sample = (cowbell->oscMix * tSquare_tick(&cowbell->p[0])) + ((1.0f-cowbell->oscMix) * tSquare_tick(&cowbell->p[1])); |
| @@ -276,7 +276,7 @@ float LEAF_chebyshevT(float in, int n){ · 275 unmodified lines | |||
| 276 | else return 2.0f * in * LEAF_chebyshevT(in, n-1) - LEAF_chebyshevT(in, n-2); | 276 | else return 2.0f * in * LEAF_chebyshevT(in, n-1) - LEAF_chebyshevT(in, n-2); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | #if !(_WIN32 || _WIN64) | 279 | #if !(_WIN32 || _WIN64 || __plan9__) |
| 280 | float LEAF_CompoundChebyshevT(float in, int n, float* amps){ | 280 | float LEAF_CompoundChebyshevT(float in, int n, float* amps){ |
| 281 | float T[n+1]; | 281 | float T[n+1]; |
| 282 | T[0] = 1.0f; | 282 | T[0] = 1.0f; |
| @@ -486,7 +486,7 @@ void LEAF_generate_sine(float* buffer, int size) · 203 unmodified lines | |||
| 486 | void LEAF_generate_sawtooth(float* buffer, float basefreq, int size, LEAF* const leaf) | 486 | void LEAF_generate_sawtooth(float* buffer, float basefreq, int size, LEAF* const leaf) |
| 487 | { | 487 | { |
| 488 | int harmonic = 1; | 488 | int harmonic = 1; |
| 489 | float phase = 0.0f; | 489 | float phase; |
| 490 | float freq = harmonic * basefreq; | 490 | float freq = harmonic * basefreq; |
| 491 | float amp; | 491 | float amp; |
| 492 | 492 | ||
| @@ -508,12 +508,12 @@ void LEAF_generate_sawtooth(float* buffer, float basefreq, int size, LEAF* const · 15 unmodified lines | |||
| 508 | void LEAF_generate_triangle(float* buffer, float basefreq, int size, LEAF* const leaf) | 508 | void LEAF_generate_triangle(float* buffer, float basefreq, int size, LEAF* const leaf) |
| 509 | { | 509 | { |
| 510 | int harmonic = 1; | 510 | int harmonic = 1; |
| 511 | float phase = 0.0f; | 511 | float phase; |
| 512 | float freq = harmonic * basefreq; | 512 | float freq = harmonic * basefreq; |
| 513 | float amp = 1.0f; | 513 | float amp; |
| 514 | 514 | ||
| 515 | int count = 0; | 515 | int count = 0; |
| 516 | float mult = 1.0f; | 516 | float mult; |
| 517 | 517 | ||
| 518 | while (freq < (leaf->sampleRate * 0.5)) | 518 | while (freq < (leaf->sampleRate * 0.5)) |
| 519 | { | 519 | { |
| @@ -537,9 +537,9 @@ void LEAF_generate_triangle(float* buffer, float basefreq, int size, LEAF* const · 17 unmodified lines | |||
| 537 | void LEAF_generate_square(float* buffer, float basefreq, int size, LEAF* const leaf) | 537 | void LEAF_generate_square(float* buffer, float basefreq, int size, LEAF* const leaf) |
| 538 | { | 538 | { |
| 539 | int harmonic = 1; | 539 | int harmonic = 1; |
| 540 | float phase = 0.0f; | 540 | float phase; |
| 541 | float freq = harmonic * basefreq; | 541 | float freq = harmonic * basefreq; |
| 542 | float amp = 1.0f; | 542 | float amp; |
| 543 | 543 | ||
| 544 | while (freq < (leaf->sampleRate * 0.5)) | 544 | while (freq < (leaf->sampleRate * 0.5)) |
| 545 | { | 545 | { |
| @@ -577,7 +577,7 @@ void LEAF_generate_table_skew_non_sym_double(float* buffer, float start, float e · 31 unmodified lines | |||
| 577 | double skew = log (0.5) / log ((center - start) / (end - start)); | 577 | double skew = log (0.5) / log ((center - start) / (end - start)); |
| 578 | double increment = 1.0 / (double)(size-1); | 578 | double increment = 1.0 / (double)(size-1); |
| 579 | double x = 0.0; | 579 | double x = 0.0; |
| 580 | double proportion = 0.0; | 580 | double proportion; |
| 581 | for (int i = 0; i < size; i++) | 581 | for (int i = 0; i < size; i++) |
| 582 | { | 582 | { |
| 583 | proportion = exp (log(x) / skew); | 583 | proportion = exp (log(x) / skew); |
| @@ -592,7 +592,7 @@ void LEAF_generate_table_skew_non_sym(float* buffer, float start, float end, flo · 8 unmodified lines | |||
| 592 | float skew = logf (0.5) / logf ((center - start) / (end - start)); | 592 | float skew = logf (0.5) / logf ((center - start) / (end - start)); |
| 593 | float increment = 1.0 / (float)(size-1); | 593 | float increment = 1.0 / (float)(size-1); |
| 594 | float x = 0.0; | 594 | float x = 0.0; |
| 595 | float proportion = 0.0; | 595 | float proportion; |
| 596 | for (int i = 0; i < size; i++) | 596 | for (int i = 0; i < size; i++) |
| 597 | { | 597 | { |
| 598 | proportion = expf (logf(x) / skew); | 598 | proportion = expf (logf(x) / skew); |
| @@ -327,15 +327,15 @@ void mpool_free(char* ptr, _tMempool* pool) · 326 unmodified lines | |||
| 327 | mpool_node_t* next_node; | 327 | mpool_node_t* next_node; |
| 328 | while (other_node != NULL) | 328 | while (other_node != NULL) |
| 329 | { | 329 | { |
| 330 | if ((long) other_node < (long) pool->mpool || | 330 | if ((uintptr_t) other_node < (uintptr_t) pool->mpool || |
| 331 | (long) other_node >= (((long) pool->mpool) + pool->msize)) | 331 | (uintptr_t) other_node >= (((uintptr_t) pool->mpool) + pool->msize)) |
| 332 | { | 332 | { |
| 333 | LEAF_internalErrorCallback(pool->leaf, LEAFInvalidFree); | 333 | LEAF_internalErrorCallback(pool->leaf, LEAFInvalidFree); |
| 334 | return; | 334 | return; |
| 335 | } | 335 | } |
| 336 | next_node = other_node->next; | 336 | next_node = other_node->next; |
| 337 | // Check if a node is directly after the freed node | 337 | // Check if a node is directly after the freed node |
| 338 | if (((long) freed_node) + (pool->leaf->header_size + freed_node->size) == (long) other_node) | 338 | if (((uintptr_t) freed_node) + (pool->leaf->header_size + freed_node->size) == (uintptr_t) other_node) |
| 339 | { | 339 | { |
| 340 | // Increase freed node's size | 340 | // Increase freed node's size |
| 341 | freed_node->size += pool->leaf->header_size + other_node->size; | 341 | freed_node->size += pool->leaf->header_size + other_node->size; |
| @@ -346,7 +346,7 @@ void mpool_free(char* ptr, _tMempool* pool) · 4 unmodified lines | |||
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | // Check if a node is directly before the freed node | 348 | // Check if a node is directly before the freed node |
| 349 | else if (((long) other_node) + (pool->leaf->header_size + other_node->size) == (long) freed_node) | 349 | else if (((uintptr_t) other_node) + (pool->leaf->header_size + other_node->size) == (uintptr_t) freed_node) |
| 350 | { | 350 | { |
| 351 | // Increase the merging node's size | 351 | // Increase the merging node's size |
| 352 | other_node->size += pool->leaf->header_size + freed_node->size; | 352 | other_node->size += pool->leaf->header_size + freed_node->size; |
| @@ -163,7 +163,6 @@ int tStack_remove(tStack* const stack, uint16_t noteVal) · 162 unmodified lines | |||
| 163 | 163 | ||
| 164 | } | 164 | } |
| 165 | // in case it got put on the stack multiple times | 165 | // in case it got put on the stack multiple times |
| 166 | foundIndex--; | ||
| 167 | ns->size--; | 166 | ns->size--; |
| 168 | removed = 1; | 167 | removed = 1; |
| 169 | } | 168 | } |
| @@ -222,7 +221,7 @@ int tStack_next(tStack* const stack) · 52 unmodified lines | |||
| 222 | { | 221 | { |
| 223 | _tStack* ns = *stack; | 222 | _tStack* ns = *stack; |
| 224 | 223 | ||
| 225 | int step = 0; | 224 | int step; |
| 226 | if (ns->size != 0) // if there is at least one note in the stack | 225 | if (ns->size != 0) // if there is at least one note in the stack |
| 227 | { | 226 | { |
| 228 | if (ns->pos > 0) // if you're not at the most recent note (first one), then go backward in the array (moving from earliest to latest) | 227 | if (ns->pos > 0) // if you're not at the most recent note (first one), then go backward in the array (moving from earliest to latest) |
| @@ -748,7 +747,7 @@ int tSimplePoly_noteOn(tSimplePoly* const polyh, int note, uint8_t vel) · 519 unmodified lines | |||
| 748 | int tSimplePoly_noteOff(tSimplePoly* const polyh, uint8_t note) | 747 | int tSimplePoly_noteOff(tSimplePoly* const polyh, uint8_t note) |
| 749 | { | 748 | { |
| 750 | _tSimplePoly* poly = *polyh; | 749 | _tSimplePoly* poly = *polyh; |
| 751 | int16_t noteToTest = -1; | 750 | int16_t noteToTest; |
| 752 | 751 | ||
| 753 | tStack_remove(&poly->stack, note); | 752 | tStack_remove(&poly->stack, note); |
| 754 | poly->notes[note][0] = -1; | 753 | poly->notes[note][0] = -1; |
| @@ -833,7 +833,7 @@ float tNeuron_tick(tNeuron* const nr) · 832 unmodified lines | |||
| 833 | { | 833 | { |
| 834 | _tNeuron* n = *nr; | 834 | _tNeuron* n = *nr; |
| 835 | 835 | ||
| 836 | float output = 0.0f; | 836 | float output; |
| 837 | float voltage = n->voltage; | 837 | float voltage = n->voltage; |
| 838 | 838 | ||
| 839 | n->alpha[0] = (0.01f * (10.0f - voltage)) / (expf((10.0f - voltage)/10.0f) - 1.0f); | 839 | n->alpha[0] = (0.01f * (10.0f - voltage)) / (expf((10.0f - voltage)/10.0f) - 1.0f); |
| @@ -978,6 +978,7 @@ void tMBPulse_place_step_dd_noBuffer(tMBPulse* const osc, int index, float phase · 138 unmodified lines | |||
| 978 | float r; | 978 | float r; |
| 979 | long i; | 979 | long i; |
| 980 | 980 | ||
| 981 | USED(index); | ||
| 981 | r = MINBLEP_PHASES * phase * inv_w; | 982 | r = MINBLEP_PHASES * phase * inv_w; |
| 982 | i = lrintf(r - 0.5f); | 983 | i = lrintf(r - 0.5f); |
| 983 | r -= (float)i; | 984 | r -= (float)i; |
| @@ -1323,6 +1324,7 @@ void tMBTriangle_place_dd_noBuffer(tMBTriangle* const osc, int index, float phas · 339 unmodified lines | |||
| 1323 | float r; | 1324 | float r; |
| 1324 | long i; | 1325 | long i; |
| 1325 | 1326 | ||
| 1327 | USED(index); | ||
| 1326 | r = MINBLEP_PHASES * phase * inv_w; | 1328 | r = MINBLEP_PHASES * phase * inv_w; |
| 1327 | i = lrintf(r - 0.5f); | 1329 | i = lrintf(r - 0.5f); |
| 1328 | r -= (float)i; | 1330 | r -= (float)i; |
| @@ -1343,7 +1345,7 @@ float tMBTriangle_tick(tMBTriangle* const osc) · 14 unmodified lines | |||
| 1343 | int j, k; | 1345 | int j, k; |
| 1344 | float sync; | 1346 | float sync; |
| 1345 | float b, b1, invB, invB1, p, w, sw, z; | 1347 | float b, b1, invB, invB1, p, w, sw, z; |
| 1346 | float x = 0.5f; | 1348 | float x; |
| 1347 | 1349 | ||
| 1348 | sync = c->sync; | 1350 | sync = c->sync; |
| 1349 | 1351 | ||
| @@ -1692,6 +1694,7 @@ void tMBSineTri_place_dd_noBuffer(tMBSineTri* const osc, int index, float phase, · 342 unmodified lines | |||
| 1692 | float r; | 1694 | float r; |
| 1693 | long i; | 1695 | long i; |
| 1694 | 1696 | ||
| 1697 | USED(index); | ||
| 1695 | r = MINBLEP_PHASES * phase * inv_w; | 1698 | r = MINBLEP_PHASES * phase * inv_w; |
| 1696 | i = lrintf(r - 0.5f); | 1699 | i = lrintf(r - 0.5f); |
| 1697 | r -= (float)i; | 1700 | r -= (float)i; |
| @@ -1712,7 +1715,7 @@ float tMBSineTri_tick(tMBSineTri* const osc) · 14 unmodified lines | |||
| 1712 | int j, k; | 1715 | int j, k; |
| 1713 | float sync; | 1716 | float sync; |
| 1714 | float b, b1, invB, invB1, p, sinPhase, w, sw, z; | 1717 | float b, b1, invB, invB1, p, sinPhase, w, sw, z; |
| 1715 | float x = 0.5f; | 1718 | float x; |
| 1716 | 1719 | ||
| 1717 | sync = c->sync; | 1720 | sync = c->sync; |
| 1718 | 1721 | ||
| @@ -2099,6 +2102,7 @@ void tMBSaw_place_step_dd_noBuffer(tMBSaw* const osc, int index, float phase, fl · 380 unmodified lines | |||
| 2099 | float r; | 2102 | float r; |
| 2100 | long i; | 2103 | long i; |
| 2101 | 2104 | ||
| 2105 | USED(index); | ||
| 2102 | r = MINBLEP_PHASES * phase * inv_w; | 2106 | r = MINBLEP_PHASES * phase * inv_w; |
| 2103 | i = lrintf(r - 0.5f); | 2107 | i = lrintf(r - 0.5f); |
| 2104 | r -= (float)i; | 2108 | r -= (float)i; |
| @@ -2322,6 +2326,7 @@ void tMBSawPulse_place_step_dd_noBuffer(tMBSawPulse* const osc, int index, float · 217 unmodified lines | |||
| 2322 | float r; | 2326 | float r; |
| 2323 | long i; | 2327 | long i; |
| 2324 | 2328 | ||
| 2329 | USED(index); | ||
| 2325 | r = MINBLEP_PHASES * phase * inv_w; | 2330 | r = MINBLEP_PHASES * phase * inv_w; |
| 2326 | i = lrintf(r - 0.5f); | 2331 | i = lrintf(r - 0.5f); |
| 2327 | r -= (float)i; | 2332 | r -= (float)i; |
| @@ -2913,7 +2918,7 @@ float tWaveOsc_tick(tWaveOsc* const cy) · 585 unmodified lines | |||
| 2913 | // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with float) | 2918 | // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with float) |
| 2914 | c->phase += c->inc; | 2919 | c->phase += c->inc; |
| 2915 | float floatPhase = (double)c->phase * 2.32830643654e-10; | 2920 | float floatPhase = (double)c->phase * 2.32830643654e-10; |
| 2916 | float s1 = 0.f, s2 = 0.f; | 2921 | float s1, s2; |
| 2917 | 2922 | ||
| 2918 | float temp; | 2923 | float temp; |
| 2919 | int idx; | 2924 | int idx; |
| @@ -3299,7 +3304,7 @@ float tWaveOscS_tick(tWaveOscS* const cy) · 379 unmodified lines | |||
| 3299 | // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with float) | 3304 | // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with float) |
| 3300 | c->phase += c->inc; | 3305 | c->phase += c->inc; |
| 3301 | float floatPhase = (double)c->phase * 2.32830643654e-10; | 3306 | float floatPhase = (double)c->phase * 2.32830643654e-10; |
| 3302 | float s1 = 0.f, s2 = 0.f; | 3307 | float s1, s2; |
| 3303 | 3308 | ||
| 3304 | float temp; | 3309 | float temp; |
| 3305 | int idx; | 3310 | int idx; |
| @@ -31,7 +31,7 @@ void tPluck_initToPool (tPluck* const pl, float lowestFrequency, tMempool* · 30 unmodified lines | |||
| 31 | 31 | ||
| 32 | p->sampleRate = leaf->sampleRate; | 32 | p->sampleRate = leaf->sampleRate; |
| 33 | 33 | ||
| 34 | if ( lowestFrequency <= 0.0f ) lowestFrequency = 10.0f; | 34 | if ( lowestFrequency <= 0.0f ) lowestFrequency = 10.0f; USED(lowestFrequency); |
| 35 | 35 | ||
| 36 | tNoise_initToPool(&p->noise, WhiteNoise, mp); | 36 | tNoise_initToPool(&p->noise, WhiteNoise, mp); |
| 37 | 37 | ||
| @@ -124,6 +124,7 @@ void tPluck_setFrequency (tPluck* const pl, float frequency ) · 86 unmodified lines | |||
| 124 | // Perform the control change specified by \e number and \e value (0.0 - 128.0). | 124 | // Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 125 | void tPluck_controlChange (tPluck* const pl, int number, float value) | 125 | void tPluck_controlChange (tPluck* const pl, int number, float value) |
| 126 | { | 126 | { |
| 127 | USED(pl); USED(number); USED(value); | ||
| 127 | return; | 128 | return; |
| 128 | } | 129 | } |
| 129 | 130 | ||
| @@ -156,7 +157,7 @@ void tKarplusStrong_initToPool (tKarplusStrong* const pl, float lowestFrequ · 26 unmodified lines | |||
| 156 | 157 | ||
| 157 | p->sampleRate = leaf->sampleRate; | 158 | p->sampleRate = leaf->sampleRate; |
| 158 | 159 | ||
| 159 | if ( lowestFrequency <= 0.0f ) lowestFrequency = 8.0f; | 160 | if ( lowestFrequency <= 0.0f ) lowestFrequency = 8.0f; USED(lowestFrequency); |
| 160 | 161 | ||
| 161 | tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, mp); | 162 | tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, mp); |
| 162 | tAllpassDelay_clear(&p->delayLine); | 163 | tAllpassDelay_clear(&p->delayLine); |
| @@ -618,7 +619,7 @@ void tSimpleLivingString3_pluck(tSimpleLivingString3* const pl, float input, f · 455 unmodified lines | |||
| 618 | int remainder = length-pluckPoint; | 619 | int remainder = length-pluckPoint; |
| 619 | for (int i = 0; i < length; i++) | 620 | for (int i = 0; i < length; i++) |
| 620 | { | 621 | { |
| 621 | float val = 0.0f; | 622 | float val; |
| 622 | if (i <= pluckPoint) | 623 | if (i <= pluckPoint) |
| 623 | { | 624 | { |
| 624 | val = input * ((float)i/(float)pluckPoint); | 625 | val = input * ((float)i/(float)pluckPoint); |
| @@ -643,6 +644,7 @@ void tSimpleLivingString3_pluck(tSimpleLivingString3* const pl, float input, f · 18 unmodified lines | |||
| 643 | float tSimpleLivingString3_tick(tSimpleLivingString3* const pl, float input) | 644 | float tSimpleLivingString3_tick(tSimpleLivingString3* const pl, float input) |
| 644 | { | 645 | { |
| 645 | _tSimpleLivingString3* p = *pl; | 646 | _tSimpleLivingString3* p = *pl; |
| 647 | USED(input); | ||
| 646 | tLinearDelay_setDelay(&p->delayLineU, tExpSmooth_tick(&p->wlSmooth)); | 648 | tLinearDelay_setDelay(&p->delayLineU, tExpSmooth_tick(&p->wlSmooth)); |
| 647 | tLinearDelay_setDelay(&p->delayLineL, tExpSmooth_tick(&p->wlSmooth)); | 649 | tLinearDelay_setDelay(&p->delayLineL, tExpSmooth_tick(&p->wlSmooth)); |
| 648 | 650 | ||
| @@ -1293,7 +1295,7 @@ float tLivingString2_tick(tLivingString2* const pl, float input) · 644 unmodified lines | |||
| 1293 | tHermiteDelay_setDelay(&p->delUB, upLen); | 1295 | tHermiteDelay_setDelay(&p->delUB, upLen); |
| 1294 | 1296 | ||
| 1295 | uint32_t PUPInt; | 1297 | uint32_t PUPInt; |
| 1296 | float pickupOut = 0.0f; | 1298 | float pickupOut; |
| 1297 | float pupos = tExpSmooth_tick(&p->puSmooth); | 1299 | float pupos = tExpSmooth_tick(&p->puSmooth); |
| 1298 | if (pupos < 0.9999f) | 1300 | if (pupos < 0.9999f) |
| 1299 | { | 1301 | { |
| @@ -281,7 +281,7 @@ float tSampler_tick (tSampler* const sp) · 280 unmodified lines | |||
| 281 | return p->last; | 281 | return p->last; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | float sample = 0.0f; | 284 | float sample; |
| 285 | float cfxsample = 0.0f; | 285 | float cfxsample = 0.0f; |
| 286 | float crossfadeMix = 0.0f; | 286 | float crossfadeMix = 0.0f; |
| 287 | float flipsample = 0.0f; | 287 | float flipsample = 0.0f; |
| @@ -1202,7 +1202,7 @@ void tAutoSampler_setCrossfadeLength (tAutoSampler* const as, uint32_t length · 914 unmodified lines | |||
| 1202 | 1202 | ||
| 1203 | void tAutoSampler_setRate (tAutoSampler* const as, float rate) | 1203 | void tAutoSampler_setRate (tAutoSampler* const as, float rate) |
| 1204 | { | 1204 | { |
| 1205 | ; | 1205 | USED(as); USED(rate); |
| 1206 | } | 1206 | } |
| 1207 | 1207 | ||
| 1208 | void tAutoSampler_setSampleRate (tAutoSampler* const as, float sr) | 1208 | void tAutoSampler_setSampleRate (tAutoSampler* const as, float sr) |
| @@ -33,7 +33,7 @@ void LEAF_init(LEAF* const leaf, float sr, char* memory, size_t memorysize, floa · 32 unmodified lines | |||
| 33 | 33 | ||
| 34 | leaf->clearOnAllocation = 0; | 34 | leaf->clearOnAllocation = 0; |
| 35 | 35 | ||
| 36 | leaf->errorCallback = &LEAF_defaultErrorCallback; | 36 | leaf->errorCallback = LEAF_defaultErrorCallback; |
| 37 | 37 | ||
| 38 | for (int i = 0; i < LEAFErrorNil; ++i) | 38 | for (int i = 0; i < LEAFErrorNil; ++i) |
| 39 | leaf->errorState[i] = 0; | 39 | leaf->errorState[i] = 0; |
| @@ -59,6 +59,7 @@ void LEAF_defaultErrorCallback(LEAF* const leaf, LEAFErrorType whichone) · 19 unmodified lines | |||
| 59 | { | 59 | { |
| 60 | // Not sure what this should do if anything | 60 | // Not sure what this should do if anything |
| 61 | // Maybe fine as a placeholder | 61 | // Maybe fine as a placeholder |
| 62 | USED(leaf); USED(whichone); | ||
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | void LEAF_internalErrorCallback(LEAF* const leaf, LEAFErrorType whichone) | 65 | void LEAF_internalErrorCallback(LEAF* const leaf, LEAFErrorType whichone) |
| @@ -24,6 +24,12 @@ · 23 unmodified lines | |||
| 24 | 24 | ||
| 25 | #ifndef LEAF_H_INCLUDED | 25 | #ifndef LEAF_H_INCLUDED |
| 26 | #define LEAF_H_INCLUDED | 26 | #define LEAF_H_INCLUDED |
| 27 | |||
| 28 | #ifdef __plan9__ | ||
| 29 | #pragma lib "./libleaf.$M.a" | ||
| 30 | #else | ||
| 31 | #define USED(x) | ||
| 32 | #endif | ||
| 27 | 33 | ||
| 28 | #define LEAF_DEBUG 0 | 34 | #define LEAF_DEBUG 0 |
| 29 | 35 | ||
| @@ -0,0 +1,67 @@ | |||
| 1 | </$objtype/mkfile | ||
| 2 | LIB=libleaf.$objtype.a | ||
| 3 | |||
| 4 | CFLAGS=$CFLAGS -p -IInc -IExternals -IExternals/plan9 -D__plan9__=1 | ||
| 5 | |||
| 6 | OFILES=\ | ||
| 7 | Externals/d_fft_mayer.$O\ | ||
| 8 | Externals/plan9/plan9.$O\ | ||
| 9 | Src/leaf-analysis.$O\ | ||
| 10 | Src/leaf-delay.$O\ | ||
| 11 | Src/leaf-distortion.$O\ | ||
| 12 | Src/leaf-dynamics.$O\ | ||
| 13 | Src/leaf-effects.$O\ | ||
| 14 | Src/leaf-electrical.$O\ | ||
| 15 | Src/leaf-envelopes.$O\ | ||
| 16 | Src/leaf-filters.$O\ | ||
| 17 | Src/leaf-instruments.$O\ | ||
| 18 | Src/leaf-math.$O\ | ||
| 19 | Src/leaf-mempool.$O\ | ||
| 20 | Src/leaf-midi.$O\ | ||
| 21 | Src/leaf-oscillators.$O\ | ||
| 22 | Src/leaf-physical.$O\ | ||
| 23 | Src/leaf-reverb.$O\ | ||
| 24 | Src/leaf-sampling.$O\ | ||
| 25 | Src/leaf-tables.$O\ | ||
| 26 | Src/leaf.$O\ | ||
| 27 | |||
| 28 | HFILES=\ | ||
| 29 | Externals/d_fft_mayer.h\ | ||
| 30 | Externals/trigtbl.h\ | ||
| 31 | Inc/leaf-analysis.h\ | ||
| 32 | Inc/leaf-delay.h\ | ||
| 33 | Inc/leaf-distortion.h\ | ||
| 34 | Inc/leaf-dynamics.h\ | ||
| 35 | Inc/leaf-effects.h\ | ||
| 36 | Inc/leaf-electrical.h\ | ||
| 37 | Inc/leaf-envelopes.h\ | ||
| 38 | Inc/leaf-filters.h\ | ||
| 39 | Inc/leaf-global.h\ | ||
| 40 | Inc/leaf-instruments.h\ | ||
| 41 | Inc/leaf-math.h\ | ||
| 42 | Inc/leaf-mempool.h\ | ||
| 43 | Inc/leaf-midi.h\ | ||
| 44 | Inc/leaf-oscillators.h\ | ||
| 45 | Inc/leaf-physical.h\ | ||
| 46 | Inc/leaf-reverb.h\ | ||
| 47 | Inc/leaf-sampling.h\ | ||
| 48 | Inc/leaf-tables.h\ | ||
| 49 | leaf-config.h\ | ||
| 50 | leaf.h\ | ||
| 51 | |||
| 52 | (.*)\.$O:R: \1.c | ||
| 53 | $CC $CFLAGS -o $target $stem1.c | ||
| 54 | |||
| 55 | LIBOBJ=${OFILES:%=$LIB(%)} | ||
| 56 | |||
| 57 | default:V: $LIB | ||
| 58 | |||
| 59 | all:V: $LIB | ||
| 60 | |||
| 61 | $LIB: $LIBOBJ | ||
| 62 | ar vu $LIB $newmember | ||
| 63 | |||
| 64 | $LIB(%.$O):N: %.$O | ||
| 65 | |||
| 66 | clean:V: | ||
| 67 | rm -f */*.[$OS] */*/*.[$OS] *.a | ||
| @@ -0,0 +1,33 @@ | |||
| 1 | #include "leaf.h" | ||
| 2 | #include <bio.h> | ||
| 3 | |||
| 4 | static float | ||
| 5 | fandom(void) | ||
| 6 | { | ||
| 7 | return frand(); | ||
| 8 | } | ||
| 9 | |||
| 10 | void | ||
| 11 | main(int, char **) | ||
| 12 | { | ||
| 13 | LEAF leaf; | ||
| 14 | tCycle cycle; | ||
| 15 | char mem[1000]; | ||
| 16 | Biobuf out; | ||
| 17 | int i; | ||
| 18 | |||
| 19 | LEAF_init(&leaf, 44100, mem, 1000, fandom); | ||
| 20 | tCycle_init(&cycle, &leaf); | ||
| 21 | tCycle_setFreq(&cycle, 220); | ||
| 22 | Binit(&out, 1, OWRITE); | ||
| 23 | |||
| 24 | for(i = 0; i < 44100; i++){ | ||
| 25 | float f = tCycle_tick(&cycle); | ||
| 26 | s16int s[2]; | ||
| 27 | s[0] = 16384.0f*(f - 0.5f); | ||
| 28 | s[1] = s[0]; | ||
| 29 | Bwrite(&out, s, sizeof(s)); | ||
| 30 | } | ||
| 31 | |||
| 32 | exits(nil); | ||
| 33 | } | ||