2#include <ossia/dataflow/graph_node.hpp>
3#include <ossia/dataflow/port.hpp>
7class mono_merger final :
public ossia::graph_node
12 explicit mono_merger(
int count)
15 for(
int i = 0; i < count; i++)
17 auto inl =
new ossia::audio_inlet;
18 inl->target<ossia::audio_port>()->set_channels(1);
19 m_inlets.push_back(std::move(inl));
22 m_outlets.push_back(
new ossia::audio_outlet);
23 m_outlets.back()->target<ossia::audio_port>()->set_channels(count);
26 ~mono_merger()
override =
default;
28 void run(
const ossia::token_request& t, ossia::exec_state_facade e)
noexcept override
30 auto& op = *m_outlets.back()->target<ossia::audio_port>();
31 op.set_channels(this->m_count);
34 for(
int i = 0; i < m_count; i++)
36 auto& in = m_inlets[i]->target<ossia::audio_port>()->get();
41 out[cur++].resize(e.bufferSize());
46 if(c.size() < e.bufferSize())
48 c.resize(e.bufferSize());
53 [[nodiscard]] std::string label() const noexcept
override {
return "Mono Merger"; }
55class merger final :
public ossia::graph_node
60 explicit merger(
int count)
63 for(
int i = 0; i < count; i++)
65 auto inl =
new ossia::audio_inlet;
66 inl->target<ossia::audio_port>()->set_channels(2);
67 for(
auto& channel : *inl->target<
ossia::audio_port>())
71 m_inlets.push_back(std::move(inl));
74 m_outlets.push_back(
new ossia::audio_outlet);
75 m_outlets.back()->target<ossia::audio_port>()->set_channels(2 * count);
76 for(
auto& channel : *m_outlets.back()->target<
ossia::audio_port>())
82 ~merger()
override =
default;
84 void run(
const ossia::token_request& t, ossia::exec_state_facade e)
noexcept override
86 auto& op = *m_outlets.back()->target<ossia::audio_port>();
87 op.set_channels(2 * this->m_count);
90 for(
int i = 0; i < m_count; i++)
92 auto& in = m_inlets[i]->target<ossia::audio_port>()->get();
105 out[cur++].resize(e.bufferSize());
106 out[cur++].resize(e.bufferSize());
113 if(c.size() < e.bufferSize())
115 c.resize(e.bufferSize());
120 [[nodiscard]] std::string label() const noexcept
override {
return "Stereo Merger"; }