Skip to content

Instantly share code, notes, and snippets.

@bagustris
Created December 26, 2014 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagustris/e6d148de0be9e6c616a9 to your computer and use it in GitHub Desktop.
Save bagustris/e6d148de0be9e6c616a9 to your computer and use it in GitHub Desktop.
msewav.m
function error = msewav(inputFile ,outputFile)
% function to compute mse between two .wav. files
% usage: mse=msewav(cleanfile.wav,enhanced.wav)
% matlab spectrum library for Vibrastic Lab, ITS
% modified by bagustris@yahoo.com (21/7/2014) for .wav files
if nargin<2
fprintf('mse=msewav(inputFile, outputFile) \n');
return;
end;
[in, fs1, Nbits1]= wavread(inputFile);
[out, fs2, Nbits2]= wavread(outputFile);
if (( fs1~= fs2) | ( Nbits1~= Nbits2))
error( 'The two files do not match!\n');
end
if length(in)<length(out);
out=out(1:length(in));
else
in=in(1:length(out));
end
in=in(:);
out=out(:);
%error=mse(in,out);
in=in./max(abs(in));
out=out/max(abs(out));
z=sum(((in)-(out)).^2);
error=z/length(in);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment