Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. clear all;
  2. close all;
  3. %Reading the file
  4. [y, fs] = audioread('gitara.wav');
  5.  
  6. %Creating the vector according to which delay is varied
  7. a= 0.01;
  8. b= 0.4;
  9. low_n = round(a*fs);
  10. high_n = round(b*fs);
  11.  
  12. delay_step = 2 /(1/fs);
  13. n = low_n;
  14. no_points = length(y(:,1));
  15. out_wav(:,1) = zeros(1,no_points);
  16. fwd_back = 0;
  17. ifs = 0;
  18. saved_signal = 1:high_n;
  19. k=1;
  20.  
  21. for i=1:no_points
  22. if(fwd_back==0)
  23. ifs = ifs +1;
  24. delay(i) = ((high_n-low_n)/(2*fs))*ifs+low_n;
  25. end
  26.  
  27. if(ifs == 2*fs)
  28. fwd_back = 1;
  29. ifs = ifs -1;
  30. end
  31.  
  32. if(fwd_back==1)
  33. ifs = ifs -1;
  34. delay(i) = ((high_n-low_n)/(2*fs))*ifs+low_n;
  35. if(ifs == 0)
  36. fwd_back = 0;
  37. end
  38. end
  39.  
  40. if (k<=high_n)
  41. saved_signal(k) = y(i);
  42. k = k+1;
  43. else
  44. k=1;
  45. end
  46.  
  47. %n(i) = i-delay(i);
  48. %if uint32(n(i))>0
  49. if uint32(i>low_n*2)
  50. %out_wav(i) = y(i)+y(uint32(n(i)));
  51. signal_before = k - uint32(delay(i)) + 1;
  52. out_wav(i) = y(i)+ saved_signal(signal_before);
  53. else
  54. out_wav(i) = y(i);
  55. end
  56.  
  57. end
  58.  
  59. p = audioplayer(out_wav,fs);
  60. play(p);
  61. plot(out_wav);
  62. hold on;
  63. plot(y);
  64. pause;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement