From 0cc1ca0ff42c986444fb9176d9fd75c4e6109454 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Wed, 25 Feb 2026 14:29:13 +0100 Subject: [PATCH] update audio --- tests/manual_test_duplex_audio.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/manual_test_duplex_audio.py b/tests/manual_test_duplex_audio.py index a7ac12cc..f1f2c707 100644 --- a/tests/manual_test_duplex_audio.py +++ b/tests/manual_test_duplex_audio.py @@ -1,7 +1,9 @@ -"""Minimal duplex I2S proof-of-concept for Fri3d 2024. +"""Minimal duplex I2S test for Fri3d 2024 with communicator. Creates TX + RX I2S instances simultaneously using merged pin config from the fri3d_2024 board setup. Intended for quick validation only. + +To get this working, the I2S needs to be changed, see plan at https://github.com/orgs/micropython/discussions/12473 """ import time @@ -42,15 +44,10 @@ class DuplexI2STest: bits=16, format=machine.I2S.MONO, rate=self.sample_rate, - ibuf=8000, + ibuf=16000, ) - - def _init_i2s(self): - if not _HAS_MACHINE: - raise RuntimeError("machine.I2S not available") - - # self._init_write() + def _init_read(self): self._rx = machine.I2S( 1, sck=machine.Pin(I2S_PINS["sck_in"], machine.Pin.OUT), @@ -60,9 +57,16 @@ class DuplexI2STest: bits=16, format=machine.I2S.MONO, rate=self.sample_rate, - ibuf=8000, + ibuf=16000, ) + def _init_i2s(self): + if not _HAS_MACHINE: + raise RuntimeError("machine.I2S not available") + + self._init_read() + self._init_write() + def _deinit_i2s(self): if self._tx: self._tx.deinit() @@ -81,7 +85,7 @@ class DuplexI2STest: t_end = time.ticks_add(time.ticks_ms(), self.duration_ms) while time.ticks_diff(t_end, time.ticks_ms()) > 0: - #self._tx.write(tone) + #self._tx.write(tone) # works but saturates the microphone read_len = self._rx.readinto(read_buf) if read_len: recorded.extend(read_buf[:read_len])