Mercurial > hg > tipic
comparison matlab/MATLAB-Chroma-Toolbox_2.0/visualizeChroma.m @ 0:b54ee0a0be67
Import MATLAB Chroma Toolbox
author | Chris Cannam |
---|---|
date | Wed, 05 Aug 2015 21:08:56 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b54ee0a0be67 |
---|---|
1 function visualizeChroma(f_chroma,parameter) | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % Name: visualizeChroma | |
4 % Date of Revision: 2011-03 | |
5 % Programmer: Meinard Mueller, Sebastian Ewert | |
6 % | |
7 % Description: | |
8 % Visualization of f_chroma | |
9 % | |
10 % Input: | |
11 % f_chroma | |
12 % parameter.featureRate = 0; % 0 means unknown | |
13 % parameter.colorbar = 1; | |
14 % parameter.colormap = 'hot'; | |
15 % parameter.print = 0; | |
16 % parameter.printFile = 'figure.eps'; | |
17 % parameter.printDir = ''; | |
18 % parameter.title = ''; | |
19 % parameter.xlabel = ''; | |
20 % parameter.imagerange = [0 1]; % 0 means automatic | |
21 % parameter.fontSize = 0; % 0 means automatic | |
22 % parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height] | |
23 % parameter.createAxisLabel = 1; | |
24 % | |
25 % License: | |
26 % This file is part of 'Chroma Toolbox'. | |
27 % | |
28 % 'Chroma Toolbox' is free software: you can redistribute it and/or modify | |
29 % it under the terms of the GNU General Public License as published by | |
30 % the Free Software Foundation, either version 2 of the License, or | |
31 % (at your option) any later version. | |
32 % | |
33 % 'Chroma Toolbox' is distributed in the hope that it will be useful, | |
34 % but WITHOUT ANY WARRANTY; without even the implied warranty of | |
35 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
36 % GNU General Public License for more details. | |
37 % | |
38 % You should have received a copy of the GNU General Public License | |
39 % along with 'Chroma Toolbox'. If not, see <http://www.gnu.org/licenses/>. | |
40 % | |
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
42 | |
43 if nargin<2 | |
44 parameter=[]; | |
45 end | |
46 | |
47 if isfield(parameter,'featureRate')==0 | |
48 parameter.featureRate = 0; | |
49 end | |
50 if isfield(parameter,'colorbar')==0 | |
51 parameter.colorbar = 1; | |
52 end | |
53 if isfield(parameter,'colormap')==0 | |
54 parameter.colormap = 'hot'; | |
55 end | |
56 if isfield(parameter,'print')==0 | |
57 parameter.print = 0; | |
58 end | |
59 if isfield(parameter,'printFile')==0 | |
60 parameter.printFile = 'figure.eps'; | |
61 end | |
62 if isfield(parameter,'printDir')==0 | |
63 parameter.printDir = ''; | |
64 end | |
65 if isfield(parameter,'title')==0 | |
66 parameter.title = ''; | |
67 end | |
68 if isfield(parameter,'xlabel')==0 | |
69 parameter.xlabel = ''; | |
70 end | |
71 if isfield(parameter,'imagerange')==0 | |
72 parameter.imagerange = [0 1]; | |
73 end | |
74 if isfield(parameter,'fontSize')==0 | |
75 % 0 means automatic | |
76 parameter.fontSize = 0; | |
77 end | |
78 if isfield(parameter,'printPaperPosition')==0 | |
79 parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height] | |
80 end | |
81 if isfield(parameter,'createAxisLabel')==0 | |
82 parameter.createAxisLabel = 1; | |
83 end | |
84 | |
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
86 % Visualization | |
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
88 | |
89 seg_num = size(f_chroma,2); | |
90 | |
91 chroma_names = ['C ';'C#';'D ';'D#';'E ';'F ';'F#';'G ';'G#';'A ';'A#';'B ']; | |
92 figure; | |
93 set(gcf,'renderer','painters'); | |
94 | |
95 if parameter.featureRate == 0 | |
96 t = (1:seg_num); | |
97 else | |
98 t = (0:seg_num-1)/parameter.featureRate; | |
99 end | |
100 | |
101 if all(parameter.imagerange == 0) | |
102 imagesc(t,[1:12],f_chroma); | |
103 else | |
104 imagesc(t,[1:12],f_chroma,parameter.imagerange); | |
105 end | |
106 set(gca,'YTick',[1:12]); | |
107 set(gca,'YTickLabel',chroma_names); | |
108 set(gca,'YDir','normal'); | |
109 if t(end)>t(1) | |
110 set(gca,'XLim',[t(1),t(end)]); | |
111 end | |
112 | |
113 title(parameter.title); | |
114 xlabel(parameter.xlabel); | |
115 | |
116 if ~parameter.createAxisLabel | |
117 set(gca, 'XTick', [], 'YTick', []) | |
118 end | |
119 | |
120 colormap(parameter.colormap); | |
121 | |
122 if parameter.fontSize | |
123 set(gca,'FontSize',parameter.fontSize) | |
124 end | |
125 | |
126 if parameter.colorbar == 1 | |
127 hColorbar = colorbar; | |
128 if parameter.fontSize | |
129 set(hColorbar,'FontSize',parameter.fontSize) | |
130 end | |
131 end | |
132 drawnow; | |
133 | |
134 if parameter.print == 1 | |
135 set(gcf,'PaperPosition',parameter.printPaperPosition); | |
136 print('-depsc2',strcat(parameter.printDir,parameter.printFile)); | |
137 end | |
138 | |
139 end | |
140 | |
141 |