Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include "Talkthrough.h"
  2. #include "math.h"
  3. #define X 9600 //0,2s
  4.  
  5. int buffer[X];
  6. int i=0;
  7. float depth= 0.1;
  8.  
  9. //--------------------------------------------------------------------------//
  10. // Function: Process_Data() //
  11. // //
  12. // Description: This function is called from inside the SPORT0 ISR every //
  13. // time a complete audio frame has been received. The new //
  14. // input samples can be found in the variables iChannel0LeftIn,//
  15. // iChannel0RightIn, iChannel1LeftIn and iChannel1RightIn //
  16. // respectively. The processed data should be stored in //
  17. // iChannel0LeftOut, iChannel0RightOut, iChannel1LeftOut, //
  18. // iChannel1RightOut, iChannel2LeftOut and iChannel2RightOut //
  19. // respectively. //
  20. //--------------------------------------------------------------------------//
  21. void Process_Data(void)
  22. {
  23. int sampleLeft=iChannel0LeftIn<<8;
  24. int sampleRight=iChannel0RightIn<<8;
  25. int sample =(sampleLeft+sampleRight)/2;
  26.  
  27. //student's code here
  28.  
  29. //echo
  30.  
  31. int y = sample;
  32. sample =buffer[i]+sample;
  33. buffer[i]=y;
  34. i++;
  35.  
  36. if(i>X)
  37. {
  38. i=0;
  39. }
  40.  
  41.  
  42. float modSignal = (1 - depth) + depth * sin(3.14*(i-X)/X);
  43. //float modSignal = sin(3.14*(i-X)/X);
  44.  
  45. sample = sample*modSignal; // efekt tremolo
  46.  
  47.  
  48.  
  49.  
  50. //postprocessing
  51. sample=sample>>8;
  52. iChannel0LeftOut = sample;
  53. iChannel0RightOut = sample;
  54. iChannel1LeftOut = sample;
  55. iChannel1RightOut = sample;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement