Using the Faust language we can create plugins that will need to embed audio files. What is the recommended way to do this in a generic manner, that is not depending of the final plugin format ? How can then the pathname of the file be finally computed ?
Until std::embed becomes a reality, the best approach is probably to encode the bytes in the file as a big C array and to build it into the final plugin. There’s a tool called BinaryBuilder in the JUCE repo, and also a similar tool in the Projucer. If you’re a CMake user, there’s at least one plain CMake alternative too.
Is there any easy way to add binary files to a juce module? It would be nice if there was a binaries folder that the projucer would automatically all the files within to .cpp resources. Or does something like that already exist?
I don’t think anything like that exists currently. You could always just run BinaryBuilder and add the resulting files to the module though.
I was so convinced that I wrote a FR for that, but seems I didn’t… Spoke to Ed about it back then, but it didn’t make it into the backlog…
i must not quite understand the question, but why not add it to the resources of the Producer? that way it can be read as an audio file from memory.
I’m afraid we deviated a bit from the original topic.
Yes adding to Projucer is the obvious choice.
@reuk was heading for a more generic solution, and @Roland1 wants (like myself) a way to have assets in a module self-contained, so that it stays separate from the users binary resources, maybe even with a separate namespace. That is possible, just not implemented. It would require an extra run of the BinaryBuilder for a module containing a keyword, that it has such an asset folder.