update_playlist.c

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

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

// at end of sample in flash, reset the byte-address, and cue the LED sweep routine
void UpdatePlaylist(void)
{
    Csample* SampleP;
    
    //update address for each all valid audio clips
    for(SampleP=FirstSample; SampleP!=0; SampleP=SampleP->Next){  
        //increment current byte address by two (16-bit samples)
        SampleP->CurrentAddr+=2;
    }

    //First clip in list is always accessed circularly, so at end of clip
    //wrap pointer to beginning and resynchronize LED sweeping.
    if( (FirstSample->CurrentAddr - FirstSample->StartAddr) >= FirstSample->Bytes){
            
            FirstSample->CurrentAddr = FirstSample->StartAddr; 
            start_sweep = 1;                                   
            sweep_count++;
    }
    
    
    //after the second sweep, play back the other ("all systems go") audio sample
    //by adding another Csample to the linked list.
    if ( sweep_count == 3 ) {
        sweep_count++;
        SampleP=FirstSample;
        //find end of playlist
        while(SampleP->Next) SampleP=SampleP->Next;
        
        //create new sample descriptor on the heap and add to end of list
        SampleP->Next=(Csample*)malloc(sizeof(Csample));
        
        //init that new descriptor
        SampleP->Next->StartAddr   = 0x1060000;
        SampleP->Next->CurrentAddr = 0x1060000;
        SampleP->Next->Bytes       = 111180;
        SampleP->Next->Next        = 0;
    }


    

    //after the third sweep, remove the other clip from playlist
    if ( sweep_count > 4 ) {

        SampleP=FirstSample;
        //find end of list.  Move through list until you point at a descriptor with
        //a Next value == 0), then erase pointer to that descriptor.       
        while(SampleP->Next->Next) SampleP=SampleP->Next;
        //delete last node               
        SampleP->Next = 0;
    }
}
        


⌨️ 快捷键说明

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