🛠 Chaîne audio 44,1 kHz : Audio Library, Design Tool, I2S, S/PDIF et sortie MQS

Teensy 4.0 · avance · Schéma : IMG-teensy-40-avance-8-teensy40-audio-44k-design-tool.svg — Teensy 4.0 avec Audio Shield empilé (rappel : broches déplacées sur Rev B, résistance 100 Ω sur MCLK) ; en médaillon la fenêtre du Design Tool PJRC avec un graphe de flux (générateur → filtre → sortie) exporté en code Arduino ; à droite les broches I2S, S/PDIF et la sortie MQS.

Objectives

The Teensy is the reference platform for DIY pedals and synths thanks to the Teensy Audio Library and its graphical Audio System Design Tool (https://www.pjrc.com/teensy/gui/): you draw a signal flow graph by drag-and-drop, and the tool EXPORTs functional Arduino code. The 600 MHz M7 and its DSP instructions enable real 44.1 kHz stereo. On the hardware side: 2 I2S/TDM ports (8 I2S channels / 16 TDM), independent S/PDIF inputs/outputs, and the MQS "Medium Quality Sound" output for direct speaker connection. Watch out for Audio Shield revisions: this is THE historical pitfall when moving from 3.x to 4.0.

Hardware

The Shield Revision Trap

Audio signals changed pins between Teensy 3.x and 4.0: the original Rev B shields do NOT work directly — you must add wires AND a 100 Ω series resistor on MCLK; Rev C only added the resistor; only Rev D natively routes the Teensy 4.0 (source: forum thread, Paul Stoffregen).

Complete Code (Generatable by the Design Tool)

// 440 Hz stéréo via l'Audio Shield — le graphe décrit ici est
// exactement ce que produit le Design Tool par glisser-déposer.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>

AudioSynthWaveformSine sine;
AudioOutputI2S         sortie;
AudioConnection        patchDroite(sine, 0, sortie, 0);
AudioConnection        patchGauche(sine, 0, sortie, 1);
AudioControlSGTL5000   codec;

void setup {
  AudioMemory(10);            // pool de blocs audio — sans lui, rien ne sort
  codec.enable;
  codec.volume(0.5);
  sine.frequency(440.0);
  sine.amplitude(0.3);
}

void loop { }   // tout tourne dans les interruptions audio

Expected Verification

A clean 440 Hz tone comes out in the headphones. Open the Design Tool: add an EffectReverb, an EffectFilterLowPass, a WAV file read from the SD card (the 8 SDIO pads on the back, SD.begin(BUILTIN_SDCARD)), export, and compare the generated code with yours — that is the whole point of the tool. Under load, check the remaining CPU headroom (the tool estimates the graph load): the M7 handles reverb + EQ + delay simultaneously.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials