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
106 106
107//==============================================================================107//==============================================================================
108 108
109#define CFX 30109#define CFX 300
110 110
111void tSamplePlayer_init (tSamplePlayer* const p, tSample* s)111void tSamplePlayer_init (tSamplePlayer* const p, tSample* s)
112{112{
@@ -144,15 +144,25 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 31 unmodified lines
144 144
145 float sample = 0.f;145 float sample = 0.f;
146 float cfxsample = 0.f;146 float cfxsample = 0.f;
147 int cfx = CFX;147 int cfx = CFX; // make this part of class
148 148
149 float* buff = p->samp->buff;149 float* buff = p->samp->buff;
150 150
151 int dir = p->dir * p->flip;151 int dir = p->dir * p->flip;
152 152
153 int idx = (int) p->idx;153 int idx;
154 float alpha = p->idx - idx;154 float alpha;
155 float idxx;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 }
156 166
157 int32_t start = p->start, end = p->end;167 int32_t start = p->start, end = p->end;
158 if (p->flip < 0)168 if (p->flip < 0)
@@ -179,16 +189,13 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 20 unmodified lines
179 buff[i4],189 buff[i4],
180 alpha);190 alpha);
181 191
182 //printf("cidx: %d\n", idx);192 cfx = (end - idx) / p->inc; // num samples to end of loop, use inverse increment
183 193
184 cfx = (end - idx) / p->inc;
185
186 if (cfx <= CFX)194 if (cfx <= CFX)
187 {195 {
188 // CROSSFADE SAMPLE196 // CROSSFADE SAMPLE
189 idxx = p->idx - p->len;197 float idxx = p->idx - p->len;
190 int cdx = (int)(idxx);198 int cdx = (int)(idxx);
191 float alpha = idxx - cdx;
192 199
193 i1 = cdx-1;200 i1 = cdx-1;
194 i3 = cdx+1;201 i3 = cdx+1;
@@ -213,7 +220,7 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 18 unmodified lines
213 220
214 if (i1 > end) i1 -= p->len;221 if (i1 > end) i1 -= p->len;
215 if (i3 < start) i3 += p->len;222 if (i3 < start) i3 += p->len;
216 if (i4 < start) i4 += p->len;223 if (i4 < start) i4 += p->len;
217 224
218 sample = LEAF_interpolate_hermite (buff[i1],225 sample = LEAF_interpolate_hermite (buff[i1],
219 buff[idx],226 buff[idx],
@@ -226,9 +233,9 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 6 unmodified lines
226 if (cfx <= CFX)233 if (cfx <= CFX)
227 {234 {
228 // CROSSFADE SAMPLE235 // CROSSFADE SAMPLE
229 idxx = p->idx + p->len;236 float idxx = p->idx + p->len + 1.f;
230 int cdx = (int)(idxx);237 int cdx = (int)(idxx);
231 float alpha = idxx - cdx;238 alpha = idxx - cdx;
232 239
233 i1 = cdx+1;240 i1 = cdx+1;
234 i3 = cdx-1;241 i3 = cdx-1;
@@ -238,7 +245,7 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 3 unmodified lines
238 buff[cdx],245 buff[cdx],
239 buff[i3],246 buff[i3],
240 buff[i4],247 buff[i4],
241 alpha);248 1.f-alpha);
242 }249 }
243 else cfx = CFX;250 else cfx = CFX;
244 }251 }

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