Advertisement
makispaiktis

Electracoustics - Sound_db_decreasement

Oct 22nd, 2021 (edited)
1,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.65 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. % dB data
  5. dB = 3;
  6. dB_range = 30;
  7. increase = 10^(dB/10);
  8. steps = floor(dB_range / dB);
  9. display([num2str(steps) ' steps of audio, decreasement by ' num2str(dB) ' dB.']);
  10. display(' ');
  11.  
  12. % Sound data
  13. [d, Fs] = audioread('ena.mp3');
  14. center = floor(steps/2) + 1;            % Center means the center step, where
  15.                                     % the amplitude of d is the original
  16. for step = 1:steps
  17.     display(['Step ' num2str(step)]);
  18.     d_new = d * increase^(center-step);
  19.     sound(d_new, Fs);
  20.     delay();
  21. end
  22.  
  23. function delay()
  24.     counter = 0;
  25.     for i = 1 : 0.6 * 10^9
  26.         counter = counter + 1;
  27.     end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement