Added an external API for the external definitions

This commit is contained in:
Paul Fd 2020-04-07 01:06:39 +02:00
parent 4e7f15328a
commit 75c898d50c
4 changed files with 56 additions and 0 deletions

View file

@ -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

View file

@ -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<sfz::Synth> synth;
};

View file

@ -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();
}

View file

@ -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<sfz::Synth*>(synth);
self->getParser().addExternalDefinition(id, value);
}
void sfizz_clear_external_definitions(sfizz_synth_t* synth)
{
auto self = reinterpret_cast<sfz::Synth*>(synth);
self->getParser().clearExternalDefinitions();
}
#ifdef __cplusplus
}
#endif