diff --git a/tests/TestHelpers.cpp b/tests/TestHelpers.cpp index ca32de0b..f58eee73 100644 --- a/tests/TestHelpers.cpp +++ b/tests/TestHelpers.cpp @@ -51,6 +51,17 @@ const std::vector getActiveVoices(const sfz::Synth& synth) return activeVoices; } +const std::vector getPlayingVoices(const sfz::Synth& synth) +{ + std::vector 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) { diff --git a/tests/TestHelpers.h b/tests/TestHelpers.h index ac8be3dc..e5e48671 100644 --- a/tests/TestHelpers.h +++ b/tests/TestHelpers.h @@ -49,6 +49,15 @@ void sortAll(C& container, Args&... others) */ const std::vector getActiveVoices(const sfz::Synth& synth); +/** + * @brief Get playing (unreleased) voices from the synth + * + * @param synth + * @return const std::vector + */ +const std::vector getPlayingVoices(const sfz::Synth& synth); + + /** * @brief Count the number of playing (unreleased) voices from the synth *