88 termination_fade_frames_ = frames;
91 return termination_fade_frames_;
97 std::span<VoiceTermination> terminations = {})
noexcept;
106 int find_idle_voice() const noexcept;
110 std::uint32_t voice_index,
111 std::uint64_t voice_id,
113 std::uint32_t choke_matching_voices(
117 void activate_voice(
std::uint32_t voice_index,
119 void free_voice(
std::uint32_t voice_index) noexcept;
122 std::uint32_t max_voices_ = 0;
123 std::uint64_t next_voice_id_ = 1;
124 std::uint64_t trigger_counter_ = 1;
std::uint32_t active_voice_count() const noexcept
InstrumentVoiceAllocator()=default
bool prepare(std::uint32_t max_voices)
void set_termination_fade_frames(std::uint32_t frames) noexcept
Definition instrument_voice_allocator.hpp:87
VoiceStealPolicy steal_policy() const noexcept
Definition instrument_voice_allocator.hpp:86
std::uint32_t termination_fade_frames() const noexcept
Definition instrument_voice_allocator.hpp:90
bool release_voice(std::uint32_t voice_index) noexcept
std::span< const InstrumentVoice > voices() const noexcept
Definition instrument_voice_allocator.hpp:83
VoiceAllocationResult trigger(const InstrumentVoiceTrigger &trigger, std::span< VoiceTermination > terminations={}) noexcept
std::uint32_t release_note(int note, std::uint32_t sample_id=kInvalidSampleId) noexcept
std::uint32_t max_voices() const noexcept
Definition instrument_voice_allocator.hpp:76
void set_steal_policy(VoiceStealPolicy policy) noexcept
Definition instrument_voice_allocator.hpp:85
std::uint32_t allocated_voice_count() const noexcept
bool finish_voice(std::uint32_t voice_index) noexcept
Definition analyzer_provider.hpp:12
VoiceStealPolicy
Definition instrument_voice_allocator.hpp:12
@ Oldest
Definition instrument_voice_allocator.hpp:13
@ PreferSameVoiceGroupOldest
Definition instrument_voice_allocator.hpp:14
constexpr std::uint32_t kDefaultVoiceTerminationFadeFrames
Definition instrument_voice_allocator.hpp:28
VoiceTerminationReason
Definition instrument_voice_allocator.hpp:23
@ Stolen
Definition instrument_voice_allocator.hpp:25
@ Choked
Definition instrument_voice_allocator.hpp:24
VoiceState
Definition instrument_voice_allocator.hpp:17
@ Active
Definition instrument_voice_allocator.hpp:19
@ Free
Definition instrument_voice_allocator.hpp:18
@ Released
Definition instrument_voice_allocator.hpp:20
constexpr std::uint32_t kInvalidSampleId
Definition sample_identity.hpp:8
Definition instrument_voice_allocator.hpp:47
int note
Definition instrument_voice_allocator.hpp:48
std::uint32_t voice_group
Definition instrument_voice_allocator.hpp:50
std::uint32_t choke_group
Definition instrument_voice_allocator.hpp:53
std::uint32_t sample_id
Definition instrument_voice_allocator.hpp:49
Definition instrument_voice_allocator.hpp:30
std::uint32_t choke_group
Definition instrument_voice_allocator.hpp:37
std::uint32_t sample_id
Definition instrument_voice_allocator.hpp:35
VoiceState state
Definition instrument_voice_allocator.hpp:31
int note
Definition instrument_voice_allocator.hpp:34
std::uint64_t started_at
Definition instrument_voice_allocator.hpp:33
std::uint32_t voice_group
Definition instrument_voice_allocator.hpp:36
std::uint64_t voice_id
Definition instrument_voice_allocator.hpp:32
Definition instrument_voice_allocator.hpp:56
std::uint32_t voice_index
Definition instrument_voice_allocator.hpp:59
std::uint32_t choked_count
Definition instrument_voice_allocator.hpp:63
std::uint32_t stolen_voice_index
Definition instrument_voice_allocator.hpp:61
std::uint32_t termination_overflow_count
Definition instrument_voice_allocator.hpp:65
bool allocated
Definition instrument_voice_allocator.hpp:57
std::uint64_t voice_id
Definition instrument_voice_allocator.hpp:60
std::uint32_t termination_count
Definition instrument_voice_allocator.hpp:64
bool stolen
Definition instrument_voice_allocator.hpp:58
std::uint64_t stolen_voice_id
Definition instrument_voice_allocator.hpp:62
Definition instrument_voice_allocator.hpp:40
VoiceTerminationReason reason
Definition instrument_voice_allocator.hpp:43
std::uint32_t voice_index
Definition instrument_voice_allocator.hpp:41
std::uint64_t voice_id
Definition instrument_voice_allocator.hpp:42
std::uint32_t fade_out_frames
Definition instrument_voice_allocator.hpp:44