iPlug2 Forum

Example of loading wav resource?

Hi,

If I want to package some wav files (e.g., some impulse responses, or a set of HRTFs) with an iPlug effect, what’s the best way? I’m assuming there is some way to put them in the resources folder, then load them, but I only see examples doing that with bitmaps and fonts. Are there functions to do it with audio data?

Thanks, Tim

Hi. Yes, I copy the files into the project folder (and drag them into the IDE folder). Then I use the function:

WDL_String path;
LocateResource (filename, filetype, path, GetBundleID (), nullptr , nullptr);
FILE *fin = fopen(path.Get(), "rb");

where filename and filetype are both const char* parameters with the file name (including path) and the file extension respectively. I don’t know if this is the best approach but at least it works for me.

As mentioned above you can use LocateResource for finding the file but there’s nothing in plug itself for loading audio.

I use IAudioFile here, which should be pretty portable and which is in a library I maintain with a liberal licenses (allowing inclusion in commercial products).

1 Like