annotate matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_pitch_to_chroma.m @ 60:1ea2aed23d4a tip

Fix version
author Chris Cannam
date Thu, 13 Feb 2020 13:37:36 +0000
parents b54ee0a0be67
children
rev   line source
Chris@0 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Chris@0 2 % Name: test_convert_pitch_to_chroma.m
Chris@0 3 % Date of Revision: 2011-03
Chris@0 4 % Programmer: Meinard Mueller, Sebastian Ewert
Chris@0 5 %
Chris@0 6 % Description:
Chris@0 7 % * Computes chroma features (f_chroma) from pitch features (f_pitch)
Chris@0 8 %
Chris@0 9 % Reference:
Chris@0 10 % Details on the feature computation can be found in the following book:
Chris@0 11 %
Chris@0 12 % Meinard Mueller: Information Retrieval for Music and Motion,
Chris@0 13 % Springer 2007
Chris@0 14 %
Chris@0 15 % License:
Chris@0 16 % This file is part of 'Chroma Toolbox'.
Chris@0 17 %
Chris@0 18 % 'Chroma Toolbox' is free software: you can redistribute it and/or modify
Chris@0 19 % it under the terms of the GNU General Public License as published by
Chris@0 20 % the Free Software Foundation, either version 2 of the License, or
Chris@0 21 % (at your option) any later version.
Chris@0 22 %
Chris@0 23 % 'Chroma Toolbox' is distributed in the hope that it will be useful,
Chris@0 24 % but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 25 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 26 % GNU General Public License for more details.
Chris@0 27 %
Chris@0 28 % You should have received a copy of the GNU General Public License
Chris@0 29 % along with 'Chroma Toolbox'. If not, see <http://www.gnu.org/licenses/>.
Chris@0 30 %
Chris@0 31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Chris@0 32
Chris@0 33 clear;
Chris@0 34 close all hidden;
Chris@0 35
Chris@0 36 directory = 'data_feature/';
Chris@0 37
Chris@0 38
Chris@0 39 %filename = 'Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav';
Chris@0 40 %filename = 'Burgmueller_Op100-02-FirstPart_Meinard_SE.wav';
Chris@0 41 %filename = 'Systematic_Cadence-C-Major_Meinard_portato.wav';
Chris@0 42 %filename = 'Systematic_Cadence-C-Major_Meinard_staccato.wav';
Chris@0 43 %filename = 'Systematic_Scale-C-Major_Meinard_fast.wav';
Chris@0 44 %filename = 'Systematic_Scale-C-Major_Meinard_middle.wav';
Chris@0 45 filename = 'Systematic_Chord-C-Major_Eight-Instruments.wav';
Chris@0 46
Chris@0 47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Chris@0 48 % Loads pitch features (f_pitch) and computes chroma features (f_chroma)
Chris@0 49 %
Chris@0 50 % Note: feature filename is specified by WAV filename
Chris@0 51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Chris@0 52
Chris@0 53 win_len = 4410;
Chris@0 54 filename_pitch = strcat(filename(1:end-4),'_pitch_',num2str(win_len));
Chris@0 55 load(strcat(directory,filename_pitch)); % load f_pitch and sideinfo;
Chris@0 56
Chris@0 57 parameter.vis = 0;
Chris@0 58 %parameter.save = 1;
Chris@0 59 %parameter.save_dir = 'data_feature/';
Chris@0 60 %parameter.save_filename = strcat(sideinfo.wav.filename(1:length(sideinfo.wav.filename)-4));
Chris@0 61 [f_chroma_norm,sideinfo] = pitch_to_chroma(f_pitch,parameter,sideinfo);
Chris@0 62
Chris@0 63 parameter.applyLogCompr = 1;
Chris@0 64 parameter.factorLogCompr = 100;
Chris@0 65 f_logchroma_norm = pitch_to_chroma(f_pitch,parameter,sideinfo);
Chris@0 66
Chris@0 67 parameter.winLenSmooth = 21;
Chris@0 68 parameter.downsampSmooth = 5;
Chris@0 69 f_logchroma_normSmoothed = pitch_to_chroma(f_pitch,parameter,sideinfo);
Chris@0 70
Chris@0 71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Chris@0 72 % Visualization of chromagrams (f_chroma_norm,f_chroma)
Chris@0 73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Chris@0 74
Chris@0 75 parameter.featureRate = sideinfo.pitch.featureRate;
Chris@0 76 parameter.xlabel = 'Time [Seconds]';
Chris@0 77 parameter.title = 'Normalized chromagram';
Chris@0 78 visualizeChroma(f_chroma_norm,parameter);
Chris@0 79
Chris@0 80 parameter.title = 'Normalized log-compressed chromagram';
Chris@0 81 visualizeChroma(f_logchroma_norm,parameter);
Chris@0 82
Chris@0 83 parameter.title = 'Normalized log-compressed smoothed chromagram';
Chris@0 84 visualizeChroma(f_logchroma_normSmoothed,parameter);
Chris@0 85