Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use DesktopAudio version 1.0
- module Test {
- ports: [
- mainOutputPort OutputPort {
- block: Output
- }
- mainInputPort InputPort {
- block: Input
- }
- propertyInputPort TestPort {
- name: "test"
- block: TestBlock
- domain: OutputPort.domain
- }
- ]
- blocks: [
- # Amp should be auto declared in OutputDomain
- ]
- streams: [
- TestBlock * 2 >> Amp;
- Input * Amp >> Output;
- ]
- }
- AudioIn[0] >> Test(test: AudioIn[1]) >> AudioOut[0];
- ------------------------------------------------
- // #include <iostream>
- #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];
- //
- template<class TestBlock_Type,class Output_Type,class Input_Type>
- class Test {
- public:
- void AudioDomain_process(TestBlock_Type &TestBlock) {
- }
- void OutputPort_domain_process(Output_Type &Output, Output_Type &Amp, Input_Type Input, TestBlock_Type TestBlock) {
- // Stream begin: /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/06_port_domain.stride:21
- Amp = (TestBlock * 2);
- // Stream begin: /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/06_port_domain.stride:22
- Output = (Input * Amp);
- }
- void TestPort_domain_process(TestBlock_Type TestBlock) {
- }
- };
- // Module call Test_0_
- double Test_0_Input = 0;
- using Test_0_TestBlock_Helper_Type = stride::SignalHelper<double>;
- Test_0_TestBlock_Helper_Type Test_0_TestBlock_Helper{0};
- using Test_0_TestBlock_Type = stride::Signal_SDRW<stride::SignalHelper<double>, double>;
- Test_0_TestBlock_Type Test_0_TestBlock{&Test_0_TestBlock_Helper_Type::init_External, &Test_0_TestBlock_Helper};
- double Test_0_Amp = 0;
- double Test_0_Output = 0;
- Test<double,double,double> 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/06_port_domain.stride:26
- Test_0_Input = in[0];
- Test_0_TestBlock.Lock();
- *Test_0_TestBlock.Write() = in[1];
- Test_0_TestBlock.Unlock();
- Test_0_TestBlock.Swap();
- Test_0_TestBlock.Swap();
- Test_0.TestPort_domain_process(Test_0_TestBlock.Read());
- Test_0.OutputPort_domain_process(Test_0_Output, Test_0_Amp, Test_0_Input, Test_0_TestBlock.Read());
- 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 <enter> 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement