diff --git a/src/sfizz.h b/src/sfizz.h index 5e5c6af8..36f6216d 100644 --- a/src/sfizz.h +++ b/src/sfizz.h @@ -394,6 +394,25 @@ SFIZZ_EXPORTED_API void sfizz_set_logging_prefix(sfizz_synth_t* synth, const cha */ SFIZZ_EXPORTED_API void sfizz_all_sound_off(sfizz_synth_t* synth); +/** + * @brief Add external definitions prior to loading; + * Note that these do not get reset by loading or resetting the synth. + * You need to call sfizz_clear_external_definitions() to erase them. + * + * @param synth + * @param id + * @param value + */ +SFIZZ_EXPORTED_API void sfizz_add_external_definitions(sfizz_synth_t* synth, const char* id, const char* value); + +/** + * @brief Clears external definitions for the next file loading. + * + * @param synth + */ +SFIZZ_EXPORTED_API void sfizz_clear_external_definitions(sfizz_synth_t* synth); + + #ifdef __cplusplus } #endif diff --git a/src/sfizz.hpp b/src/sfizz.hpp index d0e62e37..911b5eac 100644 --- a/src/sfizz.hpp +++ b/src/sfizz.hpp @@ -284,6 +284,21 @@ public: * */ void allSoundOff() noexcept; + + /** + * @brief Add external definitions prior to loading; + * Note that these do not get reset by loading or resetting the synth. + * You need to call clearExternalDefintions() to erase them. + * + * @param id + * @param value + */ + void addExternalDefinition(const std::string& id, const std::string& value); + /** + * @brief Clears external definitions for the next file loading. + * + */ + void clearExternalDefinitions(); private: std::unique_ptr synth; }; diff --git a/src/sfizz/sfizz.cpp b/src/sfizz/sfizz.cpp index 08f88c1a..3e17af01 100644 --- a/src/sfizz/sfizz.cpp +++ b/src/sfizz/sfizz.cpp @@ -210,3 +210,13 @@ void sfz::Sfizz::allSoundOff() noexcept { synth->allSoundOff(); } + +void sfz::Sfizz::addExternalDefinition(const std::string& id, const std::string& value) +{ + synth->getParser().addExternalDefinition(id, value); +} + +void sfz::Sfizz::clearExternalDefinitions() +{ + synth->getParser().clearExternalDefinitions(); +} diff --git a/src/sfizz/sfizz_wrapper.cpp b/src/sfizz/sfizz_wrapper.cpp index bc62c4c7..3c9d88f0 100644 --- a/src/sfizz/sfizz_wrapper.cpp +++ b/src/sfizz/sfizz_wrapper.cpp @@ -256,6 +256,18 @@ void sfizz_all_sound_off(sfizz_synth_t* synth) return self->allSoundOff(); } +void sfizz_add_external_definitions(sfizz_synth_t* synth, const char* id, const char* value) +{ + auto self = reinterpret_cast(synth); + self->getParser().addExternalDefinition(id, value); +} + +void sfizz_clear_external_definitions(sfizz_synth_t* synth) +{ + auto self = reinterpret_cast(synth); + self->getParser().clearExternalDefinitions(); +} + #ifdef __cplusplus } #endif