I2S audio playback is garbled for tone and mp3 playback on Metro ESP32-P4
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
CircuitPython version and board name
Adafruit CircuitPython 11.0.0-alpha.3 on 2026-11-12; Adafruit Metro ESP32-P4 with ESP32P4
Code/REPL
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
CircuitPython I2S Tone playback example.
Plays a tone for one second on, one
second off, in a loop.
"""
import time
import array
import math
import audiocore
import board
import audiobusio
audio = audiobusio.I2SOut(board.D9, board.D10, board.D11)
tone_volume = 0.1 # Increase this to increase the volume of the tone.
frequency = 440 # Set this to the Hz of the tone you want to generate.
length = 8000 // frequency
sine_wave = array.array("h", [0] * length)
for i in range(length):
sine_wave[i] = int((math.sin(math.pi * 2 * i / length)) * tone_volume * (2 ** 15 - 1))
sine_wave_sample = audiocore.RawSample(sine_wave)
while True:
audio.play(sine_wave_sample, loop=True)
time.sleep(1)
audio.stop()
time.sleep(1)
Behavior
When playing back this tone, the audio crackles and can sound garbled. This behavior is also present with mp3 playback, which is how i first came across the issue.
here is test mp3 code:
import board
from audiomp3 import MP3Decoder
import audiobusio
mp3files = ["slow.mp3", "happy.mp3"]
mp3 = open(mp3files[0], "rb")
decoder = MP3Decoder(mp3)
audio = audiobusio.I2SOut(board.D9, board.D10, board.D11)
while True:
for filename in mp3files:
decoder.file = open(filename, "rb")
audio.play(decoder)
print("playing", filename)
while audio.playing:
pass
mp3 files are available here on learn repo: https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/main/CircuitPython_Essentials/CircuitPython_Audio_Out_MP3
Description
i tested with the max98357a stereo dac and pcm5122 line out dac to rule out a speaker issue.
Additional information
the issue is not present with wav file playback. i ran the street chicken example with both DACs:
import audiocore
import board
import audiobusio
audio = audiobusio.I2SOut(board.D9, board.D10, board.D11)
with open("StreetChicken.wav", "rb") as wave_file:
wav = audiocore.WaveFile(wave_file)
print("Playing wav file!")
audio.play(wav)
while audio.playing:
pass
print("Done!")
(wav file here: https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/PCM510x_Examples/CircuitPython_WAV/StreetChicken.wav)
and that plays clearly
- Ngôn ngữ chính
- C
- Star
- 4.6k
- Fork
- 1.4k
- Merge trung bình
- 1 ngày
- Pull request đã merge (30 ngày)
- 212
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của adafruit/circuitpython
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
adafruit/circuitpython#11877 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update Learn Guides for #11777Đang mởdocumentation rp2
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 67/100
adafruit/circuitpython#11779 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
adafruit/circuitpython#11689 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
esp32-c3 memory optimization network
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
adafruit/circuitpython#11879 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
adafruit/circuitpython#11876 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của adafruit/circuitpython
Issue tương tự
-
agent:WSL code-review linux pri:low refactoring tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
DOC BUG Missing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SDL-Hercules-390/hyperion#911 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
build: man page directory doubledCó thể đã có người làm @zeusgoose đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
ATtiny xy2: Missing #else path may lead to inconsistencies in core digital_pin_to_timer[] arrayĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SpenceKonde/megaTinyCore#1294 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ROCm/rocm-libraries#15866 ·
Maintainer thường phản hồi trong vòng 2 ngày