Route element value to an AudioWriteProcessor each frame.
184{
186 if (!rec) {
188 "Bridge::write: unknown element id {}", ref.second);
189 return;
190 }
191
193 rec->outbound_tasks.push_back(
name);
194
195 auto bulk = rec->bulk_reader;
196 auto reader = rec->reader;
197
198 if (bulk) {
199 auto routine = [](Vruta::TaskScheduler&,
200 std::function<std::vector<float>()>
b,
201 std::shared_ptr<Buffers::AudioWriteProcessor> proc)
202 -> Vruta::GraphicsRoutine {
204 while (!p.should_terminate) {
205 proc->set_data(std::span<const float>(
b()));
206 co_await Kriya::FrameDelay { .frames_to_wait = 1 };
207 }
208 };
210 std::make_shared<Vruta::GraphicsRoutine>(
211 routine(
m_scheduler, std::move(bulk), std::move(target))),
213 } else {
214 auto routine = [](Vruta::TaskScheduler&,
215 std::function<float()> r,
216 std::shared_ptr<Buffers::AudioWriteProcessor> proc)
217 -> Vruta::GraphicsRoutine {
219 while (!p.should_terminate) {
220 proc->set_data(std::vector<double> { static_cast<double>(r()) });
221 co_await Kriya::FrameDelay { .frames_to_wait = 1 };
222 }
223 };
225 std::make_shared<Vruta::GraphicsRoutine>(
226 routine(
m_scheduler, std::move(reader), std::move(target))),
228 }
229}
#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.