Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Group 17 - Adaptive volume
- %% clear all
- close all
- clear variables
- %% create variables
- K = 1;
- sampleAmount = [3000001,3000500];
- [s,Fs] = audioread('klaatu.wav', sampleAmount); % read samples and sampling rate from audio
- Delta = 1/Fs;
- indices = [K+1:K:length(s)+1];
- t = (1:size(s,1))/Fs; % create timeline to plot with
- N = 50000;
- rms = arrayfun(@(x) RMS(x, s, Delta, K), indices);
- A = 0.0001; % constant to make sure the signal values dont get to high
- %% control the signal using the RMS
- s = s.';
- sControlled = (s*A)./rms;
- %% draw plot
- figure(1); % create figure window
- axis; % creates axes in figure window
- plot(t,sControlled); % plot the graph
- hold on
- plot(t,rms); % plot the RMS
- hold off
- %% label plot
- xlabel('t [seconds]'); % label the x-axis
- ylabel('s(t)'); % label the y-axis
- legend('signal','RMS'); % create a legend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement