Advertisement
Guest User

Code generation for strings

a guest
Jan 28th, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. use DesktopAudio version 1.0
  2.  
  3. string String {}
  4.  
  5. AudioIn[0] >> String;
  6.  
  7.  
  8. -------------------------------------------
  9.  
  10. // #include <iostream>
  11.  
  12. #include "ReadWriteClasses.hpp"
  13. #include "Synchronization.hpp"
  14. #include "Helper.hpp"
  15.  
  16. //[[Includes]]
  17. #include <iostream>
  18. #include <iomanip>
  19. #include <string>
  20. ///////////////////////////
  21. //[[/Includes]]
  22.  
  23.  
  24. //[[Declarations]]
  25. constexpr int NUM_IN_CHANNELS = 2;
  26. constexpr int NUM_OUT_CHANNELS = 2;
  27. constexpr int NUM_SAMPLES = 44100;
  28. float inbuf[NUM_SAMPLES * NUM_IN_CHANNELS];
  29. float outbuf[NUM_SAMPLES * NUM_OUT_CHANNELS];
  30. std::string String;
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. int audio_buffer_process()
  38. {
  39.     int nBufferFrames = NUM_SAMPLES;
  40.     float *in = inbuf;
  41.     float *out = outbuf;
  42.     while(nBufferFrames-- > 0) {
  43.  
  44.  
  45. // Stream begin:  /home/andres/Documents/src/Stride/Stride/strideroot/frameworks/RtAudio/1.0/_tests/simple/16_string.stride:5
  46.         String = std::to_string(in[0]);
  47.  
  48.  
  49.  
  50.         in += NUM_IN_CHANNELS;
  51.         out += NUM_OUT_CHANNELS;
  52.     }
  53.     return 0;
  54. }
  55. ///////////////////////////
  56. //[[/Declarations]]
  57.  
  58. //[[Instances]]
  59. //[[/Instances]]
  60.  
  61.  
  62. //[[Processing]]
  63. ///////////////////////////
  64. //[[/Processing]]
  65.  
  66. //[[OSC:Processing]]
  67. //[[/OSC:Processing]]
  68. //[[SerialIn:Processing]]
  69. //[[/SerialIn:Processing]]
  70. //[[SerialOut:Processing]]
  71. //[[/SerialOut:Processing]]
  72.  
  73.  
  74. int main() {
  75. // std::cout << "app started" << std::endl;
  76. //[[GlobalInitialization]]
  77. ///////////////////////////
  78. //[[/GlobalInitialization]]
  79. //[[Initialization]]
  80.  
  81.  
  82.     for(int i = 0; i < NUM_SAMPLES; i++) {
  83.         inbuf[i* NUM_IN_CHANNELS] = (i * 2.0 / (NUM_SAMPLES-1)) - 1; // -1 -> 1
  84.         inbuf[i* NUM_IN_CHANNELS + 1] = 1 - (i * 2.0 / (NUM_SAMPLES-1)); // 1 -> -1
  85.     }
  86.  
  87.     audio_buffer_process();
  88.     ///////////////////////////
  89. //[[/Initialization]]
  90.  
  91.     // char input;
  92.     // std::cout << "\nRunning ... press <enter> to quit.\n";
  93.     // std::cin.get(input);
  94.  
  95. //[[Cleanup]]
  96.  
  97.     for(int i = 0; i < NUM_SAMPLES * NUM_IN_CHANNELS; i++) {
  98.         std::cout << std::setprecision(10) << outbuf[i] << std::endl;
  99.     }
  100.     ///////////////////////////
  101. //[[/Cleanup]]
  102.  
  103.     return 0;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement