Skip to content

Commit 0cc1ca0

Browse files
update audio
1 parent 4bbe81f commit 0cc1ca0

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

tests/manual_test_duplex_audio.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
"""Minimal duplex I2S proof-of-concept for Fri3d 2024.
1+
"""Minimal duplex I2S test for Fri3d 2024 with communicator.
22
33
Creates TX + RX I2S instances simultaneously using merged pin config
44
from the fri3d_2024 board setup. Intended for quick validation only.
5+
6+
To get this working, the I2S needs to be changed, see plan at https://github.com/orgs/micropython/discussions/12473
57
"""
68

79
import time
@@ -42,15 +44,10 @@ def _init_write(self):
4244
bits=16,
4345
format=machine.I2S.MONO,
4446
rate=self.sample_rate,
45-
ibuf=8000,
47+
ibuf=16000,
4648
)
4749

48-
49-
def _init_i2s(self):
50-
if not _HAS_MACHINE:
51-
raise RuntimeError("machine.I2S not available")
52-
53-
# self._init_write()
50+
def _init_read(self):
5451
self._rx = machine.I2S(
5552
1,
5653
sck=machine.Pin(I2S_PINS["sck_in"], machine.Pin.OUT),
@@ -60,9 +57,16 @@ def _init_i2s(self):
6057
bits=16,
6158
format=machine.I2S.MONO,
6259
rate=self.sample_rate,
63-
ibuf=8000,
60+
ibuf=16000,
6461
)
6562

63+
def _init_i2s(self):
64+
if not _HAS_MACHINE:
65+
raise RuntimeError("machine.I2S not available")
66+
67+
self._init_read()
68+
self._init_write()
69+
6670
def _deinit_i2s(self):
6771
if self._tx:
6872
self._tx.deinit()
@@ -81,7 +85,7 @@ def run(self):
8185
t_end = time.ticks_add(time.ticks_ms(), self.duration_ms)
8286

8387
while time.ticks_diff(t_end, time.ticks_ms()) > 0:
84-
#self._tx.write(tone)
88+
#self._tx.write(tone) # works but saturates the microphone
8589
read_len = self._rx.readinto(read_buf)
8690
if read_len:
8791
recorded.extend(read_buf[:read_len])

0 commit comments

Comments
 (0)