Skip to content

Commit

Permalink
Merge pull request #168 from paulfd/definition-api
Browse files Browse the repository at this point in the history
Added an external API for the external definitions
  • Loading branch information
jpcima authored Apr 7, 2020
2 parents 332c752 + 75c898d commit cd7dd1d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/sfizz.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions src/sfizz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,21 @@ class SFIZZ_EXPORTED_API Sfizz
*
*/
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;
};
Expand Down
10 changes: 10 additions & 0 deletions src/sfizz/sfizz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
12 changes: 12 additions & 0 deletions src/sfizz/sfizz_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cd7dd1d

Please sign in to comment.