//std::audio example 1 "single process" void example_1{ double sample_rate = 44100; std::size_t frame_size =2; std::size_t buffer_size=128; std::audio_context ctx{sample_rate,buffer_size,frame_size};//contruct from values std::astream_process proc(ctx,[](std::iastream const& input, std::oastream& output){ std::frame_buffer& buff = ctx.borrow_buffer();//borrow a buffer from the context for usage //prevents the need for dynamic allocation of a temporary buffer input>>buff;//stream data into buffer for manipulation for(auto&& frame: buff){ frame=0.0;//do something with audio } output< ctx;//default context created with std::default_* values //version 1: capture context via lambda std::astream_process proc1(ctx,[&ctx](std::iastream const& input, std::oastream& output){ std::frame_buffer& buff = ctx.borrow_buffer(); input>>buff; for(auto&& frame: buff){ frame*=0.5; } output< proc2(ctx,[](std::iastream const& input, std::oastream& output,std::audio_context const& context){ std::frame_buffer& buff = ctx.borrow_buffer(); input>>buff; for(auto&& frame: buff){ frame*=2.0; } output< pgroup;//a group of processes that will happen consecutivley pgroup.push(proc1);//add to group pgroup.push(proc2);//add to group //configure stream relationships in terms of std::ain / std:aout manually //std::ain/std::aout are std::astream globals that refer to the default audio inputs and outputs supplied by the context in use //std::ain/std::aout will route the audio to the enpoint specified by the context reference held by the process that is streaming the data std::aout<>proc2>>proc1>>std::aout;//method 2 pgroup.start(); //do other stuff pgroup.stop(); } //std::audio example 3 "audio files" void example_3{ std::audio_context ctx; std::astream_process proc(ctx,[](std::iafstream const& input, std::oafstream& output){ std::frame_buffer& buff = ctx.borrow_buffer(); input>>buff; for(auto&& frame: buff){ frame=0.0; } output<>proc>>audio_file2;//equivilent syntax proc.start(); //do other stuff proc.stop(); } //std::audio example 4 "combination routing" void example_3{ std::audio_context ctx; //manually select hardware endpoints std::size_t device_id = ctx.default_device_id(); std::iastream input_device = ctx.get_device(device_id); std::oastream output_device = ctx.get_device(device_id); std::astream_process proc(ctx,[](std::iastream const& input, std::oastream& output, std::iafstream const& input_file, std::oafstream& output_file){ std::frame_buffer& buff = ctx.borrow_buffer(); (input + input_file)>>buff;//add streams to perform sum before writing to buffer //or you could use seperate buffers //like this /* std::frame_buffer buff1; std::frame_buffer buff2; input>>buff1; input_file>>buff2; buff1+=buff2;//buffer arithmatic */ output<