cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746G-DISCO

avram
Associate
Posted on January 14, 2016 at 10:11

Hello,

I'm using STM32F746G-DISCO Audio Record and Playback example. In loopback mode I want to apply an echo effect to the input buffer before sending it to the output.

The code is as follows:

int main(void)

{

  /* Enable the CPU Cache */

  CPU_CACHE_Enable();

 

  /* STM32F7xx HAL library initialization:

       - Configure the Flash ART accelerator on ITCM interface

       - Configure the Systick to generate an interrupt each 1 msec

       - Set NVIC Group Priority to 4

       - Global MSP (MCU Support Package) initialization

     */   

  HAL_Init();

 

  /* Configure the system clock to 216 MHz */

  SystemClock_Config();

  /* Init Audio Application */

  AUDIO_InitApplication();

 

  /* Init TS module */

  BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());

  /* Init Host Library */

  USBH_Init(&hUSBHost, USBH_UserProcess, 0);

  /* Add Supported Class */

  USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);

 

  /* Start Host Process */

  USBH_Start(&hUSBHost);

 

  /* Run Application (Blocking mode) */

    

    BSP_AUDIO_IN_OUT_Init(INPUT_DEVICE_INPUT_LINE_1, OUTPUT_DEVICE_HEADPHONE, 50, 48000);

    

    BSP_AUDIO_IN_SetVolume(80);

    BSP_AUDIO_OUT_SetVolume(70);

    

    BSP_AUDIO_IN_Record(in_buffer, SIZE_BUFFER);

    BSP_AUDIO_OUT_Play(out_buffer, SIZE_BUFFER * 2);

     

    while(1){

        while(in_ready == 0); //when input buffer is full

        echo(); //apply echo effect

        ready_transfer = 0; //flag for buffer ready to be sent at output

        BSP_AUDIO_IN_Resume();

    }

}

This the echo function:

void echo(){

    volatile int aux;

    for(i=0;i<SIZE_BUFFER;i++){

        aux = in_buffer[i];

        aux = aux/2;

        aux += delay_buff[j];

        aux = aux/2;

        out_buffer[i] = aux;

        j=(j+1)%DELAY_SIZE;

    }

}
2 REPLIES 2
Posted on January 14, 2016 at 19:42

I guess you'd need to look at what callbacks are being used to manage the buffer, and insert your code somewhere in there. If it's not using callbacks, perhaps you can enable them.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
avram
Associate
Posted on January 25, 2016 at 10:21

I already tried using the callbacks for managing the buffer but the output doesn't generate the proper sound. I also tried another function instead of the echo effect. This sends only half of the input buffer to the output. This effect works properly but I can't figure out why the echo effect I've mentioned about, isn't applied.

This is the function that sends half the input buffer to the output:

void effect(){

    volatile int i =0;

    for (i = 0; i < SIZE_BUFFER; i++)

    {

        if(i < SIZE_BUFFER / 2)

            out_buffer[i] = in_buffer[i];        

        else

            out_buffer[i] = 0;

    }

}