12 auto audio = std::dynamic_pointer_cast<AudioBuffer>(buffer);
15 "StreamSliceProcessor requires an AudioBuffer");
23 for (
size_t i = 0; i <
m_slots.size(); ++i)
29 return std::dynamic_pointer_cast<AudioBuffer>(buffer) !=
nullptr;
35 if (slot.proc && slot.slice.stream)
36 slot.proc->on_detach(slot.slice.stream);
44 "StreamSliceProcessor::load called before attachment to a buffer -- attach first");
53 "StreamSliceProcessor::load index {} exceeds slot count {}; use {} for next available",
73 proc->set_on_end([
this, index] {
74 m_slots[index].slice.active =
false;
82 m_slots[index].proc = std::move(proc);
91 m_slots[index].slice.active =
true;
100 m_slots[index].slice.active =
false;
105 return std::ranges::any_of(
m_slots, [](
const auto& slot) {
106 return slot.slice.active;
112 auto audio = std::dynamic_pointer_cast<AudioBuffer>(buffer);
116 const uint32_t ch = audio->get_channel_id();
117 auto& dst = audio->get_data();
118 std::ranges::fill(dst, 0.0);
121 if (!slot.slice.active || !slot.slice.stream || !slot.proc)
124 slot.proc->process(slot.slice.stream);
126 const auto& pd = slot.slice.stream->get_dynamic_data(slot.proc->get_slot_index());
130 const auto structure = slot.slice.stream->get_structure();
131 std::vector<double> tmp(dst.size(), 0.0);
134 for (
size_t s = 0; s < dst.size(); ++s)
#define MF_ERROR(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
void detach_slot(size_t index)
void unbind(size_t index)
Deactivate a slot, stopping its processor without resetting the cursor.
void on_attach(const std::shared_ptr< Buffer > &buffer) override
Called when this processor is attached to a buffer.
void bind(size_t index)
Activate a slot, resetting its processor cursor to region start.
std::vector< Slot > m_slots
bool is_compatible_with(const std::shared_ptr< Buffer > &buffer) const override
Checks if this processor can handle the specified buffer type.
void on_detach(const std::shared_ptr< Buffer > &buffer) override
Called when this processor is detached from a buffer.
bool any_active() const
Check if any slot is active.
void load(size_t index, Kakshya::StreamSlice slice)
Assign a StreamSlice to a slot.
uint32_t m_frames_per_block
void processing_function(const std::shared_ptr< Buffer > &buffer) override
The core processing function that must be implemented by derived classes.
Kakshya::StreamSlice & slice(size_t index)
std::function< void(size_t)> m_on_end
@ Configuration
Configuration and parameter updates.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
void extract_processed_data(const std::vector< DataVariant > &pd, OrganizationStrategy organization, uint64_t num_channels, uint32_t ch, std::span< double > output)
Extract one channel's samples from a processed dynamic data block.
uint64_t start_frame() const
std::shared_ptr< DynamicSoundStream > stream
uint64_t end_frame() const
A bounded region of a DynamicSoundStream with associated playback parameters.