512{
513 try {
514 switch (op.get_type()) {
517
518 break;
519 }
520
525 } else {
527 input_data = it.second;
528 break;
529 }
530 }
531
532 if (op.m_transformer) {
533 auto transformed = op.m_transformer(input_data, cycle);
535
537 if (&m_operation == &op)
538 continue;
541 break;
542 }
543 }
544 }
545 break;
546 }
547
552 } else {
554 data_to_route = it.second;
555 break;
556 }
557 }
558
559 if (op.m_target_buffer) {
563 std::source_location::current(),
564 "BufferPipeline has no BufferManager for ROUTE-to-buffer operation");
565 }
566
567 if (!op.m_attached_processor) {
568 auto writer = std::make_shared<Buffers::AudioWriteProcessor>();
571 op.m_attached_processor = writer;
572 }
573
574 std::static_pointer_cast<Buffers::AudioWriteProcessor>(op.m_attached_processor)
575 ->set_data(data_to_route);
576
577 } else if (op.m_target_container) {
579 }
580 break;
581 }
582
585 op.m_start_frame,
586 op.m_load_length);
587
588 if (op.m_target_buffer) {
590 }
591
593 break;
594 }
595
597 std::vector<Kakshya::DataVariant> fusion_inputs;
598
599 for (auto& source_buffer : op.m_source_buffers) {
602 fusion_inputs.push_back(buffer_data);
603 }
604
605 for (auto& source_container : op.m_source_containers) {
607 fusion_inputs.push_back(container_data);
608 }
609
610 if (op.m_fusion_function && !fusion_inputs.empty()) {
611 auto fused_data = op.m_fusion_function(fusion_inputs, cycle);
612
613 if (op.m_target_buffer) {
615 } else if (op.m_target_container) {
617 }
618
620 }
621 break;
622 }
623
628 } else {
630 data_to_dispatch = it.second;
631 break;
632 }
633 }
634
635 if (op.m_dispatch_handler) {
636 op.m_dispatch_handler(data_to_dispatch, cycle);
637 }
638 break;
639 }
640
645 std::source_location::current(),
646 "BufferPipeline has no BufferManager for MODIFY operation");
647 }
648
649 if (!op.m_attached_processor) {
651 op.m_buffer_modifier,
655 }
656 }
657
658 if (op.m_modify_cycle_count > 0 && cycle >= op.m_modify_cycle_count - 1) {
659 if (op.m_attached_processor) {
661 op.m_attached_processor,
662 op.m_target_buffer);
663 op.m_attached_processor = nullptr;
664 }
665 }
666
667 break;
668 }
669
671 break;
672
673 default:
676 "Unknown operation type in pipeline : {} : {}",
678 break;
679 }
680 } catch (const std::exception& e) {
683 std::source_location::current(),
684 "Error processing operation in BufferPipeline: {}",
685 e.what());
686 }
687}
#define MF_ERROR(comp, ctx,...)
@ LOAD
Load data from container to buffer with position control.
@ CONDITION
Conditional operation for branching logic.
@ FUSE
Fuse multiple sources using custom fusion functions.
@ ROUTE
Route data to destination (buffer or container)
@ CAPTURE
Capture data from source buffer using BufferCapture strategy.
@ MODIFY
Modify Buffer Data using custom quick process.
@ DISPATCH
Dispatch to external handler for custom processing.
@ TRANSFORM
Apply transformation function to data variants.
std::unordered_map< BufferOperation *, Kakshya::DataVariant > m_operation_data
static void write_to_container(const std::shared_ptr< Kakshya::DynamicSoundStream > &container, const Kakshya::DataVariant &data)
void capture_operation(BufferOperation &op, uint64_t cycle)
std::vector< BufferOperation > m_operations
static Kakshya::DataVariant read_from_container(const std::shared_ptr< Kakshya::DynamicSoundStream > &container, uint64_t start, uint32_t length)
static void write_to_buffer(const std::shared_ptr< Buffers::AudioBuffer > &buffer, const Kakshya::DataVariant &data)
std::shared_ptr< Buffers::BufferManager > m_buffer_manager
static Kakshya::DataVariant extract_buffer_data(const std::shared_ptr< Buffers::AudioBuffer > &buffer, bool should_process=false)
@ AUDIO_BACKEND
Standard audio processing backend configuration.
@ CoroutineScheduling
Coroutine scheduling and temporal coordination (Vruta::TaskScheduler)
void error_rethrow(Component component, Context context, std::source_location location=std::source_location::current(), std::string_view additional_context="")
Catch and log an exception, then rethrow it.
@ Kriya
Automatable tasks and fluent scheduling api for Nodes and Buffers.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
constexpr std::string_view enum_to_string(EnumType value) noexcept
Universal enum to string converter using magic_enum (original case)