-
|
I cannot find any way to play any sounds correctly! Right now I'm using a AI generated program and it sounds close-ish to the actual sound but it's not quite right. I attached the program I'm using. Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
|
To be honest, we just need to switch to C, python won't work for this. |
Beta Was this translation helpful? Give feedback.
-
|
Yes. If we can find one that can be built with ESP-IDF, then we can compile
it into the firmware.
|
Beta Was this translation helpful? Give feedback.
-
|
This code kinda works but still not quite there: import uasyncio as asyncio
import struct
import wave
import machine
import gc
machine.freq(240000000)
class WavPlayer:
def __init__(self, file_path, dac_pin=25, volume=1):
self.file_path = file_path
self.dac = machine.DAC(machine.Pin(dac_pin))
self.buffer_size = 1024
self.volume = volume
async def play(self):
with wave.open(self.file_path, 'rb') as wav:
assert wav.getsampwidth() == 1 # 8-bit audio
assert wav.getnchannels() == 1 # Mono audio
assert wav.getframerate() == 8000 # Sample rate
while True:
data = wav.readframes(self.buffer_size)
if not data:
break
for sample in data:
self.dac.write(round(sample*self.volume))
await asyncio.sleep(1/8000)
gc.collect()
if __name__ == "__main__":
player = WavPlayer(FILENAME)
asyncio.run(player.play()) |
Beta Was this translation helpful? Give feedback.
-
|
It seems kind of simple, but I would have no idea how to actually do anything here lol |
Beta Was this translation helpful? Give feedback.
-
|
I think the T-deck has a built in I2C audio driver! If it does, then there are a lot of drivers for that. PS. I didn’t write all that code, AI did. 😀 |
Beta Was this translation helpful? Give feedback.
-
|
I have a working driver that can play .wav files. I will upload it to the repository soon. |
Beta Was this translation helpful? Give feedback.
-
|
Oh wow that's awesome! Glad to know!
…________________________________
From: Nathanael Asher ***@***.***>
Sent: Tuesday, March 25, 2025 7:44 AM
To: MicroOS-Project/microOS ***@***.***>
Cc: Respite09 ***@***.***>; Comment ***@***.***>
Subject: Re: [MicroOS-Project/microOS] Need Sound! Help!! (Discussion #5)
I have a working driver that can play .wav files. I will upload it to the repository soon.
—
Reply to this email directly, view it on GitHub<#5 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BC7557HQK3HBC3FA5NADJ2T2WFTTHAVCNFSM6AAAAABQTRWZAKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRRGYZTEMQ>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
I think the T-deck has a built in I2C audio driver! If it does, then there are a lot of drivers for that.
PS. I didn’t write all that code, AI did. 😀