use DesktopAudio version 1.0 module Test { ports: [ mainOutputPort OutputPort { block: Output } mainInputPort InputPort { block: Input } propertyInputPort TestPort { name: "test" block: TestBlock } ] blocks: [ signal Amp { domain: TestPort.domain } ] streams: [ TestBlock * 2 >> Amp; Input * Amp >> Output; ] } AudioIn[0] >> Test(test: AudioIn[1]) >> AudioOut[0]; ------------------------------------------------------------------------------- // #include #include "ReadWriteClasses.hpp" #include "Synchronization.hpp" #include "Helper.hpp" //[[Includes]] #include "iostream" #include "iomanip" /////////////////////////// //[[/Includes]] //[[Declarations]] constexpr int NUM_IN_CHANNELS = 2; constexpr int NUM_OUT_CHANNELS = 2; constexpr int NUM_SAMPLES = 44100; float inbuf[NUM_SAMPLES * NUM_IN_CHANNELS]; float outbuf[NUM_SAMPLES * NUM_OUT_CHANNELS]; using Amp_Helper_Type = stride::SignalHelper; Amp_Helper_Type Amp_Helper{0}; using Amp_Type = stride::Signal_SDRW; Amp_Type Amp{&Amp_Helper_Type::init_External, &Amp_Helper}; // template class Test { public: void AudioDomain_process(TestBlock_Type &TestBlock) { } void OutputPort_domain_process(Output_Type &Output, TestBlock_Type &Amp, Input_Type &Input) { // Stream begin: /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/05_port_domain.stride:21 Amp.Swap(); Output = (Input * Amp.Read()); } void TestPort_domain_process(TestBlock_Type &Amp, TestBlock_Type &TestBlock) { // Stream begin: /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/05_port_domain.stride:20 TestBlock.Swap(); Amp.Lock(); *Amp.Write() = (TestBlock.Read() * 2); Amp.Unlock(); } }; // Module call Test_0_ using Test_0_Amp_Helper_Type = stride::SignalHelper; Test_0_Amp_Helper_Type Test_0_Amp_Helper{0}; using Test_0_Amp_Type = stride::Signal_SDRW; Test_0_Amp_Type Test_0_Amp{&Test_0_Amp_Helper_Type::init_External, &Test_0_Amp_Helper}; double Test_0_Input = 0; using Test_0_TestBlock_Helper_Type = stride::SignalHelper; Test_0_TestBlock_Helper_Type Test_0_TestBlock_Helper{0}; using Test_0_TestBlock_Type = stride::Signal_SDRW; Test_0_TestBlock_Type Test_0_TestBlock{&Test_0_TestBlock_Helper_Type::init_External, &Test_0_TestBlock_Helper}; double Test_0_Output = 0; Test Test_0; int audio_buffer_process() { int nBufferFrames = NUM_SAMPLES; float *in = inbuf; float *out = outbuf; while(nBufferFrames-- > 0) { // Stream begin: /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/05_port_domain.stride:25 Test_0_Input = in[0]; Test_0_TestBlock.Lock(); *Test_0_TestBlock.Write() = in[1]; Test_0_TestBlock.Unlock(); Test_0.TestPort_domain_process(Test_0_Amp, Test_0_TestBlock); Test_0.OutputPort_domain_process(Test_0_Output, Test_0_Amp, Test_0_Input); out[0] = Test_0_Output; in += NUM_IN_CHANNELS; out += NUM_OUT_CHANNELS; } return 0; } /////////////////////////// //[[/Declarations]] //[[Instances]] //[[/Instances]] //[[Processing]] /////////////////////////// //[[/Processing]] //[[OSC:Processing]] //[[/OSC:Processing]] //[[SerialIn:Processing]] //[[/SerialIn:Processing]] //[[SerialOut:Processing]] //[[/SerialOut:Processing]] int main() { // std::cout << "app started" << std::endl; //[[Initialization]] for(int i = 0; i < NUM_SAMPLES; i++) { inbuf[i* NUM_IN_CHANNELS] = (i * 2.0 / (NUM_SAMPLES-1)) - 1; // -1 -> 1 inbuf[i* NUM_IN_CHANNELS + 1] = 1 - (i * 2.0 / (NUM_SAMPLES-1)); // 1 -> -1 } audio_buffer_process(); /////////////////////////// //[[/Initialization]] // char input; // std::cout << "\nRunning ... press to quit.\n"; // std::cin.get(input); //[[Cleanup]] for(int i = 0; i < NUM_SAMPLES * NUM_IN_CHANNELS; i++) { std::cout << std::setprecision(10) << outbuf[i] << std::endl; } /////////////////////////// //[[/Cleanup]] return 0; }