Playing audio from PSRAM.

Status
Not open for further replies.

thedreiskre

Active member
I have recently purchased 2 psram chips and soldered them to my teensy 4.1. The memory test worked fine, however when I tried to use them in my program for audio - they didn't work.
I was using them to store wavetables which I was playing back with the a modified version of the waveform object. https://github.com/LawrenceBradshaw/Audio
There was no sound at all produced when using EXTMEM int16_t in defining the arrays, however when I went back to using const int16_t, or just int16_t it worked smoothly. Are there modifications that I
need to make to my waveform object to make EXTMEM work? or is the psram simply not fast enough for polyphonic playback. Any help would be much appreciated.
 
I have managed to get it working but the cpu usage is very high.
The cpu usage using program memory is ~35%, while when using psram, it is ~52%
 
I have managed to get it working but the cpu usage is very high.
The cpu usage using program memory is ~35%, while when using psram, it is ~52%

Yes, the bus to the PSRAM and the addressing is slowing things down.
For the Beta, the timing was a very conserative, too. Don't know if that is still the case.
 
If you're going to be using a SPI memory you probably want to be using DMA for transfers so that the CPU doesn't waste cycles busy-waiting. However, DMA only helps you if you've got something else for the CPU to do while waiting for the DMA transfer to complete. I'm guessing the PSRAM support is using regular SPI meaning the CPU sits there busy waiting while each transfer slowly goes across the SPI bus.

If the idea of "prefetching" your data (asking for it before you need it) makes sense in your use case, then look into DMA options. If you can't pre-fetch, then you will have to take the CPU hit or use program memory.

However, at the moment SPI DMA of Audio buffers specifically requires some modifications to work on Teensy 4.x because the audio buffers are not aligned on 32-byte cache line boundaries. See this PR for details:
https://github.com/PaulStoffregen/cores/pull/421
 
Status
Not open for further replies.
Back
Top