chaining i2s input & output

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Hannu
Senior User
Posts: 400
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: chaining i2s input & output

Post by Hannu »

There is only one physical I2S interface and it gives you left and right. You can easily write something like below when correct AUXI2S* is loaded

Code: Select all

#define SAMPLES 16
s_int16 buf[SAMPLES*2];
/* Make sure lL + rL <= 1.0 and lR + rR <= 1.0 so no overflow can happen. */
double lL, rL, lR, rL;
void mix() {
  s_int16 i, *l = buf, *r = buf+1, lMix;
  fread(buf, 2, SAMPLES, stdaudion);
  for (i = 0; i < SAMPLES; i++) {
    lMix = (s_int16)(*l*lL + *r*rL);
    *r = (s_int16)(*l*lR + *r*rR);
    *l = lMix;
    l += 2;
    r += 2;
  }
  fwrite(buf, 2, SAMPLES, stdaudioout);
}
Post Reply