Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. use DesktopAudio version 1.0
  2.  
  3. signal Accum {}
  4. switch ResetOuter { }
  5. signal OuterCounter { reset: ResetOuter}
  6.  
  7. loop Loop {
  8. ports: [
  9. ]
  10. blocks: [
  11. signal Counter {}
  12. switch CounterReset {}
  13. ]
  14. streams: [
  15. Accum + 2 >> Accum;
  16. Counter + 1 >> Counter;
  17. [Counter, 10] >> Equal() >> CounterReset;
  18. ]
  19. terminateWhen: CounterReset
  20. }
  21.  
  22.  
  23. [OuterCounter, 20] >> Equal() >> ResetOuter >> Loop();
  24. OuterCounter + 1 >> OuterCounter;
  25. Accum >> AudioOut[1];
  26.  
  27. ----------------------------------
  28.  
  29.  
  30. #include "RtAudio.h"
  31. #include <iostream>
  32. #include <cstdlib>
  33. #include <cstring>
  34.  
  35.  
  36. //[[Includes]]
  37. //[[/Includes]]
  38.  
  39.  
  40. //[[Declarations]]
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. class Equal {
  50. public:
  51. float Input[2];
  52. float EqualBlock;
  53. float Output;
  54.  
  55. Equal() {
  56. Input[0] = 0;
  57. Input[1] = 0;
  58. EqualBlock = 0.0;
  59. Output = 0;
  60.  
  61. }
  62. void process__OutputDomain(float Input[2], float &Output) {
  63. // Starting stream 00 -------------------------
  64. Output = Input[0] == Input[1];
  65. // Stream End 00
  66. }
  67.  
  68. };
  69. float Accum;
  70. void Loop_process_AudioDomain(float &Accum) {
  71. float Counter;
  72. float _Equal_048_out;
  73. Equal Equal_048;
  74. bool CounterReset;
  75. Counter = 0;
  76. CounterReset = false;
  77. while (!CounterReset) {
  78. // Starting stream 00 -------------------------
  79. Accum = (Accum + 2);
  80. // Stream End 00
  81. // Starting stream 01 -------------------------
  82. Counter = (Counter + 1);
  83. // Stream End 01
  84. // Starting stream 02 -------------------------
  85. float _bundle_connector_56[2];
  86. _bundle_connector_56[0] = Counter;
  87. _bundle_connector_56[1] = 10;
  88. Equal_048.process__OutputDomain(_bundle_connector_56, _Equal_048_out);
  89. CounterReset = _Equal_048_out;
  90. // Stream End 02
  91. }
  92.  
  93. }
  94. float OuterCounter;
  95. void _OuterCounterReset_process_AudioDomain(float &OuterCounter) {
  96. // Starting stream 00 -------------------------
  97. // Stream End 00
  98. // Starting stream 00 -------------------------
  99. OuterCounter = 0;
  100. // Stream End 00
  101. }
  102. float _Equal_014_out;
  103. Equal Equal_014;
  104. bool ResetOuter;
  105. float AudioOut[2];
  106. #include <iostream>
  107. #include <iomanip>
  108. #define NUM_IN_CHANNELS 2
  109. #define NUM_OUT_CHANNELS 2
  110. #define NUM_SAMPLES 44100
  111. float inbuf[NUM_SAMPLES * NUM_IN_CHANNELS];
  112. float outbuf[NUM_SAMPLES * NUM_OUT_CHANNELS];
  113. //[[/Declarations]]
  114.  
  115. //[[Instances]]
  116. //[[/Instances]]
  117.  
  118.  
  119. //[[Processing]]
  120.  
  121. int audio_buffer_process()
  122. {
  123. int nBufferFrames = NUM_SAMPLES;
  124. float *in = inbuf;
  125. float *out = outbuf;
  126. while(nBufferFrames-- > 0) {
  127.  
  128. // Starting stream 00 -------------------------
  129. // Stream End 00
  130. // Starting stream 00 -------------------------
  131. float _bundle_connector_58[2];
  132. _bundle_connector_58[0] = OuterCounter;
  133. _bundle_connector_58[1] = 20;
  134. Equal_014.process__OutputDomain(_bundle_connector_58, _Equal_014_out);
  135. ResetOuter = _Equal_014_out;
  136. if (ResetOuter) {
  137. Loop_process_AudioDomain(Accum);
  138. }
  139. // Stream End 00
  140. // Starting stream 01 -------------------------
  141. if (ResetOuter) {
  142. _OuterCounterReset_process_AudioDomain(OuterCounter);
  143. }
  144. // Stream End 01
  145. // Starting stream 02 -------------------------
  146. OuterCounter = (OuterCounter + 1);
  147. // Stream End 02
  148. // Starting stream 03 -------------------------
  149. //#line 25 "/home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/loop/01_simple.stride"
  150. out[0] = Accum;;
  151. // Stream End 03
  152. in += NUM_IN_CHANNELS;
  153. out += NUM_OUT_CHANNELS;
  154. }
  155. return 0;
  156. }
  157. //[[/Processing]]
  158.  
  159. //[[OSC:Processing]]
  160. //[[/OSC:Processing]]
  161. //[[SerialIn:Processing]]
  162. //[[/SerialIn:Processing]]
  163. //[[SerialOut:Processing]]
  164. //[[/SerialOut:Processing]]
  165.  
  166.  
  167. int main() {
  168. //[[Initialization]]
  169.  
  170.  
  171.  
  172. Accum = 0;
  173. OuterCounter = 0;
  174. ResetOuter = false;
  175. AudioOut[0] = 0.0;
  176. AudioOut[1] = 0.0;
  177.  
  178. for(int i = 0; i < NUM_SAMPLES; i++) {
  179. inbuf[i* NUM_IN_CHANNELS] = (i * 2.0 / (NUM_SAMPLES-1)) - 1; // -1 -> 1
  180. inbuf[i* NUM_IN_CHANNELS + 1] = 1 - (i * 2.0 / (NUM_SAMPLES-1)); // 1 -> -1
  181. }
  182. audio_buffer_process();
  183.  
  184. //[[/Initialization]]
  185.  
  186. // char input;
  187. // std::cout << "\nRunning ... press <enter> to quit.\n";
  188. // std::cin.get(input);
  189.  
  190. //[[Cleanup]]
  191.  
  192. for(int i = 0; i < NUM_SAMPLES; i++) {
  193. std::cout << std::setprecision(10) << outbuf[i] << std::endl;
  194. }
  195.  
  196. //[[/Cleanup]]
  197.  
  198.  
  199. return 0;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement