diff options
-rw-r--r-- | common/components/mss/src/mssproc.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/common/components/mss/src/mssproc.c b/common/components/mss/src/mssproc.c index 87ce6ff..fa54d08 100644 --- a/common/components/mss/src/mssproc.c +++ b/common/components/mss/src/mssproc.c | |||
@@ -343,7 +343,7 @@ void mss_src_output(mssInst_t *inst, void *out, void *mic_fix[], | |||
343 | } | 343 | } |
344 | 344 | ||
345 | /* Check if in the middle of a switch. */ | 345 | /* Check if in the middle of a switch. */ |
346 | if(!mss_chkbit(inst->state_bf, MSS_STATE_BIT_SWITCH_SRC)) { | 346 | if(!mss_chkbit(inst->state_bf, MSS_STATE_BIT_SWITCH_SRC) && cur_sel_src != NULL) { |
347 | /* If it is not during a switch, copy the current selected source to output | 347 | /* If it is not during a switch, copy the current selected source to output |
348 | without any modification. */ | 348 | without any modification. */ |
349 | memcpy(out, cur_sel_src, inst->frame_size*sizeof(linSample)); | 349 | memcpy(out, cur_sel_src, inst->frame_size*sizeof(linSample)); |
@@ -369,17 +369,23 @@ void mss_src_output(mssInst_t *inst, void *out, void *mic_fix[], | |||
369 | phase_inc = inst->crossfade_phase_inc; | 369 | phase_inc = inst->crossfade_phase_inc; |
370 | output = (linSample *)out; | 370 | output = (linSample *)out; |
371 | 371 | ||
372 | for(i=0; i<inst->frame_size; i++) { | 372 | if(cur_sel_src != NULL && new_sel_src != NULL) |
373 | // alpha = (1-utlSin(phase>>16)) / 2; /* to use macros */ | 373 | { |
374 | sin_phase = utlSin(phase>>16); /* Q.31 to Q.15 */ | 374 | for(i=0; i<inst->frame_size; i++) { |
375 | fade_out_alpha = MSS_SIN_PIOVER2/2 - sin_phase/2; /* (1-sin(pha))/2 in Q.14 */ | 375 | sin_phase = utlSin(phase>>16); /* Q.31 to Q.15 */ |
376 | fade_in_alpha = MSS_SIN_PIOVER2/2 + sin_phase/2; /* (1+sin(pha))/2 in Q.14 */ | 376 | fade_out_alpha = MSS_SIN_PIOVER2/2 - sin_phase/2; /* (1-sin(pha))/2 in Q.14 */ |
377 | fade_out_alpha = mss_MIN(16383, fade_out_alpha); | 377 | fade_in_alpha = MSS_SIN_PIOVER2/2 + sin_phase/2; /* (1+sin(pha))/2 in Q.14 */ |
378 | fade_in_alpha = mss_MIN(16383, fade_in_alpha); | 378 | fade_out_alpha = mss_MIN(16383, fade_out_alpha); |
379 | output[i] = frctMul(cur_sel_src[i], 0, fade_out_alpha, 14, 0) | 379 | fade_in_alpha = mss_MIN(16383, fade_in_alpha); |
380 | output[i] = frctMul(cur_sel_src[i], 0, fade_out_alpha, 14, 0) | ||
380 | +frctMul(new_sel_src[i], 0, fade_in_alpha, 14, 0); | 381 | +frctMul(new_sel_src[i], 0, fade_in_alpha, 14, 0); |
381 | phase += phase_inc; | 382 | phase += phase_inc; |
383 | } | ||
384 | } | ||
385 | else { | ||
386 | /* error message */ | ||
382 | } | 387 | } |
388 | |||
383 | inst->crossfade_phase = phase; | 389 | inst->crossfade_phase = phase; |
384 | 390 | ||
385 | /* for debugging only */ | 391 | /* for debugging only */ |