Skip to content

Commit

Permalink
More soundfiles localisation in faust2supercollider.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Nov 23, 2023
1 parent b97544c commit 215e72f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions architecture/faust/gui/SoundUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SoundUI : public SoundUIInterface
protected:

// The soundfile directories
std::vector<std::string> fSoundfileDir;
Soundfile::Directories fSoundfileDir;
// Map to share loaded soundfiles
std::map<std::string, std::shared_ptr<Soundfile>> fSoundfileMap;
// The soundfile reader
Expand Down Expand Up @@ -109,7 +109,7 @@ class SoundUI : public SoundUIInterface
*
* @return the soundfile loader.
*/
SoundUI(const std::vector<std::string>& sound_directories, int sample_rate = -1, SoundfileReader* reader = nullptr, bool is_double = false)
SoundUI(const Soundfile::Directories& sound_directories, int sample_rate = -1, SoundfileReader* reader = nullptr, bool is_double = false)
:fSoundfileDir(sound_directories)
{
fSoundReader = (reader)
Expand Down
6 changes: 4 additions & 2 deletions architecture/faust/gui/Soundfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ struct Soundfile {
delete[] fOffset;
}

typedef std::vector<std::string> Directories;

} POST_PACKED_STRUCTURE;

/*
Expand All @@ -180,7 +182,7 @@ class SoundfileReader {
int fDriverSR;

// Check if a soundfile exists and return its real path_name
std::string checkFile(const std::vector<std::string>& sound_directories, const std::string& file_name)
std::string checkFile(const Soundfile::Directories& sound_directories, const std::string& file_name)
{
if (checkFile(file_name)) {
return file_name;
Expand Down Expand Up @@ -322,7 +324,7 @@ class SoundfileReader {
}

// Check if all soundfiles exist and return their real path_name
std::vector<std::string> checkFiles(const std::vector<std::string>& sound_directories,
std::vector<std::string> checkFiles(const Soundfile::Directories& sound_directories,
const std::vector<std::string>& file_name_list)
{
std::vector<std::string> path_name_list;
Expand Down
15 changes: 14 additions & 1 deletion architecture/supercollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,19 @@ std::string defaultUserAppSupportDirectory()
{
return std::string(getenv("HOME")) + "/Library/Application Support/SuperCollider/Extensions";
}
std::string defaultSoundfilesDirectory1()
{
return std::string(getenv("HOME")) + "/Library/Application Support/SuperCollider/Extensions/FaustSounds";
}
#else
std::string defaultUserAppSupportDirectory()
{
return getenv("HOME");
}
std::string defaultSoundfilesDirectory1()
{
return std::string(getenv("HOME")) + "/FaustSounds";
}
#endif

using namespace std;
Expand Down Expand Up @@ -533,7 +541,12 @@ FAUST_EXPORT void load(InterfaceTable* inTable)
name = normalizeClassName(name);

#ifdef SOUNDFILE
std::vector<std::string> soundfile_dirs = { defaultUserAppSupportDirectory(), defaultSoundfilesDirectory(), SoundUI::getBinaryPath() };
Soundfile::Directories soundfile_dirs
= { defaultUserAppSupportDirectory(),
defaultSoundfilesDirectory(),
defaultSoundfilesDirectory1(),
SoundUI::getBinaryPath()
};
g_SoundInterface = new SoundUI(soundfile_dirs);
// Force soundfile loading at UGen load time
tmp_dsp->buildUserInterface(g_SoundInterface);
Expand Down
3 changes: 1 addition & 2 deletions tools/faust2appls/faust2supercollider
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ fi
#
if [[ $(uname) == Darwin || $CROSSTARGET == Darwin ]]; then
EXT="scx"
#SCFLAGS="-DNO_LIBSNDFILE -DSC_DARWIN $DNDEBUG -bundle"
SCFLAGS="-DSC_DARWIN $DNDEBUG -bundle"
SCFLAGS="-DNO_LIBSNDFILE -DSC_DARWIN $DNDEBUG -bundle"
elif [[ $(uname) == Linux ]]; then
EXT="so"
SCFLAGS="-DNO_LIBSNDFILE -DSC_LINUX $DNDEBUG -shared -fPIC"
Expand Down

0 comments on commit 215e72f

Please sign in to comment.