view aux/finddouble.m @ 8:2afd6ff39f08

prepare2listen fixes
author Brecht De Man <b.deman@qmul.ac.uk>
date Fri, 28 Nov 2014 00:52:12 +0000
parents b28ffd29e6e1
children
line wrap: on
line source
function finddouble(foldername)
% FINDDOUBLE spots doubles of audio files in the same folder
% 
% by Brecht De Man at Centre for Digital Music on 15 July 2013


list = dir([foldername '/*.wav']);  % find wav file names in folder

% remove hidden files from list
% see http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/258220
for k = length(list):-1:1
    fname = list(k).name;
    if fname(1) == '.'
        list(k) = [ ];
    end
end

sums = zeros(length(list));       % number for every file

for i = 1:length(list)
    audio = audioread([foldername '/' list(i).name]); 
    sums(i) = sum(sum(audio.^2));
end

for i = 1:length(list)
    for j = i+1:length(list)
        if sums(i) == sums(j)
            disp(['ERROR: ' list(i).name ' = ' list(j).name])
        end
    end
end

end

% TODO: expand to more folders