Sound · lesson 8 of 8
A parrot that repeats you, and a live robot voice
INMP441MAX98357A + speakerMicrophone in, speaker out. Say something and the parrot says it back: normal, as a chipmunk (1.5× faster), a giant (0.7×), a robot (ring modulator + 6-bit crunch), with an echo, or reverse. Then live effects: an echo you talk into, a robot voice. The parrot is voice-activated like S4 (12 dB, 0.3 s pre-roll, 0.7 s hold, 6 s at most) and never hears itself.
Make the parrot repeat you in three voices, talk through the live echo without a howl, and explain why a chipmunk talks fast.
You're done when
- You said a word and the parrot answered in the chipmunk voice;
fx giant+againanswered deep and slow. - echo view:
echo on, a clap comes back as fading repeats, latency about 60-80 ms. - You provoked (and the guard stopped) a howl by pointing the speaker at the mic:
Howl! Move the speaker away or turn it down.
On the board
- 3V3VCC
- 3V3MICS +
- GPIO 6AO
- GPIO 7BLK
- GPIO 8RES
- GPIO 9DC
- GPIO 10CS
- GPIO 11SDA
- GPIO 12SCL
- 5VAMP VIN
- GNDGND
- GPIO 5BTN
- GNDMICS G
- GPIO 42SD
- GPIO 41WS
- GPIO 40SCK
- GPIO 39BCLK
- GPIO 38LRC
- GPIO 0BOOT
- GPIO 47DIN
- GPIO 21DO
- GNDAMP G
You will learn
- resampling = pitch + speed
- ring modulation f±c
- bitcrush
- delay + feedback
- loop gain < 1
- howl detection
- latency budget
- echo guard
uv run pio run -d labs/sound-lab-s8 -e sound-lab-s8 -t uploadParts required
Parts library- ESP32-S3-DevKitC-1 + USB-C data cable
- 1.9″ ST7789 screen
- INMP441 I²S microphone
- MAX98357A amp + speaker
The parrot, in your browser
The same effects as fx.h, in this page. An example voice is loaded; recording your own is optional and only starts when you press the button (3 s, a red indicator while it records, nothing leaves the page).
Full-duplex dual-I2S pipeline recording INMP441 speech into PSRAM and playing back pitch-shifted robot voice. The same effects as fx.h, in this page. An example voice is loaded; recording your own is optional and only starts when you press the button (3 s, a red indicator while it records, nothing leaves the page).
- Key concepts: resampling = pitch + speed, ring modulation f±c, bitcrush, delay + feedback, loop gain < 1, howl detection, latency budget, echo guard.
- Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).
Interactive diagram loads after page initialization.
What the screen shows
Four views. Click = next, double-click = the action at the bottom left (fx next, echo, robot, again), long press = record by hand / stop.
Gallery of ST7789 audio visualizers rendered across the Sound track. Four views. Click = next, double-click = the action at the bottom left (fx next, echo, robot, again), long press = record by hand / stop.
- Key concepts: resampling = pitch + speed, ring modulation f±c, bitcrush, delay + feedback, loop gain < 1, howl detection, latency budget, echo guard.
- Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).
Interactive diagram loads after page initialization.
Wiring: the microphones and the speaker (wire what the lab needs; the screen stays as in lesson 03)
| Module pin | ESP32-S3 | Notes |
|---|---|---|
| KY-037 + · G | 3V3 | The analog mic. + on the second 3V3 pin (the screen has the first), G on GND. Never 5 V: AO and DO swing up to the module's supply, and the ESP32-S3's pins take 3.3 V at most. |
| KY-037 AO | GPIO 6 | Analog out: the microphone's voltage. GPIO 6 is ADC1 channel 5: ADC1 keeps working while Wi-Fi is on, ADC2 doesn't. |
| KY-037 DO | GPIO 21 | Digital out: the LM393 comparator says high when the sound is louder than the blue trim pot's setting. |
| INMP441 VDD · GND | 3V3 | The digital mic (I2S). VDD on 3V3 (share the breadboard rail with the KY-037), GND on GND. 3.3 V only. |
| INMP441 L/R | GND | Low = it talks in the left slot, the one the board reads. |
| INMP441 SCK | GPIO 40 | The bit clock. The ESP32 drives it: 16 000 × 64 = 1.024 MHz. |
| INMP441 WS | GPIO 41 | Word select: left slot / right slot, flips every 32 clock ticks. |
| INMP441 SD | GPIO 42 | The data, most significant bit first. Pulled down, so a missing mic reads as zeros. |
| MAX98357A VIN · GND | 5V | The speaker amplifier. 5V gives the most (about 3 W into 4 Ω); 3V3 works, quieter. |
| MAX98357A BCLK | GPIO 39 | Bit clock of the second I2S port (I2S1; the mic uses I2S0, so both run at once). |
| MAX98357A LRC | GPIO 38 | Word select (left/right). |
| MAX98357A DIN | GPIO 47 | The samples, 16-bit. |
| MAX98357A GAIN · SD | nothing | Leave both unconnected: 9 dB gain, and it plays (left + right) / 2. |
| speaker (4 Ω, 3 W) | amp + / − | On the amplifier's screw terminal: the JST-PH2.0 lead's two wires, red to +. |
| screen (8 wires) | as lesson 03 | Unchanged. The push button on GPIO 5 is optional: it does what BOOT does. |
Commands, in order
Type these in the serial monitor (uv run pio device monitor) unless the grey tag says otherwise. The coloured tag says what should be near the board while it runs.
uv run pio run -d labs/sound-lab-s8 -e sound-lab-s8 -t uploadMac terminalroom quiet- Does
- Builds lab S8 and writes it to the board, then open the monitor with
uv run pio device monitor. - You should see
Listening for an INMP441 on the I2S pins...,Microphone: INMP441 (I2S, digital) (mic setting: auto)(or KY-037), thenSound lab S8 …, the command list and a three-note hello from the speaker. Stay quiet for half a second:- learning the quiet...- If not
- Wrong mic picked:
mic inmp441ormic ky037(saved, restarts). No hello: the speaker is optional; check VIN and DIN. “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
vol 25serial monitorroom quiet- Does
- Keep it low: the mic hears the speaker.
- You should see
- volume 25.- If not
- With the KY-037:
KY-037: it works, but an INMP441 sounds much clearer.
(say “hello parrot”)with your handsmake some noise- Does
- Louder than 12 dB above the quiet starts a recording with 0.3 s from before; 0.7 s of quiet ends it; then it plays back through the voice.
- You should see
- The bubble:
I'm listening..., REC, thenSquawk!with the beak moving;+ chipmunk, 1.4 s, x9 louder. - If not
too short: a bang, not a word: speak a little longer. Never starts:trigger 8.
fx next (or fx robot, fx reverse)serial monitorsound: doesn't matter- Does
- The parrot's voice: normal chipmunk giant robot echo reverse. Double-click on parrot.
- You should see
- voice: robot (ring modulator + bitcrush).
againserial monitorroom quiet- Does
- Says the last recording again with the current voice (double-click on scope).
- You should see
- The same words, another voice.
- If not
nothing recorded yet: say something first.
echo onserial monitormake some noise- Does
- Live: mic → delay line → speaker.
delay 120(20-500 ms),feedback 60(0-70 %). Needs the mic at 16 000 Hz. - You should see
! live echo: speaker away from the mic, volume low; the taps of one clap on the echo view and a latency of ~60-80 ms.- If not
- A howl: the guard stops it with a low No. Turn the speaker away, lower
volorfeedback.
robot onserial monitormake some noise- Does
- Live: your voice × a slow sine (
carrier 50, 10-300 Hz) + crunch. Every frequency f becomes f − c and f + c. - You should see
- The robot's mouth lights with what comes out.
carrier 200sounds like a bell.
Steps
0 of 6 ticked. Ticks are saved in this browser.
Changing the speed of a recording changes its pitch and its length together: that's why the chipmunk talks fast. Keeping the speed while shifting the pitch needs much more DSP (grains or a phase vocoder). Feedback: if what the mic hears comes back louder than it went out (loop gain above 1), it goes round and round: the howl. The guard cuts the live effect when the level keeps climbing (9 dB within 300 ms) or stays above −12 dBFS. Latency = one screen frame of processing + the speaker's queue + its 16 ms DMA block.
Preview: what you should see
Interactive audio lab simulator displaying live waveforms, dBFS loudness, FFT bins, and synthesized tones.
- Key concepts: resampling = pitch + speed, ring modulation f±c, bitcrush, delay + feedback, loop gain < 1, howl detection, latency budget, echo guard.
- Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).
Interactive diagram loads after page initialization.
ESP32-S3 peripherals used in this lab
Open interactive GPIO pinoutExplore the hardware blocks, pin rules, and registers behind this experiment.
- GPIO and IO MUX
45 pins, and a matrix that routes almost any signal to almost any pin
- I2S
Digital audio in and out: microphones, amplifiers, codecs
- SPI
Fast four-wire bus for screens, card readers and flash
- SAR ADC
Two 12-bit converters that turn a voltage into a number
- GDMA
Moves data between memory and peripherals without the CPU
- UART
Three serial ports, the one you see in the serial monitor
Troubleshooting & hardware gotchas
See all 17 ESP32-S3 hardware gotchas- What if it does not work or behaves unexpectedly?
- Changing the speed of a recording changes its pitch and its length together: that's why the chipmunk talks fast. Keeping the speed while shifting the pitch needs much more DSP (grains or a phase vocoder). Feedback: if what the mic hears comes back louder than it went out (loop gain above 1), it goes round and round: the howl. The guard cuts the live effect when the level keeps climbing (9 dB within 300 ms) or stays above −12 dBFS. Latency = one screen frame of processing + the speaker's queue + its 16 ms DMA block.
- If “uv run pio run -d labs/sound-lab-s8 -e sound-lab-s8 -t upload” does not work
- Wrong mic picked:
mic inmp441ormic ky037(saved, restarts). No hello: the speaker is optional; check VIN and DIN. “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again. - If “vol 25” does not work
- With the KY-037:
KY-037: it works, but an INMP441 sounds much clearer. - If “(say “hello parrot”)” does not work
too short: a bang, not a word: speak a little longer. Never starts:trigger 8.- If “again” does not work
nothing recorded yet: say something first.- If “echo on” does not work
- A howl: the guard stops it with a low No. Turn the speaker away, lower
volorfeedback. - Four pins are read at reset
- GPIO0, GPIO3, GPIO45 and GPIO46 are sampled the moment the chip comes out of reset: they pick the boot mode, the flash voltage, the ROM log and the JTAG source. Anything wired to them must not pull them the wrong way at power-up. After reset they are normal pins again.
- GPIO3 has no pull resistor at reset
- GPIO0 has a weak pull-up and GPIO45/46 weak pull-downs, but GPIO3 floats. When the eFuses make it choose the JTAG source, an outside circuit has to hold it at a clear level.
- ADC2 stops working while Wi-Fi is on
- The ADC2 channels (GPIO11-20) cannot be used at the same time as Wi-Fi: the radio shares ADC2 through an arbiter. Put analog sensors on ADC1 (GPIO1-10), as the sound labs do with GPIO6.
- GPIO47 and 48 run at 1.8 V on R16V modules
- Modules with the ESP32-S3R16V chip set the flash voltage to 1.8 V, and GPIO47/48 share that supply. A 3.3 V part on those pins sees the wrong levels.