Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.37 KB | None | 0 0
  1. #include "Talkthrough.h"
  2. #include <math.h>
  3.  
  4. #define M_PI 3.14159265358979323846
  5.  
  6. //--------------------------------------------------------------------------//
  7. // Function:    Process_Data()                                              //
  8. //                                                                          //
  9. // Description: This function is called from inside the SPORT0 ISR every    //
  10. //              time a complete audio frame has been received. The new      //
  11. //              input samples can be found in the variables iChannel0LeftIn,//
  12. //              iChannel0RightIn, iChannel1LeftIn and iChannel1RightIn      //
  13. //              respectively. The processed data should be stored in        //
  14. //              iChannel0LeftOut, iChannel0RightOut, iChannel1LeftOut,      //
  15. //              iChannel1RightOut, iChannel2LeftOut and iChannel2RightOut   //
  16. //              respectively.                                               //
  17. //--------------------------------------------------------------------------//
  18. void Process_Data(void)
  19. {
  20.     int sampleLeft=iChannel0LeftIn<<8;
  21.     int sampleRight=iChannel0RightIn<<8;
  22.     int sample =(sampleLeft+sampleRight)/2;
  23.    
  24.     //student's code here
  25.     float krok = 0.00001636246;
  26.     static float tmp = 0;
  27.  
  28.     int sampleP = sample;
  29.     int sampleL = sample;
  30.    
  31.     sampleP *= ((cos(tmp)+1)/2);
  32.     sampleL *= ((cos(tmp+M_PI)+1)/2);
  33.     tmp += krok;
  34.    
  35.     //postprocessing
  36.     sampleL=sampleL>>8;
  37.     sampleP=sampleP>>8;
  38.     sample=sample>>8;
  39.     iChannel0LeftOut = sampleL;
  40.     iChannel0RightOut = sampleP;
  41.     iChannel1LeftOut = sampleL;
  42.     iChannel1RightOut = sampleP;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement