i everyone,
I’m building a simple looper on Teensy 4.1 + Audio Shield, using BUILTIN_SDCARD with the Teensy Audio Library:
Everything is stable most of the time (CPU ≈ 3–40%, mem 3–6/80), but at the exact moment overdub recording starts, I still see a very short spike:
Question:
Do you have architectural suggestions or proven patterns for simultaneous SD playback + SD recording with AudioPlaySdRaw/AudioRecordQueue on Teensy 4.1 (BUILTIN_SDCARD), to avoid this initial CPU/memory spike?
Examples of ideas I’m considering (but not sure what’s best):
I’m building a simple looper on Teensy 4.1 + Audio Shield, using BUILTIN_SDCARD with the Teensy Audio Library:
- AudioInputI2S (guitar on line-in)
- AudioEffectFreeverb for monitoring only
- AudioRecordQueue for recording
- AudioPlaySdRaw for playback (MASTER + OVERDUB)
- First button press: record 5 seconds MASTER to MASTER5.RAW on SD, then loop it with AudioPlaySdRaw.
- Second press: go to ARM_OVR – I prepare OVER5.RAW in advance (delete + SD.open()), no SD work at loop boundary.
- On next MASTER loop restart: start 5 seconds OVERDUB recording to OVER5.RAW while MASTER plays.
- After that, play MASTER + OVERDUB in sync, both looped from SD.
Everything is stable most of the time (CPU ≈ 3–40%, mem 3–6/80), but at the exact moment overdub recording starts, I still see a very short spike:
- cpuMax jumps above 200%
- memMax hits 80/80 blocks
- audible click/glitch right at overdub start
- Recording DRY only from lineIn (no reverb in the record path).
- Preparing the overdub file (SD.remove + SD.open) before the loop boundary.
- Limiting SD writes in loop() to a small number of blocks per iteration (e.g. max 4 blocks from AudioRecordQueue).
- Using AUDIO_MEMORY_BLOCKS = 80 (Teensy 4.1).
Question:
Do you have architectural suggestions or proven patterns for simultaneous SD playback + SD recording with AudioPlaySdRaw/AudioRecordQueue on Teensy 4.1 (BUILTIN_SDCARD), to avoid this initial CPU/memory spike?
Examples of ideas I’m considering (but not sure what’s best):
- Different way to drain AudioRecordQueue (e.g. using an ISR / dedicated task instead of loop()?).
- Using SdFat with custom buffering instead of the built-in SD wrapper.
- Reducing block size / sample rate / changing AudioMemory strategy.
- Any example projects of a stable “SD looper with overdub” on Teensy 4.x?