13 data = buffer->get_data();
24 data = buffer->get_data();
33 if (!source || source->get_data().empty()) {
39 return s.matches_buffer(source);
43 it->mix_level = mix_level;
49 m_sources.emplace_back(source, mix_level, once);
59 if (
auto root_buffer = std::dynamic_pointer_cast<RootAudioBuffer>(buffer)) {
62 auto& data = root_buffer->get_data();
64 for (uint32_t i = 0; i < data.size(); i++) {
66 if (source.has_sample_at(i)) {
67 data[i] += source.get_mixed_sample(i);
82 [](
const MixSource& s) { return s.once == true; }),
89 [](
MixSource& s) { return !s.refresh_data(); });
102 return s.matches_buffer(buffer);
std::vector< MixSource > m_sources
bool register_source(std::shared_ptr< AudioBuffer > source, double mix_level=1.0, bool once=false)
register an AudioBuffer source to be mixed into the output of specified channel
bool remove_source(std::shared_ptr< AudioBuffer > buffer)
Removes a source buffer from the mix.
void processing_function(std::shared_ptr< Buffer > buffer) override
the mechanism to mix output from one buffer to another channel
std::weak_ptr< AudioBuffer > buffer_ref
MixSource(std::shared_ptr< AudioBuffer > buffer, double level=1.0, bool once_flag=false)
Represents a source audio buffer with its data and mixing properties.