Added a feedback for unknown opcodes in the C wrapper and the LV2 synth
This commit is contained in:
parent
c6a9ba88da
commit
66e916db19
3 changed files with 55 additions and 1 deletions
14
lv2/sfizz.c
14
lv2/sfizz.c
|
|
@ -802,7 +802,19 @@ work(LV2_Handle instance,
|
||||||
{
|
{
|
||||||
const char *sfz_file_path = LV2_ATOM_BODY_CONST(atom);
|
const char *sfz_file_path = LV2_ATOM_BODY_CONST(atom);
|
||||||
lv2_log_note(&self->logger, "[work] Loading file: %s\n", sfz_file_path);
|
lv2_log_note(&self->logger, "[work] Loading file: %s\n", sfz_file_path);
|
||||||
sfizz_load_file(self->synth, sfz_file_path);
|
if (sfizz_load_file(self->synth, sfz_file_path))
|
||||||
|
{
|
||||||
|
char * unknown_opcodes = sfizz_get_unknown_opcodes(self->synth);
|
||||||
|
if (unknown_opcodes) {
|
||||||
|
lv2_log_note(&self->logger, "[work] Unknown opcodes: %s\n", unknown_opcodes);
|
||||||
|
free(unknown_opcodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lv2_log_error(&self->logger, "[work] Error with %s; no file should be loaded.\n", sfz_file_path);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (atom->type == self->sfizz_num_voices_uri)
|
else if (atom->type == self->sfizz_num_voices_uri)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
19
src/sfizz.h
19
src/sfizz.h
|
|
@ -324,8 +324,27 @@ int sfizz_get_num_buffers(sfizz_synth_t* synth);
|
||||||
*/
|
*/
|
||||||
int sfizz_get_num_bytes(sfizz_synth_t* synth);
|
int sfizz_get_num_bytes(sfizz_synth_t* synth);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables freewheeling on the synth.
|
||||||
|
*
|
||||||
|
* @param synth
|
||||||
|
*/
|
||||||
void sfizz_enable_freewheeling(sfizz_synth_t* synth);
|
void sfizz_enable_freewheeling(sfizz_synth_t* synth);
|
||||||
|
/**
|
||||||
|
* @brief Disables freewheeling on the synth.
|
||||||
|
*
|
||||||
|
* @param synth
|
||||||
|
*/
|
||||||
void sfizz_disable_freewheeling(sfizz_synth_t* synth);
|
void sfizz_disable_freewheeling(sfizz_synth_t* synth);
|
||||||
|
/**
|
||||||
|
* @brief Get a comma separated list of unknown opcodes. The caller has to free()
|
||||||
|
* the string returned. This function allocates memory, do not call on the
|
||||||
|
* audio thread.
|
||||||
|
*
|
||||||
|
* @param synth
|
||||||
|
* @return char*
|
||||||
|
*/
|
||||||
|
char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,29 @@ void sfizz_disable_freewheeling(sfizz_synth_t* synth)
|
||||||
self->disableFreeWheeling();
|
self->disableFreeWheeling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth)
|
||||||
|
{
|
||||||
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
|
const auto unknownOpcodes = self->getUnknownOpcodes();
|
||||||
|
int totalLength = 0;
|
||||||
|
for (auto& opcode: unknownOpcodes)
|
||||||
|
totalLength += opcode.length();
|
||||||
|
|
||||||
|
if (totalLength == 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto opcodeList = (char *)std::malloc(totalLength + unknownOpcodes.size());
|
||||||
|
|
||||||
|
auto listIterator = opcodeList;
|
||||||
|
for (auto& opcode: unknownOpcodes) {
|
||||||
|
std::copy(opcode.begin(), opcode.end(), listIterator);
|
||||||
|
listIterator += opcode.length();
|
||||||
|
*listIterator++ = ',';
|
||||||
|
}
|
||||||
|
opcodeList[totalLength] = '\0';
|
||||||
|
return opcodeList;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue