mborgerson
Well-known member
I'm working on a generic SD-Card bases circular buffer library for the T4.1. This project is a modification of the SD-based long audio delay class that I have been working on over the last few weeks. The library requires 32 to 64 KBytes of memory as buffers to handle read and write delays up to about 150 milliseconds that can be expected with SD cards. The question is: where do I get that memory? Among the options are:
1. The host main program defines the buffer arrays in its code, then passes a pointer to the memory block to the library begin() function. The memory could be in DTCM, DMAMEM, or EXTMEM.
2. The library begin() function uses malloc() to get a pointer to memory for the buffers. I've long been wary about the use of dynamic memory allocation--but mostly due to heap fragmentation issues that occur when blocks are allocated and freed many times in a program. Allocating buffers once that remain in use for the duration the application is less objectionable.
3. Each instance of the circular buffer class has its own buffers declared as private class variables. This means that each circular buffer object will occupy 40 to 70KBytes of DTCM.
Any advice appreciated.
1. The host main program defines the buffer arrays in its code, then passes a pointer to the memory block to the library begin() function. The memory could be in DTCM, DMAMEM, or EXTMEM.
2. The library begin() function uses malloc() to get a pointer to memory for the buffers. I've long been wary about the use of dynamic memory allocation--but mostly due to heap fragmentation issues that occur when blocks are allocated and freed many times in a program. Allocating buffers once that remain in use for the duration the application is less objectionable.
3. Each instance of the circular buffer class has its own buffers declared as private class variables. This means that each circular buffer object will occupy 40 to 70KBytes of DTCM.
Any advice appreciated.