-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WAV file plays with pronounced click at end unless the WAV DATA is an exact multiple of 512 bytes (IDFGH-8416) #9882
Comments
HI @william-ferguson-au , I've tested your code, it seems that the clicks come from the unexpected data at the end, I monitored the signal by a logic analyzer, there are some pulses at the tail: It seems the bug of |
The pulses at the end are the legacy data in the DMA buffer that not fully cleared, due to the buffers are linked as a ring, they will be sent cyclically, that is where the pulses come from. Theoretically, the DMA buffer should be cleared when it finished sending data if Currently, you can call Another tip is, setting |
OK, I think I understand some of that. How can I get notified when the tx_desc_auto_clear fix (be7c656) get backported to 4.4 ?? I did try using i2s_zero_dma_buffer() but it wasn't working, possibly because of this other bug which is why I was writing SILENCE to the buffer. |
@L-KAYA why is DMA buffer 4092 bytes and not 4096 bytes (ie 4K)? |
the |
Answers checklist.
IDF version.
v4.4.2-312-g08fa67fe92
Operating System used.
Windows
How did you build your project?
Command line with CMake
If you are using Windows, please specify command line type.
CMD
Development Kit.
ESP32-WROOM-32
Power Supply used.
USB
What is the expected behavior?
I expected it to output both WAV files to the speaker without introducing a click at the end of the second WAV.
What is the actual behavior?
Instead it plays the first WAV file cleanly, and then plays the second WAV with a pronounced lick at the end.
Note that the 2nd WAV file is a copy of the first WAV file with a chunk of sound cut out of the middle using Audacity so that the start and end of the WAV are unchanged, only the length of the data chunk is changed.
Steps to reproduce.
Build https://github.com/william-ferguson-au/esp32-wav-failure
Flash to a board that is connected to a speaker
// Speakers I2S
#define SPEAKER_BIT_CLOCK GPIO_NUM_27 // The bit clock connection, goes to pin 27 of ESP32
#define SPEAKER_WORD_SELECT GPIO_NUM_26 // Word select, also known as word select or left right clock
#define SPEAKER_DATA_OUT GPIO_NUM_25 // Data out from the ESP32, connect to DIN on 38357A
The are 2 WAVs deployed in the SPIFFS partition.
1st WAV FILE_ON_YOUR_MARKS (wav DATA size 69120B = 67.5KB)
2nd WAV FILE_ON_YOUR_MARKS_NO_MIDDLE (wav DATA size 55932B = 54.62109KB)
Note that it loops playing the 2 WAVs. The first WAV is played correctly. The 2nd has a pronounced click at the end (you can ignore the click in the middle as this is an artifact of clipping the middle out of the WAV).
Debug Logs.
More Information.
The ONLY way that the first WAV can be played correctly is via the play_wav_file3() function.
All other functions 1-9 introduce some kind of audio glitch.
The 2nd WAV cannot be played without audio glitch in any function.
I suspect that the first WAV only plays correctly because the WAV DATA Size is an exact multiple of 512B
Note also that BOTH WAVs play correctly in Audacity as well as every other audio player I have tried.
The text was updated successfully, but these errors were encountered: