AnsweredAssumed Answered

Minimizing I2S latency

Question asked by gert vierman on Sep 30, 2017
Latest reply on Oct 19, 2017 by Carlos_Mendoza

Hi all,

 

Short version: what parameters can be tuned in the LPC43xx to minimize I2s audio latency

 

Long version:

 

I'm developing a modular synthesizer (as in musical instrument) based on a bunch of LPC4330 CPU's. Each CPU runs a dedicated DSP algorithm (oscillators, filters, wave shapers, samplers, etc) with audio in and out through a codec on the I2S bus. The user can create sounds and effects by connecting audio paths of different modules with analogue cables and tuning parameters.

 

(Check Modular synthesizer - Wikipedia for a description, for those not familiar with the concept of a modular synth)

 

The basic system is functional, but I'm not happy with the latency of the audio path. Feedback is a common concept in modular synthesis, but with the current latencies I'm experiencing it is virtually impossible to get good results.

 

My current firmware configures the I2S bus at 48Khz with the fifo size set to 1. Audio is handled in the I2S IRQ as it comes in, and is sent out in the same function. Basically, something like this:


void i2s_init(void)
{
  I2S_AUDIO_FORMAT_T conf;
  conf.SampleRate = 48000;
  conf.ChannelNumber = 2;
  conf.WordWidth = 16;

  Chip_I2S_Init(LPC_I2S0);
  Chip_I2S_RxConfig(LPC_I2S0, &conf);
  Chip_I2S_TxConfig(LPC_I2S0, &conf);
  Chip_I2S_TxStop(LPC_I2S0);
  Chip_I2S_DisableMute(LPC_I2S0);
  Chip_I2S_TxStart(LPC_I2S0);
        
  Chip_I2S_Int_RxCmd(LPC_I2S0, ENABLE, 1);
  Chip_I2S_Int_TxCmd(LPC_I2S0, ENABLE, 1);
  NVIC_EnableIRQ(I2S0_IRQn);
}

void I2S0_IRQHandler(void)
{
  if(Chip_I2S_GetRxLevel(LPC_I2S0) > 0) {
  uint32_t v = Chip_I2S_Receive(LPC_I2S0);
 Chip_I2S_Send(LPC_I2S0, v);
}

This snippet simple echoes audio on the I2S bus, input to output. The codec used is the UDA1380.

 

Total round trip latency on audio is approx 1.26 msec at this time. Unfortunately, that's way to high to do things with feedback without ending up with comb filter effects all the time.

 

Any help is very much appreciated!

Outcomes