This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Insert Audio Algorithm here! 5535 eZdsp and Connected Audio Framework

Hello,

I am having a hard time trying to find out how to modify, or insert code in the example project included in the Connected Audio Framework. 

In the app_audio_alg.c file it says clearly where to /* Insert Playback algorithm here */  ... Nevertheless, I cannot seem to know what code to insert there. 

My guess was that, same as in the Teaching ROM, there would be some LeftInput and RightInput quantity, that could be bypassed or modified, to then be given to a task for the codec, such as Codec_write for instance. 

It turns I have been scratching the thing and I am more confused than in the beginning. 

Anyone, a hint or sample algorithm using the methods and functions included in this framework? All I want is to have audio coming from the USB, manipulate it and take it out the Codec and vice versa. 

Thanks!

  • Hi;

    I'm headed down a similar road; I might start with the framework, but the final design will be using the board stand-alone to process audio in from mikes and play to headphones. I'd be very interested in what you find out, as I see the same problem - "insert something here" - my middle finger didn't work, so I'm interested in a tangible example. Ideally, FFT the data, filter it, then IFFT it back. I'd be glad the share notes with you.

    I just got the board, so I'm not very far down the learning curve yet. I'd rather not get bogged down with the io stuff, rather concentrate on the processing in between.

    Dave Wicker

  • Hi Dave and Roberto,

    The current audio framework does not have any audio algorithm in place. The idea is that TI provides the framework which handles the USB audio class protocol, I2S with DMA and the audio codec configuration. Customers can integrate their own audio processing algorithms easily. I am sorry for the confusion of the "Insert your own algorithm here". I am trying to explain how it works:

    1. There two places where you insert you audio processing algorithm. One is in RecAudioAlgTsk() (marked with "Insert Record audio algorithm here") and the other is in PbAudioAlgTsk() (marked with "Insert Playback audio algorithm here")

    2. RecAudioAlgTsk() is the recording side. It handles the mic/line-in. The data to be processed is in recOutLeftBuf and recOutRightBuf (if it is stereo). the number of audio samples is RXBUFF_SZ_ADCSAMPS and 32 bit per sample (2 16-bit words). Your audio processing algorithm is responsible for modifying those samples as your wish and put it back in the same buffers and keep the number of audio samples the same. The audio frameworks will take from there and send the data to the USB host.

    3. PlayAudioAlgTsk() is the playback side. It handles the speaker/line-out. The data to be processed is in pbOutBufLeft and pbOutRightBuf (if it is stereo). the number of audio samples is numOutSamps and 32 bit per sample (2 16-bit words). Your audio processing algorithm is responsible for modifying those samples as your wish and put it back in the same buffers and keep the number of audio samples the same. The audio frameworks will take from there and send the data to the audio codec.

    4. One thing to keep in mind is the audio processing time of your algorithm has to be less than the time for the DMA to fill in the ping-pong buffer which is RXBUFF_SZ_ADCSAMPS or numOutSamps samples. make sure your alogrithm can finish the processing before the next buffer is ready to process.

    Hope this help your development.

    Best regards,

    Ming Wei

  • Wow Ming Wei!

    This is genius!, thanks for your comprehensive reply, now I got a much better sense of it, and came out with a simple test for this procedure. I include it here for future references:

    In the section of "Insert Playback audio algorithm here"

            /*                                                                    */
            /* Insert Playback audio algorithm here */
            /*                                                                     */
            int i;
            for (i = 0; i < numOutSamps; i++){
    
            	*pbOutBufLeft = (*pbOutBufLeft) * 0;
            	*pbOutBufRight = (*pbOutBufRight)/2;
    
            	 pbOutBufLeft += 2;
            	 pbOutBufRight += 2;
            }
            /*****************************************/

    Cheers!

  • However!

    A new question arises!

    If the samples are 32 bits, why are they stored in an Int16 location? when looping as in my previous reply, I have to increase the value of the pointer by 2, to account for this. 

    This causes number of questions, such as how to perform operations on these numbers, or to add them with other samples as in a filter algorithm. 

    Then, if we use for example a long value to store the addition of two samples, and then try to fit it back into the buffer which is... Int16? 32? bits, see the doubt?

    At the moment I try to add *pbOutBufLeft with another Int16, put it into a "long" location and then divide it by two, to then cast it to Int16 and fit it again in *pbOutBufLeft... but then I think about the 32 bits...

    Any word on this will be much appreciated. 

    Best

    roberto

  • Hi Roberto,

    The actual bit per sample in the audio framework is 16 bit, but it sets to 32 bit per sample simply because of the way I2S with DMA works. The maximum number of bits per sample supported in C55x5 I2S is 32. The data transmitted by the DMA from I2S register is 32 bit per sample, no matter how many actual bits per sample is. The C55x5, on the other hand is a 16-bit machine, so the 32 bit per sample will be stored in two 16 bit words.

    In the case of 16 bit per sample, the first word of a audio sample is the actual audio data and the second word is filled in with zero. It can be changed by the by setting I2S from left adjustment (current setting) to right adjustment. In your playback algorithm, you should always set  the second 16-bit word to zero. in your record algorithm, you should ignore the second 16-bit word.

    To get to 24 or 32 bit per sample case, you will have to change the audio codec settings, I2S settings and USB settings to get there. In those cases, the second 16-bit word have been used for store the 16-23 bit or 16-31 bit. Only then, you will need 32 bit operation to process those audio samples.

    Best regards,

    Ming

      

  • Good!

    Thanks again Ming, this also clarifies a lot, I figured it all had to do with the machine being 16 bits, however I also imagined the actual sample was larger than 16bits. 

    Well, now with these concepts, altogether with the Teaching Rom, I have been exploring this framework.

    Thanks a lot... again! Best!

    Roberto