Guest User

Untitled

a guest
Jun 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. import pitaru.sonia_v2_9.*;
  2.  
  3.  
  4. //vars//////
  5. int count = 0;
  6. int gesamt = 0;
  7. int endpuffer = 200000; //to be cut off later
  8. int deltime = 1000;
  9. int mergetime = 100;
  10. float faktorhoch = 1.02;
  11. float randomtime = 1;
  12. int roundedrandomtime = 0;
  13. float[] inputfloat; //in float
  14. Sample input;
  15. Sample output;
  16. int[] selection;
  17. float[] transfloat; // übertrag
  18.  
  19. //pending
  20. ///////////////
  21.  
  22.  
  23. /*
  24. x² = (y - a - b)/z
  25. x = quadwurz((y - a - b)/z)
  26. samples = sqrt((input.getNumFrames() - deltime - endpuffer)/faktorhoch)
  27. */
  28.  
  29. void setup() {//runs once
  30. println(sqrt(4));
  31.  
  32. Sonia.start(this);
  33. input = new Sample("CaliforniaWaiting1.wav"); //////INPUTFILE
  34. println("-frames = " + input.getNumFrames());
  35. inputfloat = new float[input.getNumFrames()]; //creates a new array the length of the sample
  36. input.read(inputfloat);
  37.  
  38.  
  39.  
  40. selection = new int[round(sqrt((input.getNumFrames() - deltime - endpuffer )/faktorhoch))];
  41.  
  42.  
  43. for (int samples=0; samples < (sqrt((input.getNumFrames() - deltime - endpuffer )/faktorhoch) ); ++samples) {// choose places for deletions.
  44. selection[samples] = (round((input.getNumFrames() - deltime - endpuffer + 1 ) - (samples*samples*faktorhoch)) + mergetime);
  45. print(selection[samples] + "; ");
  46. }
  47.  
  48.  
  49. frameRate(999);//per second
  50.  
  51.  
  52.  
  53. ///////////pending
  54. /*
  55. for (int zounds=0; zounds < input.getNumFrames(); ++zounds) {// zounds "adress"
  56. mergefloat[zounds] = 0; //initialise track
  57. }*/
  58.  
  59. gesamt = (round(sqrt((input.getNumFrames() - deltime - endpuffer)/faktorhoch)));
  60. println("-setup done");
  61.  
  62. noLoop();
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. void draw() {// frame by frame
  72.  
  73. println("was da? " + inputfloat[round(inputfloat.length/2)]);
  74.  
  75. println(count + " " + selection[count] + " sellength:" + selection.length);
  76.  
  77. transfloat = new float[(inputfloat.length - deltime - mergetime)];
  78.  
  79. for (int zounds=0; zounds < (selection[count] - mergetime) ; ++zounds) {// zounds "adress" ///transfare untouched start
  80. transfloat[zounds] = inputfloat[zounds];
  81.  
  82. }
  83.  
  84. for (int zounds=(selection[count] - mergetime); zounds < selection[count] ; ++zounds) {// zounds "adress" ///fade
  85. transfloat[zounds] = (((inputfloat[zounds])*(1-((zounds - (selection[count] - mergetime)+1)/mergetime))) + ((inputfloat[(zounds + deltime + mergetime)])*((zounds - (selection[count] - mergetime)+1)/mergetime)));
  86. }
  87.  
  88. for (int zounds = (selection[count]); zounds < (inputfloat.length - deltime - mergetime) ; ++zounds) {// zounds "adress" ///transfare untouched end
  89. transfloat[zounds] = inputfloat[zounds + deltime + mergetime];
  90. }
  91.  
  92.  
  93.  
  94. inputfloat = new float[transfloat.length];
  95. for (int zounds=0; zounds < (transfloat.length) ; ++zounds) {// zounds "adress" ///transfare untouched start
  96. inputfloat[zounds] = transfloat[zounds];
  97. }
  98.  
  99. ///////////pending
  100.  
  101. //////////////////////////////////////OOOOLDmerge/////////////////////////////////////////////////
  102. /* for (int zounds=0; zounds < input.getNumFrames(); ++zounds) {// zounds "adress" ///volume down merge
  103. mergefloat[zounds] = (mergefloat[zounds]/count*(count-1));
  104. }
  105.  
  106. for (int zounds=0; zounds < input.getNumFrames(); ++zounds) {// zounds "adress"
  107. if(zounds - randomint >= 0){
  108. magic = zounds ;//- randomint + input.getNumFrames();
  109. pufferfloat[magic] = pufferfloat[magic] + ((inputfloat[zounds - randomint])/count);
  110.  
  111. } else {
  112.  
  113. }
  114. }
  115.  
  116.  
  117. for (int zounds=0; zounds < input.getNumFrames(); ++zounds) {// zounds "adress"
  118. if(zounds - randomint >= 0){
  119.  
  120. } else {
  121. magic = zounds ;//- randomint + input.getNumFrames();
  122. mergefloat[magic] = mergefloat[magic] + ((inputfloat[zounds - randomint + input.getNumFrames()])/count); //SOMEHOW IS LIKE PUFFER 1 ROUND TO EARLY
  123.  
  124. }
  125. }*/
  126. //////////////////////////////////////OOOLDmerge/////////////////////////////////////////////////
  127.  
  128.  
  129.  
  130.  
  131.  
  132. if(count < (gesamt-1)) { //framestopper and layering progress
  133. count = count + 1;
  134. print(".");
  135. loop();
  136. }
  137. else {
  138. output = new Sample(transfloat.length);
  139. output.write(transfloat);
  140. println("");
  141. println("saving to disk");
  142. output.saveFile("output1");
  143.  
  144. noLoop();
  145. }
  146.  
  147.  
  148.  
  149. }
  150.  
  151.  
  152. public void stop(){
  153. Sonia.stop();
  154. super.stop();
  155. }
Add Comment
Please, Sign In to add comment