annotate getOnsetsAndSynchronyWithFillin.m @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 59c6861155d9
children
rev   line source
bogdan@0 1 %returns the segment onset times and an array of delay between each pair of
bogdan@0 2 %corresponding onsets. Also takes two arrays containing segments where
bogdan@0 3
bogdan@0 4 function [segs1,segs2, differences] = getOnsetsAndSynchronyWithFillin(csv1, csv2, fill1,fill2)
bogdan@0 5
bogdan@0 6
bogdan@0 7
bogdan@0 8 %load the two audio segmentations
bogdan@0 9 cello = csvread(csv1);
bogdan@0 10 violin = csvread(csv2);
bogdan@0 11
bogdan@0 12
bogdan@0 13 %use only the segmentation times
bogdan@0 14 celloSegmentations = cello(:,1);
bogdan@0 15 violinSegmentations = violin(:,1);
bogdan@0 16
bogdan@0 17 celloFills = [];
bogdan@0 18 celloFillsi = [];
bogdan@0 19 violinFills = [];
bogdan@0 20 violinFillsi = [];
bogdan@0 21
bogdan@0 22 'length of fill1'
bogdan@0 23 length(fill1)
bogdan@0 24 'length of fill2'
bogdan@0 25 length(fill2)
bogdan@0 26
bogdan@0 27
bogdan@0 28 for i = 1:length(fill1)
bogdan@0 29
bogdan@0 30 segNumber = fill1(1,i);
bogdan@0 31 thisSegment = celloSegmentations(segNumber)
bogdan@0 32
bogdan@0 33 segLength = celloSegmentations(segNumber+1) - celloSegmentations(segNumber);
bogdan@0 34 segDivision = segLength * (fill1(2,i)/4);
bogdan@0 35 newSegPosition = thisSegment + segDivision;
bogdan@0 36
bogdan@0 37 celloFills(i) = newSegPosition;
bogdan@0 38 celloFillsi(i) = segNumber+1;
bogdan@0 39
bogdan@0 40 end
bogdan@0 41
bogdan@0 42
bogdan@0 43 for i = 1:length(fill2)
bogdan@0 44
bogdan@0 45 segNumber = fill2(1,i);
bogdan@0 46 thisSegment = violinSegmentations(segNumber)
bogdan@0 47
bogdan@0 48 segLength = violinSegmentations(segNumber+1) - violinSegmentations(segNumber);
bogdan@0 49 segDivision = segLength * (fill2(2,i)/4);
bogdan@0 50 newSegPosition = thisSegment + segDivision;
bogdan@0 51
bogdan@0 52 violinFills(i) = newSegPosition;
bogdan@0 53 violinFillsi(i) = segNumber+1;
bogdan@0 54
bogdan@0 55 end
bogdan@0 56
bogdan@0 57
bogdan@0 58 celloFills
bogdan@0 59 violinFills
bogdan@0 60
bogdan@0 61 %NOW FILL IN THE DATA
bogdan@0 62
bogdan@0 63 segs1 = zeros(1,length(celloSegmentations)+length(celloFills));
bogdan@0 64 segs1(celloFillsi+(0:length(celloFillsi)-1)) = celloFills;
bogdan@0 65 segs1(~segs1) = celloSegmentations
bogdan@0 66
bogdan@0 67 segs2 = zeros(1,length(violinSegmentations)+length(violinFills));
bogdan@0 68 segs2(violinFillsi+(0:length(violinFillsi)-1)) = violinFills;
bogdan@0 69 segs2(~segs2) = violinSegmentations
bogdan@0 70
bogdan@0 71 %average out the segmentation times
bogdan@0 72
bogdan@0 73
bogdan@0 74
bogdan@0 75 segs1
bogdan@0 76 segs2
bogdan@0 77
bogdan@0 78 length(segs1)
bogdan@0 79 length(segs2)
bogdan@0 80
bogdan@0 81 differences = (segs1 - segs2);
bogdan@0 82
bogdan@0 83
bogdan@0 84
bogdan@0 85
bogdan@0 86
bogdan@0 87 end