Processes a buffer by combining tributary buffers and node network output.
The combination algorithm can be customized in the implementation.
12{
13
14 auto root_audio_buffer = std::dynamic_pointer_cast<RootAudioBuffer>(buffer);
15 if (!root_audio_buffer || root_audio_buffer !=
m_root_buffer) {
16 return;
17 }
18
19 auto& output_data = root_audio_buffer->get_data();
20 const size_t buffer_size = output_data.size();
21 std::ranges::fill(output_data, 0.0);
22
23 if (root_audio_buffer->has_node_output()) {
24 const auto& node_output = root_audio_buffer->get_node_output();
25 const size_t node_size = node_output.size();
26 const size_t add_size = std::min(buffer_size, node_size);
27
28 for (size_t i = 0; i < add_size; ++i) {
29 output_data[i] += node_output[i];
30 }
31 }
32
33 std::vector<std::shared_ptr<AudioBuffer>> buffers_to_remove;
35 if (child->needs_removal()) {
36 buffers_to_remove.push_back(child);
37 }
38 }
39
40 uint32_t active_buffers = 0;
42 if (child->has_data_for_cycle() && !child->needs_removal() && !child->is_internal_only()) {
43 active_buffers++;
44 }
45 }
46
47 if (active_buffers > 0) {
49 if (child->has_data_for_cycle() && !child->needs_removal() && !child->is_internal_only()) {
50 const auto& child_data = child->get_data();
51 for (size_t i = 0; i < std::min(child_data.size(), output_data.size()); i++) {
52 output_data[i] += child_data[i] / active_buffers;
53 }
54 }
55 }
56 }
57
58 for (auto& child : buffers_to_remove) {
60 }
61}
std::shared_ptr< RootAudioBuffer > m_root_buffer
Shared pointer to the root buffer this processor manages.