libDaisy
libDaisy copied to clipboard
WavPlayer digital clicks/playback issues
Reported on the forum; seems like something to do with Prepare is causing audio to be held up, and interferes with the callback in general.
This was demonstrated by generating a low freq. oscillator tone while running the WavPlayer and hearing some digital artifacts.
@stephenhensley hello! reporting back on this:
i've seemed to fix the problem by setting the buffer array as a global object with the DSY_SDRAM_BSS attribute like so:
#define BUFSIZE 4096
int16_t DSY_SDRAM_BSS buffer[BUFSIZE];
and by modifying the Init, Prepare and Stream methods of WavPlayer to be able to receive this array as an argument and thus modify it in real time. the clicks are now gone! yippie!
it doesn't seem like the attribute can be added directly on the class property buffer buff_ so i will simply use this method from now on locally :)
would it be a good idea to start a pull request to address this bug with my fix? i could also change the DaisyExamples entry to reflect the changes if we go forward with this
Hey @netherwaves this is a really interesting update. Thanks for sharing
When the buffer was internal to the WavPlayer, what memory section did you have it in? Was it just declared globally?
I'm generally a fan of portable buffers within libDaisy to changing sizes, and using other sections without having to have the object's logic data in the other memory. So I'd be open to a PR to change this.
However, it does make me wonder if there's some issue with the classes use of that buffer possibly overflowing beyond the size of the buffer or something. In which case, the portable buffer would just make it a bit more difficult to notice it.
@stephenhensley
When the buffer was internal to the WavPlayer, what memory section did you have it in? Was it just declared globally?
ah! so you mean it would be an idea to try something like this then:
WavPlayer DSY_SDRAM_BSS sampler;
this isn't something i had thought of, and yes you're right, it's been declared globally all this time, since i've been using the DaisyExamples entry as a boilerplate. although i just tried it and it doesn't fix the problem... if anything, the clicks are now even louder and steady than before :p dismembering the buffer itself is still what seems to work best for me
+1 to this issue, when I use the example .wav playback with no modifications, and an SD card with a 1kHz full scale sine tone .wav file (16 bit, 48kHz) I see and hear glitches in the waveform from the Pod line out and headphone out.

Same trouble here, I tried the workarounds mentioned above, also putting WavPlayer into the SDRAM (DSY_SDRAM_BSS). No luck this far.
+1. Is this issue being addressed to, it seems awfully quiet here?
@netherwaves would you mind sharing your code on his? I don't fully understand how you passed/used the array in sdramm?
@VorkHeftruck here's a gist with a modded version of the WavPlayer class (located at libDaisy/src/hid/wavplayer), accompanied by an usage example script: https://gist.github.com/netherwaves/880785ccac5ddf5907ba187c16241ecc
you'll have to recompile the library in order for the change to apply! i also use this version of WavPlayer with the Daisy bootloader in SRAM mode, which works well; you'd have to see if you can run this on the normal flash sector!
@netherwaves thanks for the code, very insightful! I've tried it locally (I changed it a bit to work outside of the library). I understand what you meant in previous messages, now. You pass the SDRAM buffer as a pointer to the Init. The other changes you made are very similar to my own. However the clicks and digital artifacts are still there... Way less. But still... But thanks for your example anyway, much appreciated!