Skip to content

Comments

Add I2S Slave Support For Teensy 4.0#38

Draft
bthayer3 wants to merge 2 commits intochipaudette:masterfrom
bthayer3:addI2SslaveInput
Draft

Add I2S Slave Support For Teensy 4.0#38
bthayer3 wants to merge 2 commits intochipaudette:masterfrom
bthayer3:addI2SslaveInput

Conversation

@bthayer3
Copy link

@bthayer3 bthayer3 commented Feb 15, 2026

Looks like the AudioInputI2Sslave_F32 is targeting an older teensy 3 board. Add a new logic section to support Teensy 4.0 board. I compared the logic used in the PJRC audio library and added this logic more so as an educated guess. It my testing it does work with some glitches though, I am probably testing this all wrong though as I don't have an oscilloscope.

Probably would also need the design tool with this i2sslaveinput drag and drop element. Didn't add that code yet as I think this slave code needs more work.

For reference: this is the code I was using in the Arduino sketch when I tested this. I was sending over 16 bit at 48 khz:

#include "OpenAudio_ArduinoLibrary.h"
#include "AudioStream_F32.h"
#include "USB_Audio_F32.h"
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2Sslave_F32       audioInI2S1;
AudioOutputUSB_F32           audioOutUSB1;
AudioConnection_F32          patchCord1(audioInI2S1, 0, audioOutUSB1, 0);
AudioConnection_F32          patchCord2(audioInI2S1, 1, audioOutUSB1, 1);

void setup() {
  AudioMemory(30);  
  AudioMemory_F32(30);
}

void loop() {
}

@boblark
Copy link
Collaborator

boblark commented Feb 18, 2026

I confess to being unqualified in this area of the code! So some random thoughts.
I think we can get 16-bit code by borrowing from the work of the I16 library. But, that leaves up to 8-bits that may be available and within the dynamic range of floating point. We also have this issue with the non-slave quad input as well. Does this seem right?
Alternatively, we can restrict the slave input to 16-bits resolution?
The need for slave seems less with 4.1 than 3.6 as the I2S clock generation is both more accurate and can do all the frequencies we need, I think. Thoughts?
Bob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants