MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ processing_function()

void MayaFlux::Buffers::MixProcessor::processing_function ( const std::shared_ptr< Buffer > &  buffer)
overridevirtual

the mechanism to mix output from one buffer to another channel

Implements MayaFlux::Buffers::BufferProcessor.

Definition at line 53 of file MixProcessor.cpp.

54{
55 if (m_sources.empty()) {
56 return;
57 }
58
59 if (auto root_buffer = std::dynamic_pointer_cast<RootAudioBuffer>(buffer)) {
61
62 auto& data = root_buffer->get_data();
63 const bool normalize = root_buffer->is_mix_normalized();
64
65 for (uint32_t i = 0; i < data.size(); i++) {
66 for (const auto& source : m_sources) {
67 if (source.has_sample_at(i)) {
68 data[i] += source.get_mixed_sample(i);
69 }
70 }
71
72 if (normalize) {
73 data[i] /= (double)m_sources.size();
74 }
75 }
76
77 cleanup();
78 }
79}
std::shared_ptr< NetworkGeometryBuffer > buffer
std::vector< MixSource > m_sources
void normalize(std::span< double > data, double target_min, double target_max) noexcept
Normalize to [target_min, target_max] in-place Single-pass min/max reduction followed by a single tra...
Definition Transform.cpp:61
Source source()
Begin a Source chain.
Definition Plot.hpp:127

References buffer, cleanup(), m_sources, and validate_sources().

+ Here is the call graph for this function: