Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.91 KB | None | 0 0
  1. use DesktopAudio version 1.0
  2.  
  3. module Test {
  4.     ports: [
  5.         mainOutputPort OutputPort {
  6.             block: Output
  7.         }
  8.         mainInputPort InputPort {
  9.             block: Input
  10.         }
  11.         propertyInputPort TestPort {
  12.             name: "test"
  13.             block: TestBlock
  14.             domain: OutputPort.domain
  15.         }
  16.     ]
  17.     blocks: [
  18. #   Amp should be auto declared in OutputDomain
  19.     ]
  20.     streams: [
  21.         TestBlock * 2 >> Amp;
  22.         Input * Amp >> Output;
  23.     ]
  24. }
  25.  
  26. AudioIn[0] >> Test(test: AudioIn[1]) >> AudioOut[0];
  27.  
  28.  
  29.  
  30. ------------------------------------------------
  31.  
  32.  
  33. // #include <iostream>
  34.  
  35. #include "ReadWriteClasses.hpp"
  36. #include "Synchronization.hpp"
  37. #include "Helper.hpp"
  38.  
  39. //[[Includes]]
  40. #include "iostream"
  41. #include "iomanip"
  42. ///////////////////////////
  43. //[[/Includes]]
  44.  
  45.  
  46. //[[Declarations]]
  47. constexpr int NUM_IN_CHANNELS = 2;
  48. constexpr int NUM_OUT_CHANNELS = 2;
  49. constexpr int NUM_SAMPLES = 44100;
  50. float inbuf[NUM_SAMPLES * NUM_IN_CHANNELS];
  51. float outbuf[NUM_SAMPLES * NUM_OUT_CHANNELS];
  52. //
  53. template<class TestBlock_Type,class Output_Type,class Input_Type>
  54. class Test {
  55. public:
  56.  
  57.  
  58.  
  59.     void AudioDomain_process(TestBlock_Type &TestBlock) {
  60.     }
  61.     void OutputPort_domain_process(Output_Type &Output, Output_Type &Amp, Input_Type Input, TestBlock_Type TestBlock) {
  62.  
  63. // Stream begin:  /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/06_port_domain.stride:21
  64.         Amp = (TestBlock * 2);
  65.  
  66. // Stream begin:  /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/06_port_domain.stride:22
  67.         Output = (Input * Amp);
  68.     }
  69.     void TestPort_domain_process(TestBlock_Type TestBlock) {
  70.     }
  71. };
  72.  
  73.  
  74.  
  75. // Module call Test_0_
  76. double Test_0_Input = 0;
  77. using Test_0_TestBlock_Helper_Type = stride::SignalHelper<double>;
  78. Test_0_TestBlock_Helper_Type Test_0_TestBlock_Helper{0};
  79. using Test_0_TestBlock_Type = stride::Signal_SDRW<stride::SignalHelper<double>, double>;
  80. Test_0_TestBlock_Type Test_0_TestBlock{&Test_0_TestBlock_Helper_Type::init_External, &Test_0_TestBlock_Helper};
  81. double Test_0_Amp = 0;
  82. double Test_0_Output = 0;
  83. Test<double,double,double> Test_0;
  84.  
  85.  
  86.  
  87.  
  88. int audio_buffer_process()
  89. {
  90.     int nBufferFrames = NUM_SAMPLES;
  91.     float *in = inbuf;
  92.     float *out = outbuf;
  93.     while(nBufferFrames-- > 0) {
  94.  
  95.  
  96. // Stream begin:  /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/module/06_port_domain.stride:26
  97.         Test_0_Input = in[0];
  98.         Test_0_TestBlock.Lock();
  99.         *Test_0_TestBlock.Write() = in[1];
  100.         Test_0_TestBlock.Unlock();
  101.         Test_0_TestBlock.Swap();
  102.         Test_0_TestBlock.Swap();
  103.         Test_0.TestPort_domain_process(Test_0_TestBlock.Read());
  104.         Test_0.OutputPort_domain_process(Test_0_Output, Test_0_Amp, Test_0_Input, Test_0_TestBlock.Read());
  105.         out[0] = Test_0_Output;
  106.  
  107.  
  108.         in += NUM_IN_CHANNELS;
  109.         out += NUM_OUT_CHANNELS;
  110.     }
  111.     return 0;
  112. }
  113. ///////////////////////////
  114. //[[/Declarations]]
  115.  
  116. //[[Instances]]
  117. //[[/Instances]]
  118.  
  119.  
  120. //[[Processing]]
  121. ///////////////////////////
  122. //[[/Processing]]
  123.  
  124. //[[OSC:Processing]]
  125. //[[/OSC:Processing]]
  126. //[[SerialIn:Processing]]
  127. //[[/SerialIn:Processing]]
  128. //[[SerialOut:Processing]]
  129. //[[/SerialOut:Processing]]
  130.  
  131.  
  132. int main() {
  133. // std::cout << "app started" << std::endl;
  134. //[[Initialization]]
  135.  
  136.  
  137.     for(int i = 0; i < NUM_SAMPLES; i++) {
  138.         inbuf[i* NUM_IN_CHANNELS] = (i * 2.0 / (NUM_SAMPLES-1)) - 1; // -1 -> 1
  139.         inbuf[i* NUM_IN_CHANNELS + 1] = 1 - (i * 2.0 / (NUM_SAMPLES-1)); // 1 -> -1
  140.     }
  141.  
  142.     audio_buffer_process();
  143.     ///////////////////////////
  144. //[[/Initialization]]
  145.  
  146.     // char input;
  147.     // std::cout << "\nRunning ... press <enter> to quit.\n";
  148.     // std::cin.get(input);
  149.  
  150. //[[Cleanup]]
  151.  
  152.     for(int i = 0; i < NUM_SAMPLES * NUM_IN_CHANNELS; i++) {
  153.         std::cout << std::setprecision(10) << outbuf[i] << std::endl;
  154.     }
  155.     ///////////////////////////
  156. //[[/Cleanup]]
  157.  
  158.     return 0;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement