Chris@0: function visualizePitch(f_pitch,parameter) Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Name: visualizePitch Chris@0: % Date of Revision: 2011-03 Chris@0: % Programmer: Meinard Mueller, Sebastian Ewert Chris@0: % Chris@0: % Description: Chris@0: % Visualization of f_pitch Chris@0: % Chris@0: % Input: Chris@0: % f_pitch Chris@0: % parameter.midiMin = 21; Chris@0: % parameter.midiMax = 108; Chris@0: % parameter.featureRate = 0; Chris@0: % parameter.colorbar = 1; Chris@0: % parameter.colormap = hot2; Chris@0: % parameter.print = 0; Chris@0: % parameter.printFile = 'figure.eps'; Chris@0: % parameter.printDir = ''; Chris@0: % parameter.title = ''; Chris@0: % parameter.xlabel = ''; Chris@0: % parameter.ylabel = ''; Chris@0: % parameter.imagerange = 0; %[0 1]; % 0 means automatic Chris@0: % parameter.usePitchNameLabels = 0; Chris@0: % parameter.PitchNameLabels = ... Chris@0: % parameter.Ytick = [1 10 20 30 40 50 60 70 80 90 100 110 120]; % not used when usePitchNameLabels==1 Chris@0: % parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height] Chris@0: % parameter.fontSize = 0; % 0 means automatic Chris@0: % parameter.createAxisLabel = 1; Chris@0: % Chris@0: % License: Chris@0: % This file is part of 'Chroma Toolbox'. Chris@0: % Chris@0: % 'Chroma Toolbox' is free software: you can redistribute it and/or modify Chris@0: % it under the terms of the GNU General Public License as published by Chris@0: % the Free Software Foundation, either version 2 of the License, or Chris@0: % (at your option) any later version. Chris@0: % Chris@0: % 'Chroma Toolbox' is distributed in the hope that it will be useful, Chris@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: % GNU General Public License for more details. Chris@0: % Chris@0: % You should have received a copy of the GNU General Public License Chris@0: % along with 'Chroma Toolbox'. If not, see . Chris@0: % Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: if nargin<2 Chris@0: parameter=[]; Chris@0: end Chris@0: Chris@0: if isfield(parameter,'midiMin')==0 Chris@0: parameter.midiMin = 21; Chris@0: end Chris@0: if isfield(parameter,'midiMax')==0 Chris@0: parameter.midiMax = 108; Chris@0: end Chris@0: if isfield(parameter,'featureRate')==0 Chris@0: parameter.featureRate = 0; Chris@0: end Chris@0: if isfield(parameter,'colorbar')==0 Chris@0: parameter.colorbar = 1; Chris@0: end Chris@0: if (isfield(parameter,'colormap')==0) || (isstr(parameter.colormap) && strcmpi(parameter.colormap,'hot2')) Chris@0: hot2 = hot(64); Chris@0: hot2 = [hot2; hot2(32:64,:); hot2(32:64,:)]; Chris@0: hot2 = sort(hot2); Chris@0: parameter.colormap = hot2; Chris@0: end Chris@0: if isfield(parameter,'print')==0 Chris@0: parameter.print = 0; Chris@0: end Chris@0: if isfield(parameter,'printFile')==0 Chris@0: parameter.printFile = 'figure.eps'; Chris@0: end Chris@0: if isfield(parameter,'printDir')==0 Chris@0: parameter.printDir = ''; Chris@0: end Chris@0: if isfield(parameter,'title')==0 Chris@0: parameter.title = ''; Chris@0: end Chris@0: if isfield(parameter,'xlabel')==0 Chris@0: parameter.xlabel = ''; Chris@0: end Chris@0: if isfield(parameter,'ylabel')==0 Chris@0: parameter.ylabel = ''; Chris@0: end Chris@0: if isfield(parameter,'imagerange')==0 Chris@0: parameter.imagerange = 0; %[0 1]; Chris@0: end Chris@0: if isfield(parameter,'usePitchNameLabels')==0 Chris@0: parameter.usePitchNameLabels = 0; Chris@0: end Chris@0: if isfield(parameter,'PitchNameLabels')==0 Chris@0: parameter.PitchNameLabels = ... Chris@0: [' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C0 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C1 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C2 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C3 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C4 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C5 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C6 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C7 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C8 ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';' ';... Chris@0: 'C9 ']; Chris@0: end Chris@0: if isfield(parameter,'Ytick')==0 Chris@0: parameter.Ytick = [1 10 20 30 40 50 60 70 80 90 100 110 120]; % not used when usePitchNameLabels==1 Chris@0: end Chris@0: if isfield(parameter,'printPaperPosition')==0 Chris@0: parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height] Chris@0: end Chris@0: if isfield(parameter,'fontSize')==0 Chris@0: % 0 means automatic Chris@0: parameter.fontSize = 0; Chris@0: end Chris@0: if isfield(parameter,'createAxisLabel')==0 Chris@0: parameter.createAxisLabel = 1; Chris@0: end Chris@0: Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Visualization Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: figure; Chris@0: Chris@0: if parameter.featureRate == 0 Chris@0: t_axis = (1:size(f_pitch,2)); Chris@0: else Chris@0: t_axis = (0:size(f_pitch,2)-1)/parameter.featureRate; Chris@0: end Chris@0: Chris@0: p_axis = (parameter.midiMin:parameter.midiMax); Chris@0: f_image = f_pitch(p_axis,:); Chris@0: Chris@0: if parameter.imagerange == 0 Chris@0: imagesc(t_axis,p_axis,f_image); Chris@0: else Chris@0: imagesc(t_axis,p_axis,f_image,parameter.imagerange); Chris@0: end Chris@0: Chris@0: set(gca,'YTick',parameter.Ytick); Chris@0: set(gca,'YDir','normal'); Chris@0: Chris@0: if parameter.usePitchNameLabels Chris@0: set(gca,'YTick',[parameter.midiMin:parameter.midiMax]); Chris@0: set(gca,'YTickLabel',parameter.PitchNameLabels(parameter.midiMin:parameter.midiMax,:)); Chris@0: end Chris@0: Chris@0: title(parameter.title); Chris@0: xlabel(parameter.xlabel); Chris@0: ylabel(parameter.ylabel); Chris@0: Chris@0: if ~parameter.createAxisLabel Chris@0: set(gca, 'XTick', [], 'YTick', []) Chris@0: end Chris@0: Chris@0: colormap(parameter.colormap); Chris@0: Chris@0: if parameter.fontSize Chris@0: set(gca,'FontSize',parameter.fontSize) Chris@0: end Chris@0: Chris@0: if parameter.colorbar == 1 Chris@0: hColorbar = colorbar; Chris@0: if parameter.fontSize Chris@0: set(hColorbar,'FontSize',parameter.fontSize) Chris@0: end Chris@0: end Chris@0: Chris@0: drawnow; Chris@0: Chris@0: if parameter.print == 1 Chris@0: set(gcf,'PaperPosition',parameter.printPaperPosition); Chris@0: print('-depsc2',strcat(parameter.printDir,parameter.printFile)); Chris@0: end Chris@0: Chris@0: end Chris@0: Chris@0: