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
sums = zeros(length(list));       % array for every file (don't count '.')

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