History

Sampler working well with manual linear crossfade.

mulshine committed 7 years ago

Commit 1a65dc61 parent 6c87e501 file · +20 −11Browse files

Unified · Split

LEAF/Src/leaf-sample.c+20−11
@@ -106,7 +106,7 @@ void tSample_clear (tSample* const s) · 105 unmodified lines
106106
107107 //==============================================================================
108108
109−#define CFX 50
109+#define CFX 10
110110
111111 void tSamplePlayer_init (tSamplePlayer* const p, tSample* s)
112112 {
@@ -144,6 +144,7 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 31 unmodified lines
144144
145145 float sample = 0.f;
146146 float cfxsample = 0.f;
147+ int cfx = CFX;
147148
148149 float* buff = p->samp->buff;
149150
@@ -179,10 +180,15 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 29 unmodified lines
179180 buff[i3],
180181 buff[i4],
181182 alpha);
182− if ((end - idx) <= CFX)
183+
184+ cfx = (end - idx) / p->inc;
185+
186+ if (cfx <= CFX)
183187 {
184188 // CROSSFADE SAMPLE
185− int cdx = idx - p->len;
189+ float idxx = p->idx - p->len;
190+ int cdx = (int)(idxx);
191+ float alpha = idxx - cdx;
186192
187193 i1 = cdx-1;
188194 i3 = cdx+1;
@@ -193,10 +199,8 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 4 unmodified lines
193199 buff[i3],
194200 buff[i4],
195201 alpha);
196−
197− p->g2 = (float) (CFX - (end - idx - 1)) / (float) CFX;
198− p->g1 = 1.f - p->g2;
199202 }
203+ else cfx = CFX;
200204 }
201205 else
202206 {
@@ -215,7 +219,9 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 12 unmodified lines
215219 buff[i4],
216220 1.0f-alpha);
217221
218− if ((idx - start) <= CFX)
222+ cfx = (idx - start) / p->inc;
223+
224+ if (cfx <= CFX)
219225 {
220226 // CROSSFADE SAMPLE
221227 int cdx = idx + p->len;
@@ -229,10 +235,8 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 7 unmodified lines
229235 buff[i3],
230236 buff[i4],
231237 alpha);
232−
233− p->g2 = (float) (CFX - (idx - start - 1)) / (float) CFX;
234− p->g1 = 1.f - p->g2;
235238 }
239+ else cfx = CFX;
236240 }
237241
238242 p->idx += (dir * p->inc);
@@ -259,7 +263,12 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 20 unmodified lines
259263 }
260264 }
261265
262− return sample * p->g1 + cfxsample * p->g2;
266+ sample = sample * p->g1 + cfxsample * p->g2;
267+
268+ p->g2 = (float) (CFX - cfx) / (float) CFX;
269+ p->g1 = 1.f - p->g2;
270+
271+ return sample;
263272 }
264273
265274 void tSamplePlayer_setSample (tSamplePlayer* const p, tSample* s)

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