20class VoiceUsage final :
public HorizontalMenu {
24 enum class Kind { LIVE, AVERAGE, MAXIMUM };
26 VoiceCount(VoiceUsage& usage, Kind kind, l10n::String
name, l10n::String columnLabel)
27 :
Integer(
name), usage_(usage), kind_(kind), column_label_(columnLabel) {}
35 ActionResult
timerCallback()
override {
return usage_.timerCallback(); }
37 bool selectEncoderActionIsPermitted()
override {
return false; }
39 void getColumnLabel(
StringBuf& label)
override { label.append(l10n::getView(column_label_)); }
44 int32_t metricValue()
const {
47 return usage_.live_voice_count_;
49 return usage_.averageVoiceCount();
51 return usage_.maximum_voice_count_;
56 [[nodiscard]] int32_t getMaxValue()
const override {
return std::numeric_limits<int32_t>::max(); }
57 [[nodiscard]] deluge::gui::menu_item::RenderingStyle getRenderingStyle()
const override {
58 return deluge::gui::menu_item::RenderingStyle::NUMBER;
63 l10n::String column_label_;
66 VoiceUsage(l10n::String
name, l10n::String
title)
67 : HorizontalMenu(
name,
title, {&live_, &average_, &maximum_}, HorizontalMenu::Layout::FIXED),
68 live_(*
this, VoiceCount::Kind::LIVE, l10n::String::STRING_FOR_LIVE_VOICE_COUNT,
69 l10n::String::STRING_FOR_LIVE),
70 average_(*
this, VoiceCount::Kind::AVERAGE, l10n::String::STRING_FOR_AVERAGE_VOICE_COUNT,
71 l10n::String::STRING_FOR_AVG),
72 maximum_(*
this, VoiceCount::Kind::MAXIMUM, l10n::String::STRING_FOR_MAXIMUM_VOICE_COUNT,
73 l10n::String::STRING_FOR_MAX) {}
76 total_voice_count_ = 0;
78 maximum_voice_count_ = 0;
86 if (renderingStyle() == RenderingStyle::HORIZONTAL) {
90 getCurrentItem()->readValueAgain();
93 return ActionResult::DEALT_WITH;
97 static constexpr uint32_t kRefreshIntervalMs = 500;
99 void startTimer() { uiTimerManager.setTimer(TimerName::UI_SPECIFIC, kRefreshIntervalMs); }
103 AudioEngine::getNumVoices() + (currentSong !=
nullptr ? currentSong->countAudioVoices() : 0);
104 total_voice_count_ += live_voice_count_;
106 maximum_voice_count_ = std::max(maximum_voice_count_, live_voice_count_);
109 int32_t averageVoiceCount()
const {
110 return sample_count_ == 0 ? 0 :
static_cast<int32_t
>(total_voice_count_ / sample_count_);
113 int32_t live_voice_count_{0};
114 int32_t maximum_voice_count_{0};
115 uint64_t total_voice_count_{0};
116 uint32_t sample_count_{0};