Use cached SOFA files to save memory
mainIf you need to open the same SOFA file multiple times or use multiple filters, use the cached API. This ensures that HRTFs with the same filename and sampling rate are stored only once in memory.
Note: If your program is multi-threaded, you must use synchronization mechanisms to ensure only a single thread accesses mysofa_open_cached and mysofa_close_cached at a time.
To release all cached memory, call mysofa_cache_release_all().
// Open files using the cache
hrtf1 = mysofa_open_cached("file.sofa", 48000, &filter_length, &err);
hrtf2 = mysofa_open_cached("file.sofa", 48000, &filter_length, &err);
// Close using the cache
mysofa_close_cached(hrtf1);
mysofa_close_cached(hrtf2);
// Release everything
mysofa_cache_release_all();