Advertisement
regzarr

l6 dsp

Mar 23rd, 2021
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.07 KB | None | 0 0
  1. function [V] = flanger(inputPath, outputPath, maxSize, minSize, val, step)
  2.  
  3. if(val > maxSize || val < minSize)
  4.     disp('val has to be between minSize and maxSize!');
  5.     val = randi(minSize, maxSize, 1);
  6. end
  7.  
  8.  
  9. [Y, FS] = audioread(inputPath);
  10.  
  11. %rd = uint32(1);
  12. %wr = uint32(1);
  13.  
  14. rd = 1;
  15. wr = val - 1;
  16.  
  17. Z = Y;
  18.  
  19. buf = Y(1:val) / 2;
  20.  
  21. for i = 1:length(Y)
  22.     if((mod(i, val) == 0 )|| (mod(i, val) > val))
  23.         val = val + step;
  24.        
  25.         if (val < minSize)
  26.             val = maxSize;
  27.         end
  28.         if (val > maxSize)
  29.             val = minSize;
  30.         end
  31.        
  32.         rd = 1;
  33.         wr = val - 1;
  34.        
  35.         if ((i + val) < length(Y))
  36.             buf = Y(i : i + val) / 2;
  37.         end
  38.     end
  39.    
  40.     Z(i) = Y(i) / 2;
  41.    
  42.     %disp('i == ');
  43.     %disp(i);
  44.    
  45.     buf(wr) = Z(i);
  46.     wr = mod((wr + 1), (val)) + 1;
  47.    
  48.     %disp('rd == ');
  49.     %disp(rd);
  50.     %disp('val == ');
  51.     %disp(val);
  52.    
  53.     Z(i) = Z(i) + buf(rd);
  54.     rd = mod((rd + 1), (val)) + 1;
  55.        
  56. end
  57.  
  58. audiowrite(outputPath, Z, FS);
  59.  
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement