Unified · Split
| @@ -106,7 +106,7 @@ void tSample_clear (tSample* const s) · 105 unmodified lines | ||
| 106 | 106 | |
| 107 | 107 | //============================================================================== |
| 108 | 108 | |
| 109 | −#define CFX 50 | |
| 109 | +#define CFX 10 | |
| 110 | 110 | |
| 111 | 111 | void tSamplePlayer_init (tSamplePlayer* const p, tSample* s) |
| 112 | 112 | { |
| @@ -144,6 +144,7 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 31 unmodified lines | ||
| 144 | 144 | |
| 145 | 145 | float sample = 0.f; |
| 146 | 146 | float cfxsample = 0.f; |
| 147 | + int cfx = CFX; | |
| 147 | 148 | |
| 148 | 149 | float* buff = p->samp->buff; |
| 149 | 150 | |
| @@ -179,10 +180,15 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 29 unmodified lines | ||
| 179 | 180 | buff[i3], |
| 180 | 181 | buff[i4], |
| 181 | 182 | alpha); |
| 182 | − if ((end - idx) <= CFX) | |
| 183 | + | |
| 184 | + cfx = (end - idx) / p->inc; | |
| 185 | + | |
| 186 | + if (cfx <= CFX) | |
| 183 | 187 | { |
| 184 | 188 | // 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; | |
| 186 | 192 | |
| 187 | 193 | i1 = cdx-1; |
| 188 | 194 | i3 = cdx+1; |
| @@ -193,10 +199,8 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 4 unmodified lines | ||
| 193 | 199 | buff[i3], |
| 194 | 200 | buff[i4], |
| 195 | 201 | alpha); |
| 196 | − | |
| 197 | − p->g2 = (float) (CFX - (end - idx - 1)) / (float) CFX; | |
| 198 | − p->g1 = 1.f - p->g2; | |
| 199 | 202 | } |
| 203 | + else cfx = CFX; | |
| 200 | 204 | } |
| 201 | 205 | else |
| 202 | 206 | { |
| @@ -215,7 +219,9 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 12 unmodified lines | ||
| 215 | 219 | buff[i4], |
| 216 | 220 | 1.0f-alpha); |
| 217 | 221 | |
| 218 | − if ((idx - start) <= CFX) | |
| 222 | + cfx = (idx - start) / p->inc; | |
| 223 | + | |
| 224 | + if (cfx <= CFX) | |
| 219 | 225 | { |
| 220 | 226 | // CROSSFADE SAMPLE |
| 221 | 227 | int cdx = idx + p->len; |
| @@ -229,10 +235,8 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 7 unmodified lines | ||
| 229 | 235 | buff[i3], |
| 230 | 236 | buff[i4], |
| 231 | 237 | alpha); |
| 232 | − | |
| 233 | − p->g2 = (float) (CFX - (idx - start - 1)) / (float) CFX; | |
| 234 | − p->g1 = 1.f - p->g2; | |
| 235 | 238 | } |
| 239 | + else cfx = CFX; | |
| 236 | 240 | } |
| 237 | 241 | |
| 238 | 242 | p->idx += (dir * p->inc); |
| @@ -259,7 +263,12 @@ float tSamplePlayer_tick (tSamplePlayer* const p) · 20 unmodified lines | ||
| 259 | 263 | } |
| 260 | 264 | } |
| 261 | 265 | |
| 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; | |
| 263 | 272 | } |
| 264 | 273 | |
| 265 | 274 | void tSamplePlayer_setSample (tSamplePlayer* const p, tSample* s) |