Feeling dense... just want to be able to on demand play a wav file stored in SPIFFS I2S to Internal DAC #1734
-
I have spent a few days playing with this and just am not getting it. Feeling very dense (and tired). I have an app where I occasionally need to play a wav file as an audible warning message. (I do not want it continuously playing). I want to use I2S and the internal DAC on an ESP-WROOM-32 (actually, a "Cheap Yellow Display" board). It only has DAC_channel_2 (GPIO_26) going to the on-board single-channel analog amplifier. Also, everything I have been able to get even a little "going" using I2S and the internal DAC leaves the DAC outputting a bit of noise all the time. How can I "kill" the DAC between the times that I want to output my wav file so that there is no ambient noise coming out the speaker. (If I don't start the I2S and DAC, I don't get any noise so I know the source of the noise is the active DAC). (I have tried many things to do this but so far have not found any that work). Is there an example of this that I can study? (I am using platform = [email protected]) |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Your description is quite confusing: either you use I2S with an extrernal DAC or the Analog API for the internal DAC! I am also not sure with what you mean with [email protected]: the latest IDF release is 5.3! What sketch are you using ? |
Beta Was this translation helpful? Give feedback.
-
Well let's se if I can clarify... I think in Shatzman-speak, routing the
I2S to the internal DAC is what you CALL "Analog-API"
I have not found an example yet that does what I want to do but I imagine
it exists in your extensive catalog of examples. I just have not found it
yet...
Objective: buffer using I2S, route to DAC, output through that path a wav
file on demand, not continuously.
I am using Platformio on Visual Studio Code and the most current rev of the
espressif32 platform is higher than 6.5 but that changed a lot of things
that broke a lot of my projects so I lock down to that rev for most of my
projects.
…On Sat, Oct 5, 2024, 4:46 PM Phil Schatzmann ***@***.***> wrote:
Your description is quite confusing: either you use I2S with an extrernal
DAC or the Analog API for the internal DAC!
If you are done with the output just call end to close the interface.
Alternatively you can continue to send out silence...
I am also not sure with what you mean with ***@***.***: the latest
IDF release is 5.3!
What sketch are you using ?
What development platform are you using ?
—
Reply to this email directly, view it on GitHub
<#1734 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANQI5JU7SJ7VC7TAYQUKXZ3Z2BMZ7AVCNFSM6AAAAABPNVWH4SVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAOBVGUYDCMA>
.
You are receiving this because you authored the thread.Message ID:
<pschatzmann/arduino-audio-tools/repo-discussions/1734/comments/10855010@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Hi Phil. Thanks again for your reply.
Sorry if I caused confusion... regarding framework, I am using arduino
framework... in platformio.ini:
platform = ***@***.***
board = esp32dev
framework = arduino
I will definitely study the Codecs section. Thank you for that pointer.
I understand the benefits of using a MemoryStream for the sound data for
many applications. In the case of the current application that I am
working on, we have a concrete reason for keeping the wav files in SPIFFS
and separate from the code. In managing our over-the-air updates, we can
choose to push either an update to files saved in SPIFFS or an update to
the firmware. Separating the language-specific files (including the sound
files) allows us to reduce over-the-air update times significantly. Also,
maintaining the language-specific files (including sound files) in the
SPIFFS space allows us to manage country or language specific units in the
field based on the SPIFFS files while maintaining a single version of the
core firmware across the entire fleet devices.
Thanks again,
Pete
…On Sat, Oct 5, 2024 at 8:53 PM Phil Schatzmann ***@***.***> wrote:
The last releases with the old I2S API was in Arduino ESP 2.0.16 which
used IDF 4.4.7
Since Arduino ESP 3.0 with IDF 5 there is a new I2S API for external DACs
and separate analog APIs for the internal DAC and ADC!
I suggest to use Arduino Framework instead of espidf directly as described
in the Wiki "How to use PlatformIO". You were not clear on this.
In this case, there is no separate simple SPIFFS example necessary since
this is just one of the many options how to manage files in Arduino with
the ESP32. Just try to understand the chapter about Codecs.
To make your sketch simple, I suggest to consider to use a MemoryStream
and to convert and load your file to flash memory instead.
—
Reply to this email directly, view it on GitHub
<#1734 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANQI5JSMOCVNLHCW7PYCUTLZ2CJ3DAVCNFSM6AAAAABPNVWH4SVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAOBVGU4DEMQ>
.
You are receiving this because you authored the thread.Message ID:
<pschatzmann/arduino-audio-tools/repo-discussions/1734/comments/10855822@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
I have a solution, though it seems more complex than it should... first, I solved the issue of a slight hum from the internal DAC output. After trying all of these things...
I finally settled on disabling the DAC after the wav file completes playing by using:
and re-enabling the DAC each time I play a wav file (see playWAV below) (the Cheap Yellow Board only has one audio output channel... DAC_CHANNEL_2) This led me to creating two functions: In this sample code, I just play the next file in a list of files. In "real life" there are other things I would do after the wav playing was completed. The point is that I wanted a way to play selected wav files from SPIFFS on demand with the loop() of my code and have the speaker absolutely quiet the rest of the time. I am VERY WELCOME to getting input for simpler ways of doing this remembering the objectives:
So, here is the test code...
|
Beta Was this translation helpful? Give feedback.
-
If I understand EncodedAudioStream, as in this example: stream-memory_wav-pwm.ino, then I have to provide the size and bit depth of each file into the code whereas the player using WAVdecoder figures that out for itself. That of course helps the goal of keeping the field deployment/updating easy. Towards you advice to "end" the AnalogAudioStream, if I understand correctly, where I have used AnalogAudioStream out; then I would just use out.end(); correct? I avoid opening and closing (beginning/ending) objects repeatedly for fear of unknown memory leaks catching up with me, but I'll give it a go. In re noisy power supply, that certainly is likely but not something that can be fixed to the level of total silence in the application. The nature of the power in the countries were we will deploy these devices is deplorable to start with and to the extent that the noisy power does not otherwise effect the processor and display, disabling the DAC while not playing the waves is a very workable solution. the AudioSourceCallback is nice but I playing the files in sequence was just used in my test code to show that I could call different files, not necessarily in a set sequence. In fact, in the app, the objective is to play sounds (announcements) based on the state of the system... You have created a very rich tool here which I imagine I will revisit many times over the years for various projects. I am just nibbling off a bit for a specific project now. Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Thanks Phil. That's great and it runs a bit faster. I appreciate your patience as I learned this. I am just stuck on one last thing... how to set the volume. And I just found this example https://github.com/pschatzmann/arduino-audio-tools/wiki/Volume-Control so I will work through that... Here is the code I have now.
|
Beta Was this translation helpful? Give feedback.
Your description is quite confusing: either you use I2S with an extrernal DAC or the Analog API for the internal DAC!
If you are done with the output just call end to close the interface. Alternatively you can continue to send out silence...
I am also not sure with what you mean with [email protected]: the latest IDF release is 5.3!
What sketch are you using ?
What development platform are you using ?