Analog audio is without doubt the least painful one. USB audio is not an option, because you would not be able to maintain the low-latency of Bela (though you could in principle load the audio cape overlay and use the Bela cape via ALSA/Jack, but then you would lose access to the analog I/O and all the Bela programming environment).
In principle I2S should be doable, and also an interesting application. Getting that to work would require some changes in:
- the McASP configuration (lines 779-846 in pru_rtaudio.p
, perhaps more),
- the Bela TLV320AIC3104 codec configuration (core/I2c_Codec.cpp
and core/RTAudio.cpp
), described here.
- possibly the Teensy I2S configuration.
The Beaglebone's McASP (Multi-channel audio serial port) is described in detail in the am335x technical reference manual. It allows plain I2S mode, as well as TDM (time-division multiplexing), to host up to 32 channels per port, possibly from multiple devices/codecs, assuming all devices/codecs support it. There are three clocks (interface clock, frame clock, bit clock) which you will need to configure properly (I think currently the McASP generates the interface clock, but the frame clock and bit clock are generated by the TLV320AIC3104 codec and sent back into the McASP.
0) So, the normal situation on Bela is
I2S I2S
Bela codec --> McASP --> Bela code --> McASP --> Bela codec --> analog outs
1) You would probably use the Teensy's I2S output into the BBB's McASP, but then use the TLV320 codec for the final analog output:
I2S I2S
Teensy codec --> McASP --> Bela code --> McASP --> Bela codec --> analog outs
2) If TDM is available on the Teensy codec, you could even figure out a way to do:
TDM (slots2-3)
Teensy codec ------->| TDM
| McASP --> Bela code --> McASP --> Bela codec --> analog outs
Bela codec ------->|
TDM(slots0-1)
3) You could also explore the possibility of sending the Bela audio out back over I2S to the Teensy codec, if you can then send it to the analog output there (it seems unlikely to me that this is possible, but I know nothing about the Teensy). If this option would work, it could simplify things as you could simply disable the TLV320 codec and only deal with one codec (the Teensy's) on the McASP, however it requires some "magic" (loopback?) on the Teensy.
I2S I2S
Teensy codec --> McASP --> Bela code --> McASP --> Teensy codec --> magic happens -->analog outs
In cases 1) and 3), the Bela audio code would not see any change with respect to 0). In case 2), you would have to make it aware of the extra audio inputs (as you would have 4!).