History

fixed issues with tPoly where stolen voices werent updated properly, and made tCycle capable of goings through zero in frequency so that proper FM is possible

spiricom committed 6 years ago

Commit e5863731 parent 72b60cd7 files · +51 −24Browse files

Unified · Split

7 files
  1. .DS_Store +0 −0
  2. LEAF/.DS_Store +0 −0
  3. LEAF/Inc/leaf-midi.h +2 −0
  4. LEAF/Src/leaf-effects.c +1 −9
  5. LEAF/Src/leaf-envelopes.c +2 −5
  6. LEAF/Src/leaf-midi.c +29 −3
  7. LEAF/Src/leaf-oscillators.c +19 −9
.DS_Store+0−0

Binary file not shown.

LEAF/.DS_Store+0−0

Binary file not shown.

LEAF/Inc/leaf-midi.h+2−0
@@ -107,6 +107,8 @@ extern "C" { · 106 unmodified lines
107107 void tPoly_setPitchBend (tPoly* const, float pitchBend);
108108 void tPoly_setPitchGlideActive (tPoly* const, oBool isActive);
109109 void tPoly_setPitchGlideTime (tPoly* const, float t);
110+ void tPoly_setBendGlideTime (tPoly* const polyh, float t);
111+ void tPoly_setBendSamplesPerTick (tPoly* const polyh, float t);
110112 void tPoly_tickPitch (tPoly* const);
111113 void tPoly_tickPitchGlide (tPoly* const);
112114 void tPoly_tickPitchBend (tPoly* const);
LEAF/Src/leaf-effects.c+1−9
@@ -254,15 +254,7 @@ float tTalkbox_tick(tTalkbox* const voc, float synth, float voice) · 253 unmodified lines
254254 v->pos = p0;
255255 v->FX = fx;
256256
257− float den = 1.0e-10f; //(float)pow(10.0f, -10.0f * param[4]);
258− if(fabs(v->d0) < den) v->d0 = 0.0f; //anti-denormal (doesn't seem necessary but P4?)
259− if(fabs(v->d1) < den) v->d1 = 0.0f;
260− if(fabs(v->d2) < den) v->d2 = 0.0f;
261− if(fabs(v->d3) < den) v->d3 = 0.0f;
262− if(fabs(v->u0) < den) v->u0 = 0.0f;
263− if(fabs(v->u1) < den) v->u1 = 0.0f;
264− if(fabs(v->u2) < den) v->u2 = 0.0f;
265− if(fabs(v->u3) < den) v->u3 = 0.0f;
257+
266258 return o;
267259 }
268260
LEAF/Src/leaf-envelopes.c+2−5
@@ -399,7 +399,7 @@ void tADSR_setAttack(tADSR* const adsrenv, float attack) · 398 unmodified lines
399399 adsr->attackInc = adsr->inc_buff[attackIndex];
400400 }
401401
402−void tADSR_detDecay(tADSR* const adsrenv, float decay)
402+void tADSR_setDecay(tADSR* const adsrenv, float decay)
403403 {
404404 _tADSR* adsr = *adsrenv;
405405
@@ -657,14 +657,11 @@ float tRamp_tick(tRamp* const ramp) · 251 unmodified lines
657657
658658 r->curr += r->inc;
659659
660− if (((r->curr >= r->dest) && (r->inc > 0.0f)) || ((r->curr <= r->dest) && (r->inc < 0.0f)))
660+ if (((r->curr >= r->dest) && (r->inc >= 0.0f)) || ((r->curr <= r->dest) && (r->inc < 0.0f)))
661661 {
662662 r->inc = 0.0f;
663663 r->curr=r->dest;
664664 }
665−
666− // Palle: There is a slight risk that you overshoot here and stay on dest+inc, which with a large inc value could be a real problem
667− // I suggest you add: r->curr=r->dest in the true if case
668665
669666 return r->curr;
670667 }
LEAF/Src/leaf-midi.c+29−3
@@ -425,7 +425,6 @@ void tPoly_tickPitchBend(tPoly* polyh) · 424 unmodified lines
425425 tRamp_tick(&poly->pitchBendRamp);
426426 }
427427
428−//instead of including in dacsend, should have a separate pitch bend ramp, that is added when the ramps are ticked and sent to DAC
429428 void tPoly_setPitchBend(tPoly* const polyh, float pitchBend)
430429 {
431430 _tPoly* poly = *polyh;
@@ -480,7 +479,7 @@ int tPoly_noteOn(tPoly* const polyh, int note, uint8_t vel) · 48 unmodified lines
480479 whichVoice = poly->notes[whichNote][1];
481480 if (whichVoice >= 0)
482481 {
483− poly->lastVoiceToChange = j;
482+ poly->lastVoiceToChange = whichVoice;
484483 int oldNote = poly->voices[whichVoice][0];
485484 poly->voices[whichVoice][0] = note;
486485 poly->voices[whichVoice][1] = vel;
@@ -488,7 +487,14 @@ int tPoly_noteOn(tPoly* const polyh, int note, uint8_t vel) · 1 unmodified line
488487 poly->notes[note][0] = vel;
489488 poly->notes[note][1] = whichVoice;
490489
491− tRamp_setTime(&poly->ramps[whichVoice], poly->glideTime);
490+ if (poly->pitchGlideIsActive)
491+ {
492+ tRamp_setTime(&poly->ramps[whichVoice], poly->glideTime);
493+ }
494+ else
495+ {
496+ tRamp_setVal(&poly->ramps[whichVoice], note);
497+ }
492498 tRamp_setDest(&poly->ramps[whichVoice], poly->voices[whichVoice][0]);
493499
494500 alteredVoice = whichVoice;
@@ -546,6 +552,14 @@ int tPoly_noteOff(tPoly* const polyh, uint8_t note) · 51 unmodified lines
546552 if (poly->notes[noteToTest][1] < 0) //if there is a stolen note waiting (marked inactive but on the stack)
547553 {
548554 poly->voices[deactivatedVoice][0] = noteToTest; //set the newly free voice to use the old stolen note
555+ if (poly->pitchGlideIsActive)
556+ {
557+ tRamp_setTime(&poly->ramps[deactivatedVoice], poly->glideTime);
558+ }
559+ else
560+ {
561+ tRamp_setVal(&poly->ramps[deactivatedVoice], noteToTest);
562+ }
549563 tRamp_setDest(&poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]);
550564 poly->voices[deactivatedVoice][1] = poly->notes[noteToTest][0]; // set the velocity of the voice to be the velocity of that note
551565 poly->notes[noteToTest][1] = deactivatedVoice; //mark that it is no longer stolen and is now active
@@ -618,6 +632,18 @@ void tPoly_setPitchGlideTime(tPoly* const polyh, float t) · 66 unmodified lines
618632 }
619633 }
620634
635+void tPoly_setBendGlideTime(tPoly* const polyh, float t)
636+{
637+ _tPoly* poly = *polyh;
638+ tRamp_setTime(&poly->pitchBendRamp, t);
639+}
640+
641+void tPoly_setBendSamplesPerTick(tPoly* const polyh, float t)
642+{
643+ _tPoly* poly = *polyh;
644+ poly->pitchBendRamp->samples_per_tick = t;
645+}
646+
621647 int tPoly_getNumVoices(tPoly* const polyh)
622648 {
623649 _tPoly* poly = *polyh;
LEAF/Src/leaf-oscillators.c+19−9
@@ -25,6 +25,7 @@ void tCycle_init(tCycle* const cy) · 24 unmodified lines
2525
2626 c->inc = 0.0f;
2727 c->phase = 0.0f;
28+
2829 }
2930
3031 void tCycle_free(tCycle* const cy)
@@ -41,6 +42,7 @@ void tCycle_initToPool (tCycle* const cy, tMempool* const mp) · 10 unmodified lines
4142
4243 c->inc = 0.0f;
4344 c->phase = 0.0f;
45+
4446 }
4547
4648 void tCycle_freeFromPool (tCycle* const cy, tMempool* const mp)
@@ -55,30 +57,38 @@ int tCycle_setFreq(tCycle* const cy, float freq) · 8 unmodified lines
5557 {
5658 _tCycle* c = *cy;
5759
58− if (freq < 0.0f) freq = 0.0f;
59−
6060 c->freq = freq;
6161 c->inc = freq * leaf.invSampleRate;
6262
6363 return 0;
6464 }
6565
66+//need to check bounds and wrap table properly to allow through-zero FM
6667 float tCycle_tick(tCycle* const cy)
6768 {
6869 _tCycle* c = *cy;
70+ float temp;;
71+ int intPart;;
72+ float fracPart;
73+ float samp0;
74+ float samp1;
6975
7076 // Phasor increment
7177 c->phase += c->inc;
7278 while (c->phase >= 1.0f) c->phase -= 1.0f;
73−
79+ while (c->phase <= 0.0f) c->phase += 1.0f;
80+
7481 // Wavetable synthesis
75− float temp = SINE_TABLE_SIZE * c->phase;
76− int intPart = (int)temp;
77− float fracPart = temp - (float)intPart;
78− float samp0 = sinewave[intPart];
79− if (++intPart >= SINE_TABLE_SIZE) intPart = 0;
80− float samp1 = sinewave[intPart];
82+
83+ temp = SINE_TABLE_SIZE * c->phase;
84+ intPart = (int)temp;
85+ fracPart = temp - (float)intPart;
86+ samp0 = sinewave[intPart];
87+ if (++intPart >= SINE_TABLE_SIZE) intPart = 0;
88+ samp1 = sinewave[intPart];
89+
8190 return (samp0 + (samp1 - samp0) * fracPart);
91+
8292 }
8393
8494 void tCycleSampleRateChanged (tCycle* const cy)

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