diff options
Diffstat (limited to 'apps/plugins/midi/synth.c')
-rw-r--r-- | apps/plugins/midi/synth.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 0819722030..bae6149860 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c | |||
@@ -296,7 +296,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
296 | while(samples-- > 0) | 296 | while(samples-- > 0) |
297 | { | 297 | { |
298 | /* Is voice being ramped? */ | 298 | /* Is voice being ramped? */ |
299 | if(so->state == STATE_RAMPDOWN) | 299 | if(unlikely(so->state == STATE_RAMPDOWN)) |
300 | { | 300 | { |
301 | if(so->decay != 0) /* Ramp has been started */ | 301 | if(so->decay != 0) /* Ramp has been started */ |
302 | { | 302 | { |
@@ -318,12 +318,12 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
318 | 318 | ||
319 | s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); | 319 | s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); |
320 | 320 | ||
321 | if(mode_mask28) | 321 | if(likely(mode_mask28)) |
322 | { | 322 | { |
323 | /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ | 323 | /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ |
324 | if(mode_mask24 && so->loopState == STATE_LOOPING && (cp_temp < start_loop)) | 324 | if(unlikely(mode_mask24 && so->loopState == STATE_LOOPING && (cp_temp < start_loop))) |
325 | { | 325 | { |
326 | if(mode_mask_looprev) | 326 | if(unlikely(mode_mask_looprev)) |
327 | { | 327 | { |
328 | cp_temp += diff_loop; | 328 | cp_temp += diff_loop; |
329 | s2=getSample((cp_temp >> FRACTSIZE), wf); | 329 | s2=getSample((cp_temp >> FRACTSIZE), wf); |
@@ -334,10 +334,10 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | if(cp_temp >= end_loop) | 337 | if(unlikely(cp_temp >= end_loop)) |
338 | { | 338 | { |
339 | so->loopState = STATE_LOOPING; | 339 | so->loopState = STATE_LOOPING; |
340 | if(!mode_mask24) | 340 | if(unlikely(!mode_mask24)) |
341 | { | 341 | { |
342 | cp_temp -= diff_loop; | 342 | cp_temp -= diff_loop; |
343 | s2=getSample((cp_temp >> FRACTSIZE), wf); | 343 | s2=getSample((cp_temp >> FRACTSIZE), wf); |
@@ -350,7 +350,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
350 | } | 350 | } |
351 | 351 | ||
352 | /* Have we overrun? */ | 352 | /* Have we overrun? */ |
353 | if(cp_temp >= num_samples) | 353 | if(unlikely(cp_temp >= num_samples)) |
354 | { | 354 | { |
355 | cp_temp -= so->delta; | 355 | cp_temp -= so->delta; |
356 | s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); | 356 | s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); |
@@ -362,21 +362,21 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
362 | 362 | ||
363 | s1 +=((signed)((s2 - s1) * (cp_temp & ((1<<FRACTSIZE)-1)))>>FRACTSIZE); | 363 | s1 +=((signed)((s2 - s1) * (cp_temp & ((1<<FRACTSIZE)-1)))>>FRACTSIZE); |
364 | 364 | ||
365 | if(so->curRate == 0) | 365 | if(unlikely(so->curRate == 0)) |
366 | { | 366 | { |
367 | stopVoice(so); | 367 | stopVoice(so); |
368 | // so->isUsed = false; | 368 | // so->isUsed = false; |
369 | 369 | ||
370 | } | 370 | } |
371 | 371 | ||
372 | if(so->ch != 9 && so->state != STATE_RAMPDOWN) /* Stupid ADSR code... and don't do ADSR for drums */ | 372 | if(likely(so->ch != 9 && so->state != STATE_RAMPDOWN)) /* Stupid ADSR code... and don't do ADSR for drums */ |
373 | { | 373 | { |
374 | if(so->curOffset < so->targetOffset) | 374 | if(unlikely(so->curOffset < so->targetOffset)) |
375 | { | 375 | { |
376 | so->curOffset += (so->curRate); | 376 | so->curOffset += (so->curRate); |
377 | if(so -> curOffset > so->targetOffset && so->curPoint != 2) | 377 | if(unlikely(so -> curOffset > so->targetOffset && so->curPoint != 2)) |
378 | { | 378 | { |
379 | if(so->curPoint != 5) | 379 | if(unlikely(so->curPoint != 5)) |
380 | { | 380 | { |
381 | setPoint(so, so->curPoint+1); | 381 | setPoint(so, so->curPoint+1); |
382 | } | 382 | } |
@@ -388,10 +388,9 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
388 | } else | 388 | } else |
389 | { | 389 | { |
390 | so->curOffset -= (so->curRate); | 390 | so->curOffset -= (so->curRate); |
391 | if(so -> curOffset < so->targetOffset && so->curPoint != 2) | 391 | if(unlikely(so -> curOffset < so->targetOffset && so->curPoint != 2)) |
392 | { | 392 | { |
393 | 393 | if(unlikely(so->curPoint != 5)) | |
394 | if(so->curPoint != 5) | ||
395 | { | 394 | { |
396 | setPoint(so, so->curPoint+1); | 395 | setPoint(so, so->curPoint+1); |
397 | } | 396 | } |
@@ -404,7 +403,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
404 | } | 403 | } |
405 | } | 404 | } |
406 | 405 | ||
407 | if(so->curOffset < 0) | 406 | if(unlikely(so->curOffset < 0)) |
408 | { | 407 | { |
409 | so->curOffset = so->targetOffset; | 408 | so->curOffset = so->targetOffset; |
410 | stopVoice(so); | 409 | stopVoice(so); |
@@ -417,7 +416,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i | |||
417 | s1 = s1 * volscale >> 14; | 416 | s1 = s1 * volscale >> 14; |
418 | 417 | ||
419 | /* need to set ramp beginning */ | 418 | /* need to set ramp beginning */ |
420 | if(so->state == STATE_RAMPDOWN && so->decay == 0) | 419 | if(unlikely(so->state == STATE_RAMPDOWN && so->decay == 0)) |
421 | { | 420 | { |
422 | so->decay = s1; | 421 | so->decay = s1; |
423 | if(so->decay == 0) | 422 | if(so->decay == 0) |
@@ -443,7 +442,7 @@ int32_t samp_buf[512] IBSS_ATTR; | |||
443 | void synthSamples(int32_t *buf_ptr, unsigned int num_samples) ICODE_ATTR; | 442 | void synthSamples(int32_t *buf_ptr, unsigned int num_samples) ICODE_ATTR; |
444 | void synthSamples(int32_t *buf_ptr, unsigned int num_samples) | 443 | void synthSamples(int32_t *buf_ptr, unsigned int num_samples) |
445 | { | 444 | { |
446 | if (num_samples > 512) | 445 | if (unlikely(num_samples > 512)) |
447 | DEBUGF("num_samples is too big!\n"); | 446 | DEBUGF("num_samples is too big!\n"); |
448 | else | 447 | else |
449 | { | 448 | { |
@@ -463,6 +462,7 @@ void synthSamples(int32_t *buf_ptr, unsigned int num_samples) | |||
463 | 462 | ||
464 | rb->memcpy(buf_ptr, samp_buf, num_samples*4); | 463 | rb->memcpy(buf_ptr, samp_buf, num_samples*4); |
465 | } | 464 | } |
465 | |||
466 | /* TODO: Automatic Gain Control, anyone? */ | 466 | /* TODO: Automatic Gain Control, anyone? */ |
467 | /* Or, should this be implemented on the DSP's output volume instead? */ | 467 | /* Or, should this be implemented on the DSP's output volume instead? */ |
468 | 468 | ||