Add a helper for playing voices
This commit is contained in:
parent
95165ca650
commit
80aee5a9cd
2 changed files with 20 additions and 0 deletions
|
|
@ -51,6 +51,17 @@ const std::vector<const sfz::Voice*> getActiveVoices(const sfz::Synth& synth)
|
|||
return activeVoices;
|
||||
}
|
||||
|
||||
const std::vector<const sfz::Voice*> getPlayingVoices(const sfz::Synth& synth)
|
||||
{
|
||||
std::vector<const sfz::Voice*> playingVoices;
|
||||
for (int i = 0; i < synth.getNumVoices(); ++i) {
|
||||
const auto* voice = synth.getVoiceView(i);
|
||||
if (!voice->releasedOrFree())
|
||||
playingVoices.push_back(voice);
|
||||
}
|
||||
return playingVoices;
|
||||
}
|
||||
|
||||
unsigned numPlayingVoices(const sfz::Synth& synth)
|
||||
{
|
||||
return absl::c_count_if(getActiveVoices(synth), [](const sfz::Voice* v) {
|
||||
|
|
|
|||
|
|
@ -49,6 +49,15 @@ void sortAll(C& container, Args&... others)
|
|||
*/
|
||||
const std::vector<const sfz::Voice*> getActiveVoices(const sfz::Synth& synth);
|
||||
|
||||
/**
|
||||
* @brief Get playing (unreleased) voices from the synth
|
||||
*
|
||||
* @param synth
|
||||
* @return const std::vector<const sfz::Voice*>
|
||||
*/
|
||||
const std::vector<const sfz::Voice*> getPlayingVoices(const sfz::Synth& synth);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Count the number of playing (unreleased) voices from the synth
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue