annotate util/AMT_analysis.m @ 68:f2ca04532eac

(none)
author idamnjanovic
date Wed, 16 Mar 2011 14:13:48 +0000
parents fc395272d53e
children dab78a3598b6
rev   line source
idamnjanovic@8 1 function AMT_res = AMT_analysis(Problem, solver)
idamnjanovic@8 2 %%% Automatic Music Transcription results analysis
idamnjanovic@24 3 %
idamnjanovic@24 4 % Centre for Digital Music, Queen Mary, University of London.
idamnjanovic@24 5 % This file copyright 2009 Ivan Damnjanovic.
idamnjanovic@24 6 %
idamnjanovic@24 7 % This program is free software; you can redistribute it and/or
idamnjanovic@24 8 % modify it under the terms of the GNU General Public License as
idamnjanovic@24 9 % published by the Free Software Foundation; either version 2 of the
idamnjanovic@24 10 % License, or (at your option) any later version. See the file
idamnjanovic@24 11 % COPYING included with this distribution for more information.
idamnjanovic@24 12 %
idamnjanovic@8 13 % If wav file that is transcribed is generated from midi file (i.e. if
idamnjanovic@8 14 % groundtruth exists) transcription is comapred to the original notes and
idamnjanovic@8 15 % AMT_res structure is generated. It contains following fields:
idamnjanovic@8 16 % - tp_notes - true positive notes (notes corectly transcribed)
idamnjanovic@8 17 % - oe_notes - octave errors (erroes due to imperfect pitch estimation)
idamnjanovic@8 18 % - fn_notes_wo_oe - false negative notes without octave errors
idamnjanovic@8 19 % (notes that were not detected)
idamnjanovic@8 20 % - fp_notes_wo_oe - false positive notes without octave erors
idamnjanovic@8 21 % - TP - number of true positives
idamnjanovic@8 22 % - FN - number of false negatives
idamnjanovic@8 23 % - FP - number of false positives
idamnjanovic@8 24
idamnjanovic@8 25 timeOr=Problem.notesOriginal(:,5);
idamnjanovic@8 26 noteOr=Problem.notesOriginal(:,3);
idamnjanovic@8 27 timeTr=solver.reconstructed.notes(:,5);
idamnjanovic@8 28 noteTr=solver.reconstructed.notes(:,3);
idamnjanovic@8 29 n=size(timeOr,1);
idamnjanovic@8 30 m=size(timeTr,1);
idamnjanovic@8 31
idamnjanovic@8 32 % tolerance (ts) is set to one window before and after the reference offset
idamnjanovic@8 33 % time
idamnjanovic@8 34
idamnjanovic@8 35 ts=(Problem.windowSize)/Problem.fs;
idamnjanovic@8 36
idamnjanovic@8 37 Hits=[];
idamnjanovic@8 38 OE=[];
idamnjanovic@8 39
idamnjanovic@8 40 for i=1:n
idamnjanovic@8 41 Hit= find((noteTr(:)==noteOr(i))&(abs(timeOr(i)-timeTr(:))<ts));
idamnjanovic@8 42 if size(Hit,1)>1 Hit=Hit(1); end
idamnjanovic@8 43 if ~isempty(Hit) Hits=[Hits; i , Hit];
idamnjanovic@8 44 else
idamnjanovic@8 45 OctErr=find(((noteTr(:)==noteOr(i)-12)|(noteTr(:)==noteOr(i)-24))&(abs(timeOr(i)-timeTr(:))<ts), 1);
idamnjanovic@8 46 if ~isempty(OctErr) OE=[OE; i , OctErr]; end
idamnjanovic@8 47 end
idamnjanovic@8 48 end
idamnjanovic@8 49
idamnjanovic@8 50 AMT_res.tp_notes = [Problem.notesOriginal(Hits(:,1),[3 5]) solver.reconstructed.notes(Hits(:,2),[3 5])];
idamnjanovic@8 51 AMT_res.oe_notes = [Problem.notesOriginal(OE(:,1),[3 5]) solver.reconstructed.notes(OE(:,2),[3 5])];
idamnjanovic@8 52 AMT_res.fn_notes_wo_oe = Problem.notesOriginal(setdiff([1:n],union(Hits(:,1),OE(:,1))),[3 5]);
idamnjanovic@8 53 AMT_res.fp_notes_wo_oe = solver.reconstructed.notes(setdiff([1:m],union(Hits(:,2),OE(:,2))),[3 5]);
idamnjanovic@8 54 AMT_res.TP=size(Hits,1);
idamnjanovic@8 55 AMT_res.FN=n-AMT_res.TP;
idamnjanovic@8 56 AMT_res.FP=m-AMT_res.TP;
idamnjanovic@8 57 end