Binary resources not in Binary Data


#1

I've got my samplesynth to build on MacOS but it won't run, as it can't find "rawwaves" directory which contains some raw files for STK. I could try to modify STK to use JUCE's binary data, but isn't it possible to simply point STK at the right directory?

Like Contents/Resources/rawwaves?

What do I need to set Stk::setRawwaves(...); I tried simply Stk::setRawwaves("rawwaves") which works for Windows (as long as the directory is in the same place as the .exe) but not for MacOS?


#2

I've found an answer:

#ifdef JUCE_WINDOWS
    Stk::setRawwavePath("rawwaves");
#endif

#ifdef JUCE_MAC
    File file = File::getSpecialLocation(File::currentApplicationFile);
    String appPath = file.getFullPathName();
    String rawwavesPath = appPath + "/Contents/Resources/rawwaves";
    Stk::setRawwavePath(rawwavesPath.toRawUTF8());
#endif

What I don't know how to do is make JUCE TheIntrojucer move the rawwaves directory to <app>/Contents/Resources, so that will have to be done manually.


#3

Is this the general format for making code in your project execute only when being run on a specific platform?   i have some os x-specific code in mine, and am trying to compile on windows. 


#4

Yes, but be careful - the code above is not strictly correct!

Always use:

#if JUCE_MAC

and NOT:

#ifdef JUCE_MAC

Because sometimes these definitions could be explicitly set to 0 rather than just being left undefined.

(And this is true of ALL the macro flags that we use in JUCE!)