Advertisement
Guest User

Untitled

a guest
Sep 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.10 KB | None | 0 0
  1. %% Group 17 - Adaptive volume
  2.  
  3. %% clear all
  4. close all
  5. clear variables
  6.  
  7. %% create variables
  8. K = 1;
  9. sampleAmount = [3000001,3000500];
  10. [s,Fs] = audioread('klaatu.wav', sampleAmount);           % read samples and sampling rate from audio
  11. Delta = 1/Fs;
  12. indices = [K+1:K:length(s)+1];
  13. t = (1:size(s,1))/Fs;                       % create timeline to plot with
  14. N = 50000;
  15. rms = arrayfun(@(x) RMS(x, s, Delta, K), indices);
  16. A = 0.0001;                                    % constant to make sure the signal values dont get to high
  17.  
  18. %% control the signal using the RMS
  19. s = s.';
  20. sControlled = (s*A)./rms;
  21.  
  22. %% draw plot
  23. figure(1);                                  % create figure window
  24. axis;                                       % creates axes in figure window
  25. plot(t,sControlled);                        % plot the graph
  26. hold on
  27. plot(t,rms);                                % plot the RMS
  28. hold off
  29.  
  30. %% label plot
  31. xlabel('t [seconds]');                      % label the x-axis
  32. ylabel('s(t)');                             % label the y-axis
  33. legend('signal','RMS');                     % create a legend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement