% Matlab/Octave script demonstrating the estimation of the peak-to-peak and
% root-mean-square signal amplitude and the signal-to-noise ratio of a
% periodic waveform, estimating the noise by looking at the time periods
% where its envelope drops below a threshold. Needs fastsmooth.m and
% PlotFrequencySpectrum in the path.
format compact
% Load the wav file into a Matlab variable
v=wavread('TestingOneTwoThree.wav');
time=0:1/44001:1.5825; % 44001 is the sampling rate; 1.5825 is the duration of the signal
waveform=v(:,1)'+v(:,2)';
% Set the threshold below which is mostly noise.
threshold=.03
% load george-dataShort.csv
% waveform=george_dataShort;
% slength=length(waveform);
% time=(1:slength)./8000;
disp(' ')
% Compute the envelope by smoothing the absolute value of the waveform
SmoothWidth=500;
SmoothType=2;
envelope=fastsmooth(abs(waveform),SmoothWidth,SmoothType);
bz=zeros(size(time));
j=1;
for i=1:length(time),
if envelope(i)