3

I'm trying to use AppleSampler which uses AVAudioUnitSampler to load a EXS24 file that references ~400 .caf files. The error I'm receiving is:

FileSample.cpp:52:LoadFromURL: about to throw -42: FileSample::LoadFromURL: ExtAudioFileOpenURL
SampleManager.cpp:434:AddSample: Failed to load sample ...: error -42
SampleManager.cpp:435:AddSample: about to throw -42: Failed to load sample
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=-42 "(null)"

Where -42 means: kAudio_TooManyFilesOpenError

I know there is a lot of files, but I need to load all those samples for an instrument.

I've tried using .aupreset file instead of EXS24 but the results were the same.

Is there a way to tell AppleSampler (AVAudioUnitSampler) to lazy load those files, or a way for me to easily combine those ~400 .caf files into one big file that can be referenced by my EXS24 file, or some other options I'm not seeing?

Vlaho
  • 31
  • 1
  • According to [this answer](https://stackoverflow.com/a/62074374/2679386) there is a per process maximum number of file descriptors, which can be set through the `settrlimit` system call. – vindur Jun 01 '21 at 19:54
  • Hi @vindur, ty for the answer. I'm just wondering, this feels like private api; will app using it pass the app review? – Vlaho Jun 02 '21 at 20:07
  • Hi @Vlaho, I don't think it's a private API, it's actually a system call, which means it's a standard UNIX system call provided by iOS. Usually you can use system calls without fear of being rejected from the app store. I do think you would have to call the function from an Objective C, C or C++ file, and call that function from Swift using a bridging header. Here's the [documentation of the system call](https://pubs.opengroup.org/onlinepubs/009695399/functions/getrlimit.html) in case you need it. – vindur Jun 02 '21 at 20:37

0 Answers0