adjust_balance.c

来自「ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代」· C语言 代码 · 共 37 行

C
37
字号
#include "Sample Playback.h"


//This subroutine is called for every sport interrupt. It's function is
//to sweep the audio balance from right to left and back to right again.
//This is synchronized with the LED sweeping. Note, the sample has some
//ambient sound at the end, so the middle of the sweep is NOT the middle 
//of the entire audio sample.
void adjust_balance(void)
{   
    int offset;
    
    //current offset into sample
    offset=(FirstSample->CurrentAddr - FirstSample->StartAddr);
    
    
    //For the first half of sweep percieved source shifts left<-right
    if (offset <= SWEEP_MIDDLE) {
        //step is simply 1/SWEEP_MIDDLE, and allows the gain to move from 0<->1 over half the sample.
        
        //decrease Rgain
        Rgain = 1-(step*offset);
        //increse Lgain
        Lgain =   (step*offset);    
    }
    
    // for second half of sweep, shift source left->right
    if ((offset>SWEEP_MIDDLE)&(offset<=2*SWEEP_MIDDLE) ){
            //decrease Lgain
            Lgain = 1-(step*(offset-(float)SWEEP_MIDDLE));
            //decrease Rgain
            Rgain =   (step*(offset-(float)SWEEP_MIDDLE));    
    }
    
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?