process_samples.c

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

C
41
字号
#include <def21262.h>
#include "kr.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 process_sample(void)
{   
    int current_addr;
    
    //current offset into sample
    current_addr=(FirstSample->CurrentAddr - FirstSample->StartAddr);
    
    
    //For the first half of sweep percieved source shifts left<-right
    if (current_addr <= SWEEP_MIDDLE) {
        
        //the global float step is simply 1/SWEEP_MIDDLE, and
        //allows the gain to move from 0<->1 over half the sample.
        
        //decrease Rgain
        Rgain = 1-(step*current_addr);
        //increse Lgain
        Lgain =   (step*current_addr);    
    }
    
    // for second half of sweep, shift source left->right
    if ((current_addr>SWEEP_MIDDLE)&(current_addr<=2*SWEEP_MIDDLE) ){
            //decrease Lgain
            Lgain = 1-(step*(current_addr-(float)SWEEP_MIDDLE));
            //decrease Rgain
            Rgain =   (step*(current_addr-(float)SWEEP_MIDDLE));    
    }
    
    
    
}

⌨️ 快捷键说明

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