unicornpower
Well-known member
I'm writing a looper effect which requires recording to one audio buffer (a file on the SD card), whilst reading from another (a different file on the SD card). The 'play file' is read during an AudioStream::update(), e.g. within an interrupt. The 'record file' is written to during the standard main loop update. I'm struggling to find documentation about the SD library and reentrancy, and whether it should be possible to have 2 open SD files where calls into SD functions may 'overlap', e.g an SD function is called on one file, and during this function call, an interrupt triggers which calls an SD function on another file.
This is making it hard for me to determine if I simply have a bug in my code, or I'm doing something unsupported.
For anyone interested, the full code is here https://github.com/cutlasses/Looper. This is running on a Teensy 3.5, using the built in ADC and DAC.
The issue I have is that the main loop hangs when the audio stream closes its file. I've traced the flow of control to this:
This is making it hard for me to determine if I simply have a bug in my code, or I'm doing something unsupported.
For anyone interested, the full code is here https://github.com/cutlasses/Looper. This is running on a Teensy 3.5, using the built in ADC and DAC.
The issue I have is that the main loop hangs when the audio stream closes its file. I've traced the flow of control to this:
Code:
--Main Loop-- --Interrupt--
call to SD::write()
on record file
call to SD::close()
on play file
HANG
SD::write() never terminates
interrupt continues interrupting