Rename all: note label -> key label
This commit is contained in:
parent
a810dc5775
commit
5f94e34230
8 changed files with 38 additions and 38 deletions
14
src/sfizz.h
14
src/sfizz.h
|
|
@ -399,29 +399,29 @@ SFIZZ_EXPORTED_API void sfizz_clear_external_definitions(sfizz_synth_t* synth);
|
||||||
#define SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX -1
|
#define SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX -1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the number of note labels registered in the current sfz file
|
* @brief Get the number of key labels registered in the current sfz file
|
||||||
* @since 0.4.0-dev
|
* @since 0.4.0-dev
|
||||||
*/
|
*/
|
||||||
SFIZZ_EXPORTED_API unsigned int sfizz_get_num_note_labels(sfizz_synth_t* synth);
|
SFIZZ_EXPORTED_API unsigned int sfizz_get_num_key_labels(sfizz_synth_t* synth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the note number for the label registered at index label_index.
|
* @brief Get the key number for the label registered at index label_index.
|
||||||
* @since 0.4.0-dev
|
* @since 0.4.0-dev
|
||||||
*
|
*
|
||||||
* @returns the number or SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX if the index is out of bounds.
|
* @returns the number or SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX if the index is out of bounds.
|
||||||
*/
|
*/
|
||||||
SFIZZ_EXPORTED_API int sfizz_get_note_label_number(sfizz_synth_t* synth, int label_index);
|
SFIZZ_EXPORTED_API int sfizz_get_key_label_number(sfizz_synth_t* synth, int label_index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the note text for the label registered at index label_index.
|
* @brief Get the key text for the label registered at index label_index.
|
||||||
* @since 0.4.0-dev
|
* @since 0.4.0-dev
|
||||||
*
|
*
|
||||||
* @returns the label or NULL if the index is out of bounds.
|
* @returns the label or NULL if the index is out of bounds.
|
||||||
*/
|
*/
|
||||||
SFIZZ_EXPORTED_API const char * sfizz_get_note_label_text(sfizz_synth_t* synth, int label_index);
|
SFIZZ_EXPORTED_API const char * sfizz_get_key_label_text(sfizz_synth_t* synth, int label_index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the number of note labels registered in the current sfz file
|
* @brief Get the number of CC labels registered in the current sfz file
|
||||||
* @since 0.4.0-dev
|
* @since 0.4.0-dev
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -317,11 +317,11 @@ public:
|
||||||
void clearExternalDefinitions();
|
void clearExternalDefinitions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the note labels, if any
|
* @brief Get the key labels, if any
|
||||||
* @since 0.4.0-dev
|
* @since 0.4.0-dev
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const std::vector<std::pair<uint8_t, std::string>>& getNoteLabels() const noexcept;
|
const std::vector<std::pair<uint8_t, std::string>>& getKeyLabels() const noexcept;
|
||||||
/**
|
/**
|
||||||
* @brief Get the CC labels, if any
|
* @brief Get the CC labels, if any
|
||||||
* @since 0.4.0-dev
|
* @since 0.4.0-dev
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ void sfz::Synth::clear()
|
||||||
defaultPath = "";
|
defaultPath = "";
|
||||||
resources.midiState.reset();
|
resources.midiState.reset();
|
||||||
ccLabels.clear();
|
ccLabels.clear();
|
||||||
noteLabels.clear();
|
keyLabels.clear();
|
||||||
globalOpcodes.clear();
|
globalOpcodes.clear();
|
||||||
masterOpcodes.clear();
|
masterOpcodes.clear();
|
||||||
groupOpcodes.clear();
|
groupOpcodes.clear();
|
||||||
|
|
@ -212,9 +212,9 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
||||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back()))
|
if (Default::ccNumberRange.containsWithEnd(member.parameters.back()))
|
||||||
ccLabels.emplace_back(member.parameters.back(), std::string(member.value));
|
ccLabels.emplace_back(member.parameters.back(), std::string(member.value));
|
||||||
break;
|
break;
|
||||||
case hash("label_note&"):
|
case hash("label_key&"):
|
||||||
if (Default::keyRange.containsWithEnd(member.parameters.back()))
|
if (Default::keyRange.containsWithEnd(member.parameters.back()))
|
||||||
noteLabels.emplace_back(member.parameters.back(), std::string(member.value));
|
keyLabels.emplace_back(member.parameters.back(), std::string(member.value));
|
||||||
break;
|
break;
|
||||||
case hash("Default_path"):
|
case hash("Default_path"):
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
|
@ -891,7 +891,7 @@ std::string sfz::Synth::exportMidnam(absl::string_view model) const
|
||||||
{
|
{
|
||||||
pugi::xml_node nnl = device.append_child("NoteNameList");
|
pugi::xml_node nnl = device.append_child("NoteNameList");
|
||||||
nnl.append_attribute("Name").set_value("Notes");
|
nnl.append_attribute("Name").set_value("Notes");
|
||||||
for (const auto& pair : noteLabels) {
|
for (const auto& pair : keyLabels) {
|
||||||
pugi::xml_node nn = nnl.append_child("Note");
|
pugi::xml_node nn = nnl.append_child("Note");
|
||||||
nn.append_attribute("Number").set_value(std::to_string(pair.first).c_str());
|
nn.append_attribute("Number").set_value(std::to_string(pair.first).c_str());
|
||||||
nn.append_attribute("Name").set_value(pair.second.c_str());
|
nn.append_attribute("Name").set_value(pair.second.c_str());
|
||||||
|
|
|
||||||
|
|
@ -389,11 +389,11 @@ public:
|
||||||
const Parser& getParser() const noexcept { return parser; }
|
const Parser& getParser() const noexcept { return parser; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the note labels, if any
|
* @brief Get the key labels, if any
|
||||||
*
|
*
|
||||||
* @return const std::vector<NoteNamePair>&
|
* @return const std::vector<NoteNamePair>&
|
||||||
*/
|
*/
|
||||||
const std::vector<NoteNamePair>& getNoteLabels() const noexcept { return noteLabels; }
|
const std::vector<NoteNamePair>& getKeyLabels() const noexcept { return keyLabels; }
|
||||||
/**
|
/**
|
||||||
* @brief Get the CC labels, if any
|
* @brief Get the CC labels, if any
|
||||||
*
|
*
|
||||||
|
|
@ -508,9 +508,9 @@ private:
|
||||||
*/
|
*/
|
||||||
Voice* findFreeVoice() noexcept;
|
Voice* findFreeVoice() noexcept;
|
||||||
|
|
||||||
// Names for the CC and notes as set by label_cc and label_note
|
// Names for the CC and notes as set by label_cc and label_key
|
||||||
std::vector<CCNamePair> ccLabels;
|
std::vector<CCNamePair> ccLabels;
|
||||||
std::vector<NoteNamePair> noteLabels;
|
std::vector<NoteNamePair> keyLabels;
|
||||||
|
|
||||||
// Default active switch if multiple keyswitchable regions are present
|
// Default active switch if multiple keyswitchable regions are present
|
||||||
absl::optional<uint8_t> defaultSwitch;
|
absl::optional<uint8_t> defaultSwitch;
|
||||||
|
|
|
||||||
|
|
@ -221,9 +221,9 @@ void sfz::Sfizz::clearExternalDefinitions()
|
||||||
synth->getParser().clearExternalDefinitions();
|
synth->getParser().clearExternalDefinitions();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::pair<uint8_t, std::string>>& sfz::Sfizz::getNoteLabels() const noexcept
|
const std::vector<std::pair<uint8_t, std::string>>& sfz::Sfizz::getKeyLabels() const noexcept
|
||||||
{
|
{
|
||||||
return synth->getNoteLabels();
|
return synth->getKeyLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::pair<uint16_t, std::string>>& sfz::Sfizz::getCCLabels() const noexcept
|
const std::vector<std::pair<uint16_t, std::string>>& sfz::Sfizz::getCCLabels() const noexcept
|
||||||
|
|
|
||||||
|
|
@ -269,20 +269,20 @@ void sfizz_clear_external_definitions(sfizz_synth_t* synth)
|
||||||
self->getParser().clearExternalDefinitions();
|
self->getParser().clearExternalDefinitions();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int sfizz_get_num_note_labels(sfizz_synth_t* synth)
|
unsigned int sfizz_get_num_key_labels(sfizz_synth_t* synth)
|
||||||
{
|
{
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
return self->getNoteLabels().size();
|
return self->getKeyLabels().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sfizz_get_note_label_number(sfizz_synth_t* synth, int label_index)
|
int sfizz_get_key_label_number(sfizz_synth_t* synth, int label_index)
|
||||||
{
|
{
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
const auto noteLabels = self->getNoteLabels();
|
const auto keyLabels = self->getKeyLabels();
|
||||||
if (label_index < 0)
|
if (label_index < 0)
|
||||||
return SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX;
|
return SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX;
|
||||||
|
|
||||||
if (static_cast<unsigned int>(label_index) >= noteLabels.size())
|
if (static_cast<unsigned int>(label_index) >= keyLabels.size())
|
||||||
return SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX;
|
return SFIZZ_OUT_OF_BOUNDS_LABEL_INDEX;
|
||||||
|
|
||||||
// Sanity checks for the future or platforms
|
// Sanity checks for the future or platforms
|
||||||
|
|
@ -290,20 +290,20 @@ int sfizz_get_note_label_number(sfizz_synth_t* synth, int label_index)
|
||||||
std::numeric_limits<sfz::NoteNamePair::first_type>::max() < std::numeric_limits<int>::max(),
|
std::numeric_limits<sfz::NoteNamePair::first_type>::max() < std::numeric_limits<int>::max(),
|
||||||
"The C API sends back an int but the note index in NoteNamePair can overflow it on this platform"
|
"The C API sends back an int but the note index in NoteNamePair can overflow it on this platform"
|
||||||
);
|
);
|
||||||
return static_cast<int>(noteLabels[label_index].first);
|
return static_cast<int>(keyLabels[label_index].first);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * sfizz_get_note_label_text(sfizz_synth_t* synth, int label_index)
|
const char * sfizz_get_key_label_text(sfizz_synth_t* synth, int label_index)
|
||||||
{
|
{
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
const auto noteLabels = self->getNoteLabels();
|
const auto keyLabels = self->getKeyLabels();
|
||||||
if (label_index < 0)
|
if (label_index < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (static_cast<unsigned int>(label_index) >= noteLabels.size())
|
if (static_cast<unsigned int>(label_index) >= keyLabels.size())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return noteLabels[label_index].second.c_str();
|
return keyLabels[label_index].second.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int sfizz_get_num_cc_labels(sfizz_synth_t* synth)
|
unsigned int sfizz_get_num_cc_labels(sfizz_synth_t* synth)
|
||||||
|
|
|
||||||
|
|
@ -568,13 +568,13 @@ TEST_CASE("[Files] Labels")
|
||||||
{
|
{
|
||||||
sfz::Synth synth;
|
sfz::Synth synth;
|
||||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/labels.sfz");
|
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/labels.sfz");
|
||||||
auto noteLabels = synth.getNoteLabels();
|
auto keyLabels = synth.getKeyLabels();
|
||||||
auto ccLabels = synth.getCCLabels();
|
auto ccLabels = synth.getCCLabels();
|
||||||
REQUIRE( noteLabels.size() == 2);
|
REQUIRE( keyLabels.size() == 2);
|
||||||
REQUIRE( noteLabels[0].first == 12 );
|
REQUIRE( keyLabels[0].first == 12 );
|
||||||
REQUIRE( noteLabels[0].second == "Cymbals" );
|
REQUIRE( keyLabels[0].second == "Cymbals" );
|
||||||
REQUIRE( noteLabels[1].first == 65 );
|
REQUIRE( keyLabels[1].first == 65 );
|
||||||
REQUIRE( noteLabels[1].second == "Crash" );
|
REQUIRE( keyLabels[1].second == "Crash" );
|
||||||
REQUIRE( ccLabels.size() == 2);
|
REQUIRE( ccLabels.size() == 2);
|
||||||
REQUIRE( ccLabels[0].first == 54 );
|
REQUIRE( ccLabels[0].first == 54 );
|
||||||
REQUIRE( ccLabels[0].second == "Gain" );
|
REQUIRE( ccLabels[0].second == "Gain" );
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<control>
|
<control>
|
||||||
label_cc54=Gain
|
label_cc54=Gain
|
||||||
label_cc2=Other
|
label_cc2=Other
|
||||||
label_note12=Cymbals
|
label_key12=Cymbals
|
||||||
label_note65=Crash
|
label_key65=Crash
|
||||||
label_note128=Ignored
|
label_key128=Ignored
|
||||||
<region> sample=*sine
|
<region> sample=*sine
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue