Route element value to an AudioWriteProcessor each frame.
151{
155 "Bridge::write: unknown element id {}", id);
156 return;
157 }
158
160 it->second.outbound_tasks.push_back(name);
161
162 auto bulk = it->second.bulk_reader;
163 auto reader = it->second.reader;
164
165 if (bulk) {
166 auto routine = [](Vruta::TaskScheduler&,
167 std::function<std::vector<float>()>
b,
168 std::shared_ptr<Buffers::AudioWriteProcessor> proc)
169 -> Vruta::GraphicsRoutine {
171 while (!p.should_terminate) {
172 proc->set_data(std::span<const float>(
b()));
173 co_await Kriya::FrameDelay { .frames_to_wait = 1 };
174 }
175 };
177 std::make_shared<Vruta::GraphicsRoutine>(
178 routine(
m_scheduler, std::move(bulk), std::move(target))),
179 name, false);
180 } else {
181 auto routine = [](Vruta::TaskScheduler&,
182 std::function<float()> r,
183 std::shared_ptr<Buffers::AudioWriteProcessor> proc)
184 -> Vruta::GraphicsRoutine {
186 while (!p.should_terminate) {
187 proc->set_data(std::vector<double> { static_cast<double>(r()) });
188 co_await Kriya::FrameDelay { .frames_to_wait = 1 };
189 }
190 };
192 std::make_shared<Vruta::GraphicsRoutine>(
193 routine(
m_scheduler, std::move(reader), std::move(target))),
194 name, false);
195 }
196}
#define MF_ERROR(comp, ctx,...)
void add_task(const std::shared_ptr< Routine > &routine, const std::string &name="", bool initialize=false)
Add a routine to the scheduler based on its processing token.
@ Init
Engine/subsystem initialization.
@ Portal
High-level user-facing API layer.
GetPromiseBase< Vruta::graphics_promise > GetGraphicsPromise
Graphics domain promise accessor.