d@0
|
1 function songDataSet = plotPitchData(globalPlot, songTypeIndex, intPattern)
|
d@0
|
2
|
d@0
|
3 pitchDataInput = 1:22;
|
d@0
|
4
|
d@0
|
5 % globalPlot = 0;
|
d@0
|
6 % pitchDataInput(11) = [];
|
d@0
|
7 % pitchDataInput(7) = [];
|
d@0
|
8 % pitchDataInput(6) = [];
|
d@0
|
9 % pitchDataInput(5) = [];
|
d@0
|
10 % pitchDataInput(3) = [];
|
d@0
|
11 % pitchDataInput(1) = [];
|
d@0
|
12
|
d@0
|
13 % data = readInCSV('Dataset.csv')
|
d@0
|
14 %
|
d@0
|
15 % songDataSet = {'How long has this been going on?', 'Wh';
|
d@0
|
16 % 'But don`t you remember?', 'YN';
|
d@0
|
17 % 'Is there life on Mars?', 'YN';
|
d@0
|
18 % 'Can you feel the love tonight?' 'YN';
|
d@0
|
19 % 'What have I done?', 'Wh';
|
d@0
|
20 % 'Are we human or are we dancers?', 'Echo';
|
d@0
|
21 % 'How can anybody possibly know how I feel?', 'Wh';
|
d@0
|
22 % 'D`you know what I mean?', 'YN';
|
d@0
|
23 % 'Do you remember?', 'YN';
|
d@0
|
24 % 'Do you remember the first time?', 'YN';
|
d@0
|
25 % 'Who want to live forever?', 'Wh';
|
d@0
|
26 % 'Is this the real life?', 'YN';
|
d@0
|
27 % 'Is this just fantasy?', 'YN'};
|
d@0
|
28
|
d@0
|
29 % songDataSet = readDataSet;
|
d@0
|
30 songTypeArray = {'Wh', 'YN', 'All'};
|
d@0
|
31 intPatternArray = {'rf', 'f', 'rise-hold','all'};
|
d@0
|
32 % songType = songTypeArray{songTypeIndex}
|
d@0
|
33 validQuestion = [1:52];
|
d@0
|
34
|
d@0
|
35 % for i = pitchDataInput;
|
d@0
|
36 % if(strcmp(songDataSet{i,2},songTypeArray{songTypeIndex}) || songTypeIndex == 3)
|
d@0
|
37 % if(strcmp(songDataSet{i,3},intPatternArray{intPattern}))
|
d@0
|
38 % validQuestion = cat(2,validQuestion,i);
|
d@0
|
39 % elseif(intPattern == 4 && (~strcmp(songDataSet{i,3},'x')))
|
d@0
|
40 % validQuestion = cat(2,validQuestion,i);
|
d@0
|
41 % elseif(intPattern == 3 && ~(strcmp(songDataSet{i,3},'x') ||...
|
d@0
|
42 % strcmp(songDataSet{i,3},intPatternArray{1}) ||...
|
d@0
|
43 % strcmp(songDataSet{i,3},intPatternArray{2})))
|
d@0
|
44 % validQuestion = cat(2,validQuestion,i);
|
d@0
|
45 % end
|
d@0
|
46 % end
|
d@0
|
47 % end
|
d@0
|
48
|
d@0
|
49
|
d@0
|
50 % (songDataSet{:,2} == songType)
|
d@0
|
51
|
d@0
|
52 if(globalPlot)
|
d@0
|
53 figure; hold on;
|
d@0
|
54 end
|
d@0
|
55
|
d@0
|
56 zerosPlot = 0:0.01:1;
|
d@0
|
57
|
d@0
|
58
|
d@0
|
59 totalF = zeros(1,length(zerosPlot));
|
d@0
|
60
|
d@0
|
61 % plotCol = ['y','m','c','r','g','b','k','y','m','c','r','g','b','k','y','m','c','r','g','b','k','y','m','c','r','g','b','k'];
|
d@0
|
62 plotCol = ['y','m','c','r','g','b','k'];
|
d@0
|
63 colIndex = 1;
|
d@0
|
64 for i = validQuestion
|
d@0
|
65 i
|
d@0
|
66 songTrack = csvread(strcat('T',num2str(i),'/01.csv'));
|
d@0
|
67 songTrack = songTrack(:,1:2);
|
d@0
|
68 % songTrack = songTrack(ceil(end/2):end,:)
|
d@0
|
69 songTrack(:,1) = songTrack(:,1) - min(songTrack(:,1));
|
d@0
|
70 songTrack(:,1) = songTrack(:,1) / max(songTrack(:,1));
|
d@0
|
71 if(0)
|
d@0
|
72 songTrack(:,2) = songTrack(:,2) - min(songTrack(:,2));
|
d@0
|
73 songTrack(:,2) = songTrack(:,2) / max(songTrack(:,2));
|
d@0
|
74 end
|
d@0
|
75 songTrack(:,2) = smooth(songTrack(:,2),50);
|
d@0
|
76 % songTrack = songTrack(songTrack(:,1)<0.95,:);
|
d@0
|
77 % songTrack(:,2) = songTrack(:,2) / min(songTrack(:,2));
|
d@0
|
78 % songTrack(:,2) = songTrack(:,2) / max(songTrack(:,2));
|
d@0
|
79
|
d@0
|
80 %totalF = totalF + interp1(songTrack(:,1),songTrack(:,2),zerosPlot);
|
d@0
|
81
|
d@0
|
82 songTrack(songTrack(:,2) == 0,:) = [];
|
d@0
|
83 if(~globalPlot)
|
d@0
|
84 plot(songTrack(:,1),songTrack(:,2),plotCol(mod(colIndex,7)+1));
|
d@0
|
85 axis([0,1,50,500]);
|
d@0
|
86 xlabel('Normalised Time');
|
d@0
|
87 ylabel('Frequency (Hz)');
|
d@0
|
88 plotTitle = strcat('Song: ',songDataSet{i,1} ,' Question Type: ',songDataSet{i,2}, ' with ', intPatternArray{intPattern}, ' Terminal Intonation');
|
d@0
|
89 title(plotTitle);
|
d@0
|
90 saveAsName = strcat('plots/plot',num2str(i));
|
d@0
|
91 saveas(gcf,saveAsName,'pdf');
|
d@0
|
92 else
|
d@0
|
93 plot(songTrack(:,1),songTrack(:,2),plotCol(mod(colIndex,7)+1));
|
d@0
|
94 end
|
d@0
|
95
|
d@0
|
96
|
d@0
|
97 % plot(songTrack(:,1),smooth(songTrack(:,2),size(songTrack,1)/20),plotCol(colIndex));
|
d@0
|
98 colIndex = colIndex +1;
|
d@0
|
99 end
|
d@0
|
100
|
d@0
|
101 totalF = totalF / length(validQuestion);
|
d@0
|
102
|
d@0
|
103 if(globalPlot)
|
d@0
|
104 xlabel('Normalised Time');
|
d@0
|
105 ylabel('Normalised Frequency');
|
d@0
|
106 plotTitle =strcat(songTypeArray{songTypeIndex},' Questions Data Plot with: ', intPatternArray{intPattern}, ' Terminal Intonation');
|
d@0
|
107 title(plotTitle);
|
d@0
|
108 % legend(songDataSet{pitchDataInput,1});
|
d@0
|
109 saveAsTitle = strcat('plots/',songTypeArray{songTypeIndex},'QuestionsPlot', intPatternArray{intPattern}, 'Intonation');
|
d@0
|
110 saveas(gcf,saveAsTitle,'pdf');
|
d@0
|
111 hold off;
|
d@0
|
112 end
|
d@0
|
113
|
d@0
|
114 if(1)
|
d@0
|
115 plot(zerosPlot, totalF);
|
d@0
|
116 % axis([0,1,50,500]);
|
d@0
|
117 xlabel('Normalised Time');
|
d@0
|
118 ylabel('Frequency (Hz)');
|
d@0
|
119 plotTitle = strcat(songTypeArray{songTypeIndex},' Questions Data Plot with: ', intPatternArray{intPattern}, ' Terminal Intonation Mean Results');
|
d@0
|
120 title(plotTitle);
|
d@0
|
121 % legend(songDataSet{pitchDataInput,1});
|
d@0
|
122 saveAsTitle = strcat('plots/',songTypeArray{songTypeIndex},'QuestionsPlot', intPatternArray{intPattern}, 'IntonationMean');
|
d@0
|
123 saveas(gcf,saveAsTitle,'pdf');
|
d@0
|
124 hold off;
|
d@0
|
125 end
|
d@0
|
126
|
d@0
|
127
|
d@0
|
128
|
d@0
|
129 end |