Created
December 26, 2014 06:52
-
-
Save bagustris/e6d148de0be9e6c616a9 to your computer and use it in GitHub Desktop.
msewav.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] (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