AnsweredAssumed Answered

STM32F746G-DISCO

Question asked by avram.oana on Jan 14, 2016
Latest reply on Jan 25, 2016 by avram.oana
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;
    }
}

Outcomes