-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualizePitch.m
181 lines (163 loc) · 5.83 KB
/
visualizePitch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
function visualizePitch(f_pitch,parameter)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Name: visualizePitch
% Date of Revision: 2011-03
% Programmer: Meinard Mueller, Sebastian Ewert
%
% Description:
% Visualization of f_pitch
%
% Input:
% f_pitch
% parameter.midiMin = 21;
% parameter.midiMax = 108;
% parameter.featureRate = 0;
% parameter.colorbar = 1;
% parameter.colormap = hot2;
% parameter.print = 0;
% parameter.printFile = 'figure.eps';
% parameter.printDir = '';
% parameter.title = '';
% parameter.xlabel = '';
% parameter.ylabel = '';
% parameter.imagerange = 0; %[0 1]; % 0 means automatic
% parameter.usePitchNameLabels = 0;
% parameter.PitchNameLabels = ...
% parameter.Ytick = [1 10 20 30 40 50 60 70 80 90 100 110 120]; % not used when usePitchNameLabels==1
% parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height]
% parameter.fontSize = 0; % 0 means automatic
% parameter.createAxisLabel = 1;
%
% License:
% This file is part of 'Chroma Toolbox'.
%
% 'Chroma Toolbox' is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 2 of the License, or
% (at your option) any later version.
%
% 'Chroma Toolbox' is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with 'Chroma Toolbox'. If not, see <http://www.gnu.org/licenses/>.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin<2
parameter=[];
end
if isfield(parameter,'midiMin')==0
parameter.midiMin = 21;
end
if isfield(parameter,'midiMax')==0
parameter.midiMax = 108;
end
if isfield(parameter,'featureRate')==0
parameter.featureRate = 0;
end
if isfield(parameter,'colorbar')==0
parameter.colorbar = 1;
end
if (isfield(parameter,'colormap')==0) || (isstr(parameter.colormap) && strcmpi(parameter.colormap,'hot2'))
hot2 = hot(64);
hot2 = [hot2; hot2(32:64,:); hot2(32:64,:)];
hot2 = sort(hot2);
parameter.colormap = hot2;
end
if isfield(parameter,'print')==0
parameter.print = 0;
end
if isfield(parameter,'printFile')==0
parameter.printFile = 'figure.eps';
end
if isfield(parameter,'printDir')==0
parameter.printDir = '';
end
if isfield(parameter,'title')==0
parameter.title = '';
end
if isfield(parameter,'xlabel')==0
parameter.xlabel = '';
end
if isfield(parameter,'ylabel')==0
parameter.ylabel = '';
end
if isfield(parameter,'imagerange')==0
parameter.imagerange = 0; %[0 1];
end
if isfield(parameter,'usePitchNameLabels')==0
parameter.usePitchNameLabels = 0;
end
if isfield(parameter,'PitchNameLabels')==0
parameter.PitchNameLabels = ...
[' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C0 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C1 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C2 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C3 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C4 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C5 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C6 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C7 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C8 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';...
'C9 '];
end
if isfield(parameter,'Ytick')==0
parameter.Ytick = [1 10 20 30 40 50 60 70 80 90 100 110 120]; % not used when usePitchNameLabels==1
end
if isfield(parameter,'printPaperPosition')==0
parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height]
end
if isfield(parameter,'fontSize')==0
% 0 means automatic
parameter.fontSize = 0;
end
if isfield(parameter,'createAxisLabel')==0
parameter.createAxisLabel = 1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Visualization
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure;
if parameter.featureRate == 0
t_axis = (1:size(f_pitch,2));
else
t_axis = (0:size(f_pitch,2)-1)/parameter.featureRate;
end
p_axis = (parameter.midiMin:parameter.midiMax);
f_image = f_pitch(p_axis,:);
if parameter.imagerange == 0
imagesc(t_axis,p_axis,f_image);
else
imagesc(t_axis,p_axis,f_image,parameter.imagerange);
end
set(gca,'YTick',parameter.Ytick);
set(gca,'YDir','normal');
if parameter.usePitchNameLabels
set(gca,'YTick',[parameter.midiMin:parameter.midiMax]);
set(gca,'YTickLabel',parameter.PitchNameLabels(parameter.midiMin:parameter.midiMax,:));
end
title(parameter.title);
xlabel(parameter.xlabel);
ylabel(parameter.ylabel);
if ~parameter.createAxisLabel
set(gca, 'XTick', [], 'YTick', [])
end
colormap(parameter.colormap);
if parameter.fontSize
set(gca,'FontSize',parameter.fontSize)
end
if parameter.colorbar == 1
hColorbar = colorbar;
if parameter.fontSize
set(hColorbar,'FontSize',parameter.fontSize)
end
end
drawnow;
if parameter.print == 1
set(gcf,'PaperPosition',parameter.printPaperPosition);
print('-depsc2',strcat(parameter.printDir,parameter.printFile));
end
end