History

New stuff.

mulshine committed 7 years ago

Commit 54f35b11 parent d0fbdd51 file · +22 −15Browse files

Unified · Split

LEAF/Src/leaf-sample.c+22−15
@@ -106,7 +106,7 @@ void tSample_clear (tSample* const s) · 105 unmodified lines
106106
107107 //==============================================================================
108108
109−#define CFX 30
109+#define CFX 300
110110
111111 void tSamplePlayer_init (tSamplePlayer* const p, tSample* s)
112112 {
@@ -144,15 +144,25 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 31 unmodified lines
144144
145145 float sample = 0.f;
146146 float cfxsample = 0.f;
147− int cfx = CFX;
147+ int cfx = CFX; // make this part of class
148148
149149 float* buff = p->samp->buff;
150150
151151 int dir = p->dir * p->flip;
152152
153− int idx = (int) p->idx;
154− float alpha = p->idx - idx;
155− float idxx;
153+ int idx;
154+ float alpha;
155+
156+ if (dir > 0)
157+ {
158+ idx = (int) p->idx;
159+ alpha = p->idx - idx;
160+ }
161+ else
162+ {
163+ idx = (int) (p->idx + 1.f); // we think this is because flooring on int works different when reading backwards
164+ alpha = (p->idx+1.f) - idx;
165+ }
156166
157167 int32_t start = p->start, end = p->end;
158168 if (p->flip < 0)
@@ -179,16 +189,13 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 20 unmodified lines
179189 buff[i4],
180190 alpha);
181191
182− //printf("cidx: %d\n", idx);
183−
184− cfx = (end - idx) / p->inc;
185−
192+ cfx = (end - idx) / p->inc; // num samples to end of loop, use inverse increment
193+
186194 if (cfx <= CFX)
187195 {
188196 // CROSSFADE SAMPLE
189− idxx = p->idx - p->len;
197+ float idxx = p->idx - p->len;
190198 int cdx = (int)(idxx);
191− float alpha = idxx - cdx;
192199
193200 i1 = cdx-1;
194201 i3 = cdx+1;
@@ -213,7 +220,7 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 18 unmodified lines
213220
214221 if (i1 > end) i1 -= p->len;
215222 if (i3 < start) i3 += p->len;
216− if (i4 < start) i4 += p->len;
223+ if (i4 < start) i4 += p->len;
217224
218225 sample = LEAF_interpolate_hermite (buff[i1],
219226 buff[idx],
@@ -226,9 +233,9 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 6 unmodified lines
226233 if (cfx <= CFX)
227234 {
228235 // CROSSFADE SAMPLE
229− idxx = p->idx + p->len;
236+ float idxx = p->idx + p->len + 1.f;
230237 int cdx = (int)(idxx);
231− float alpha = idxx - cdx;
238+ alpha = idxx - cdx;
232239
233240 i1 = cdx+1;
234241 i3 = cdx-1;
@@ -238,7 +245,7 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 3 unmodified lines
238245 buff[cdx],
239246 buff[i3],
240247 buff[i4],
241− alpha);
248+ 1.f-alpha);
242249 }
243250 else cfx = CFX;
244251 }

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