# HG changeset patch
# User Chris Cannam
# Date 1438805336 -3600
# Node ID b54ee0a0be67245020f468fae9d73dd84e76ec11
Import MATLAB Chroma Toolbox
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusHalf.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusHalf.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusQuarter.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusQuarter.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThird.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThird.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThreeQuarters.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThreeQuarters.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusTwoThird.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/MIDI_FB_ellip_pitch_60_96_22050_Q25_minusTwoThird.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/audio_to_pitch_via_FB.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/audio_to_pitch_via_FB.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,249 @@
+function [f_pitch,sideinfo] = audio_to_pitch_via_FB(f_audio,parameter,sideinfo)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: audio_to_pitch_via_FB
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% Computing and saving of pitch features via a pre-designed filterbank.
+% features. For each window length specified via parameter.winLenSTMSP
+% the following is computed:
+% - STMSP (short-time mean-square power) for each MIDI pitch between
+% parameter.midiMin and parameter.midiMax
+% - STMSP subbands are stored in f_pitch, where f_pitch(p,:) contains
+% STMSP of subband of pitch p
+% - sideinfo contains information of original pcm, which is saved along
+% with f_pitch into a single mat-file
+% - Information f_pitch and sideinfo is stored in mat-file:
+% save(strcat(parameter.saveDir,parameter.saveFilename),'f_pitch','sideinfo');
+%
+% Input:
+% f_audio
+% parameter.winLenSTMSP = 4410;
+% parameter.shiftFB = 0;
+% parameter.midiMin = 21;
+% parameter.midiMax = 108;
+% parameter.save = 0;
+% parameter.saveDir = '';
+% parameter.saveFilename = '';
+% parameter.saveAsTuned = 0;
+% parameter.fs = 22050;
+% parameter.visualize = 0;
+%
+% Required files:
+% 'MIDI_FB_ellip_pitch_60_96_22050_Q25.mat'
+% 'MIDI_FB_ellip_pitch_60_96_22050_Q25_minusHalf.mat'
+% 'MIDI_FB_ellip_pitch_60_96_22050_Q25_minusQuarter.mat'
+% 'MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThird.mat'
+% 'MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThreeQuarters.mat'
+% 'MIDI_FB_ellip_pitch_60_96_22050_Q25_minusTwoThird.mat'
+%
+% Output:
+% f_pitch
+% sideinfo
+%
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Check parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<3
+ sideinfo=[];
+end
+
+if nargin<2
+ parameter=[];
+end
+if isfield(parameter,'visualize')==0
+ parameter.visualize = 0;
+end
+if isfield(parameter,'save')==0
+ parameter.save = 0;
+end
+if isfield(parameter,'saveDir')==0
+ parameter.saveDir = '';
+end
+if isfield(parameter,'saveFilename')==0
+ parameter.saveFilename = '';
+end
+if isfield(parameter,'saveAsTuned')==0
+ parameter.saveAsTuned = 0;
+end
+if isfield(parameter,'fs')==0
+ parameter.fs = 22050;
+else
+ if parameter.fs ~= 22050
+ error('audio_to_pitch_via_FB not implemented yet for sample rates other than 22050.');
+ end
+end
+if isfield(parameter,'midiMin')==0
+ parameter.midiMin = 21;
+end
+if isfield(parameter,'midiMax')==0
+ parameter.midiMax = 108;
+end
+if isfield(parameter,'winLenSTMSP')==0
+ parameter.winLenSTMSP = 4410;
+ %parameter.winLenSTMSP = [882 4410];
+end
+if isfield(parameter,'shiftFB')==0
+ parameter.shiftFB = 0;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Main program
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if parameter.shiftFB == 0
+ load MIDI_FB_ellip_pitch_60_96_22050_Q25.mat
+elseif parameter.shiftFB == 1
+ load MIDI_FB_ellip_pitch_60_96_22050_Q25_minusQuarter.mat
+elseif parameter.shiftFB == 2
+ load MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThird.mat
+elseif parameter.shiftFB == 3
+ load MIDI_FB_ellip_pitch_60_96_22050_Q25_minusHalf.mat
+elseif parameter.shiftFB == 4
+ load MIDI_FB_ellip_pitch_60_96_22050_Q25_minusTwoThird.mat
+elseif parameter.shiftFB == 5
+ load MIDI_FB_ellip_pitch_60_96_22050_Q25_minusThreeQuarters.mat
+else
+ error('Wrong shift parameter!')
+end
+
+fs_pitch = zeros(1,128);
+fs_index = zeros(1,128);
+
+fs_pitch(21:59) = 882;
+fs_pitch(60:95) = 4410;
+fs_pitch(96:120) = 22050;
+
+fs_index(21:59) = 3;
+fs_index(60:95) = 2;
+fs_index(96:120) = 1;
+
+pcm_ds = cell(3,1);
+pcm_ds{1} = f_audio;
+pcm_ds{2} = resample(pcm_ds{1},1,5,100);
+pcm_ds{3} = resample(pcm_ds{2},1,5,100);
+
+fprintf('Computing subbands and STMSP for all pitches: (%i-%i): %4i',parameter.midiMin,parameter.midiMax,0);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Compute features for all pitches
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+winLenSTMSP = parameter.winLenSTMSP;
+winOvSTMSP = round(winLenSTMSP/2);
+featureRate = parameter.fs./(winLenSTMSP-winOvSTMSP); %formerly win_res
+wav_size = size(f_audio,1);
+
+num_window = length(winLenSTMSP);
+f_pitch_energy = cell(num_window,1);
+seg_pcm_num = cell(num_window,1);
+seg_pcm_start = cell(num_window,1);
+seg_pcm_stop = cell(num_window,1);
+for w=1:num_window;
+ step_size = winLenSTMSP(w)-winOvSTMSP(w);
+ group_delay = round(winLenSTMSP(w)/2);
+ seg_pcm_start{w} = [1 1:step_size:wav_size]'; %group delay is adjusted
+ seg_pcm_stop{w} = min(seg_pcm_start{w}+winLenSTMSP(w),wav_size);
+ seg_pcm_stop{w}(1) = min(group_delay,wav_size);
+ seg_pcm_num{w} = size(seg_pcm_start{w},1);
+ f_pitch_energy{w} = zeros(120,seg_pcm_num{w});
+end
+
+
+for p=parameter.midiMin:parameter.midiMax
+ fprintf('\b\b\b\b');fprintf('%4i',p);
+ index = fs_index(p);
+ f_filtfilt = filtfilt(h(p).b, h(p).a, pcm_ds{index});
+ f_square = f_filtfilt.^2;
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % f_pitch_energy
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ for w=1:length(winLenSTMSP)
+ factor = (parameter.fs/fs_pitch(p)); %adjustment for sampling rate
+ for k=1:seg_pcm_num{w}
+ start = ceil((seg_pcm_start{w}(k)/parameter.fs)*fs_pitch(p));
+ stop = floor((seg_pcm_stop{w}(k)/parameter.fs)*fs_pitch(p));
+ f_pitch_energy{w}(p,k)=sum(f_square(start:stop))*factor;
+ end
+ end
+end
+fprintf('\n');
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Save f_pitch_energy for each window size separately as f_pitch
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+sideinfo.pitch.version = 1;
+sideinfo.pitch.midiMin = parameter.midiMin;
+sideinfo.pitch.midiMax = parameter.midiMax;
+if parameter.save == 1
+ for w=1:num_window;
+ f_pitch = f_pitch_energy{w};
+ sideinfo.pitch.winLenSTMSP = winLenSTMSP(w);
+ sideinfo.pitch.winOvSTMSP = winOvSTMSP(w);
+ sideinfo.pitch.featureRate = featureRate(w);
+ sideinfo.pitch.shiftFB = parameter.shiftFB;
+ sideinfo.pitch.featuresAreTuned = 0;
+ if parameter.saveAsTuned
+ sideinfo.pitch.featuresAreTuned = 1;
+ filename = strcat(parameter.saveFilename,'_pitch_',num2str(winLenSTMSP(w)));
+ else
+ switch(parameter.shiftFB)
+ case 0
+ filename = strcat(parameter.saveFilename,'_pitch_',num2str(winLenSTMSP(w)));
+ case 1
+ filename = strcat(parameter.saveFilename,'_pitch_',num2str(winLenSTMSP(w)),'_minusQuarter');
+ case 2
+ filename = strcat(parameter.saveFilename,'_pitch_',num2str(winLenSTMSP(w)),'_minusThird');
+ case 3
+ filename = strcat(parameter.saveFilename,'_pitch_',num2str(winLenSTMSP(w)),'_minusHalf');
+ case 4
+ filename = strcat(parameter.saveFilename,'_pitch_',num2str(winLenSTMSP(w)),'_minusTwoThird');
+ case 5
+ filename = strcat(parameter.saveFilename,'_pitch_',num2str(winLenSTMSP(w)),'_minusThreeQuarter');
+ end
+ end
+ save(strcat(parameter.saveDir,filename),'f_pitch','sideinfo');
+ end
+else
+ f_pitch = f_pitch_energy{num_window};
+ sideinfo.pitch.winLenSTMSP = winLenSTMSP(num_window);
+ sideinfo.pitch.winOvSTMSP = winOvSTMSP(num_window);
+ sideinfo.pitch.featureRate = featureRate(num_window);
+ sideinfo.pitch.shiftFB = parameter.shiftFB;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.visualize == 1
+ for w=1:num_window;
+ parameterVis.featureRate = featureRate(w);
+ visualizePitch(f_pitch_energy{w},parameterVis);
+ end
+end
+
+end
+
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Burgmueller_Op100-02-FirstPart_Meinard_SE.wav
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Burgmueller_Op100-02-FirstPart_Meinard_SE.wav has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Cadence-C-Major_Meinard_portato.wav
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Cadence-C-Major_Meinard_portato.wav has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Cadence-C-Major_Meinard_staccato.wav
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Cadence-C-Major_Meinard_staccato.wav has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Chord-C-Major_Eight-Instruments.wav
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Chord-C-Major_Eight-Instruments.wav has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Scale-C-Major_Meinard_fast.wav
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Scale-C-Major_Meinard_fast.wav has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Scale-C-Major_Meinard_middle.wav
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_WAV/Systematic_Scale-C-Major_Meinard_middle.wav has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Bach_BWV988-Aria-Measures1-4_Meinard_fast_pitch_4410.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Bach_BWV988-Aria-Measures1-4_Meinard_fast_pitch_4410.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Burgmueller_Op100-02-FirstPart_Meinard_SE_pitch_4410.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Burgmueller_Op100-02-FirstPart_Meinard_SE_pitch_4410.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Cadence-C-Major_Meinard_portato_pitch_4410.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Cadence-C-Major_Meinard_portato_pitch_4410.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Cadence-C-Major_Meinard_staccato_pitch_4410.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Cadence-C-Major_Meinard_staccato_pitch_4410.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Chord-C-Major_Eight-Instruments_CRP_1_1.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Chord-C-Major_Eight-Instruments_CRP_1_1.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Chord-C-Major_Eight-Instruments_CRP_21_5.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Chord-C-Major_Eight-Instruments_CRP_21_5.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Chord-C-Major_Eight-Instruments_pitch_4410.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Chord-C-Major_Eight-Instruments_pitch_4410.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Scale-C-Major_Meinard_fast_pitch_4410.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Scale-C-Major_Meinard_fast_pitch_4410.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Scale-C-Major_Meinard_middle_pitch_4410.mat
Binary file matlab/MATLAB-Chroma-Toolbox_2.0/data_feature/Systematic_Scale-C-Major_Meinard_middle_pitch_4410.mat has changed
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/demoChromaToolbox.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/demoChromaToolbox.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,85 @@
+clear
+close all
+
+filename = 'Systematic_Chord-C-Major_Eight-Instruments.wav';
+[f_audio,sideinfo] = wav_to_audio('', 'data_WAV/', filename);
+shiftFB = estimateTuning(f_audio);
+
+paramPitch.winLenSTMSP = 4410;
+paramPitch.shiftFB = shiftFB;
+paramPitch.visualize = 1;
+[f_pitch,sideinfo] = ...
+ audio_to_pitch_via_FB(f_audio,paramPitch,sideinfo);
+
+paramCP.applyLogCompr = 0;
+paramCP.visualize = 1;
+paramCP.inputFeatureRate = sideinfo.pitch.featureRate;
+[f_CP,sideinfo] = pitch_to_chroma(f_pitch,paramCP,sideinfo);
+
+paramCLP.applyLogCompr = 1;
+paramCLP.factorLogCompr = 100;
+paramCLP.visualize = 1;
+paramCLP.inputFeatureRate = sideinfo.pitch.featureRate;
+[f_CLP,sideinfo] = pitch_to_chroma(f_pitch,paramCLP,sideinfo);
+
+paramCENS.winLenSmooth = 21;
+paramCENS.downsampSmooth = 5;
+paramCENS.visualize = 1;
+paramCENS.inputFeatureRate = sideinfo.pitch.featureRate;
+[f_CENS,sideinfo] = pitch_to_CENS(f_pitch,paramCENS,sideinfo);
+
+paramCRP.coeffsToKeep = [55:120];
+paramCRP.visualize = 1;
+paramCRP.inputFeatureRate = sideinfo.pitch.featureRate;
+[f_CRP,sideinfo] = pitch_to_CRP(f_pitch,paramCRP,sideinfo);
+
+paramSmooth.winLenSmooth = 21;
+paramSmooth.downsampSmooth = 5;
+paramSmooth.inputFeatureRate = sideinfo.CRP.featureRate;
+[f_CRPSmoothed, featureRateSmoothed] = ...
+ smoothDownsampleFeature(f_CRP,paramSmooth);
+parameterVis.featureRate = featureRateSmoothed;
+visualizeCRP(f_CRPSmoothed,parameterVis);
+
+
+% filename = 'Systematic_Chord-C-Major_Eight-Instruments.wav';
+% [f_audio,sideinfo] = wav_to_audio('', 'data_WAV/', filename);
+% shiftFB = estimateTuning(f_audio);
+%
+% paramPitch.win_len = 4410;
+% paramPitch.shiftFB = shiftFB;
+% paramPitch.visualize = 1;
+% [f_pitch,sideinfo] = ...
+% audio_to_pitch_via_FB(f_audio,paramPitch,sideinfo);
+%
+% paramCP.applyLogCompr = 0;
+% paramCP.visualize = 1;
+% paramCP.inputFeatureRate = sideinfo.pitch.featureRate;
+% [f_CP,sideinfo] = pitch_to_chroma(f_pitch,paramCP,sideinfo);
+%
+% paramCLP.applyLogCompr = 1;
+% paramCLP.logParamMult = 100;
+% paramCLP.visualize = 1;
+% paramCLP.inputFeatureRate = sideinfo.pitch.featureRate;
+% [f_CLP,sideinfo] = pitch_to_chroma(f_pitch,paramCLP,sideinfo);
+%
+% paramCENS.stat_window_length = 21;
+% paramCENS.stat_downsample = 5;
+% paramCENS.visualize = 1;
+% paramCENS.inputFeatureRate = sideinfo.pitch.featureRate;
+% [f_CENS,sideinfo] = pitch_to_CENS(f_pitch,paramCENS,sideinfo);
+%
+% paramCRP.coeffsToKeep = [55:120];
+% paramCRP.visualize = 1;
+% paramCRP.inputFeatureRate = sideinfo.pitch.featureRate;
+% [f_CRP,sideinfo] = pitch_to_CRP(f_pitch,paramCRP,sideinfo);
+%
+% paramSmooth.stat_window_length = 21;
+% paramSmooth.stat_downsample = 5;
+% paramSmooth.inputFeatureRate = sideinfo.CRP.featureRate;
+% [f_CRPSmoothed, featureRateSmoothed] = ...
+% smoothDownsampleFeature(f_CRP,paramSmooth);
+% parameterVis.featureRate = featureRateSmoothed;
+% visualize_CRP(f_CRPSmoothed,parameterVis);
+
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/estimateTuning.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/estimateTuning.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,230 @@
+function [shiftFB,centerA4,tuningSemitones,sideinfo] = estimateTuning(f_input,parameter,sideinfo)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: estimateTuning
+% Date of Revision: 2011-03
+% Programmer: Sebastian Ewert
+%
+% Description:
+% - input is either a mono audio signal or a real valued spectrogram (magnitude or power)
+% - if input is a spectrogram you have to set parameter.timeinfo and
+% parameter.freqinfo (vectors defining the time and freq centers for each spectrogram bin)
+% - if input is an audio signal, a sampling freq of 22050 Hz is assumed
+% - guesses the tuning according to a simple energy maximizing criterion
+% - output is either: what shiftFB is best to use (shiftFB \in [0:5]).
+% Alternatively, the center freq for A4 is given which can be used to
+% specify a filterbank on your own. The second option is more fine
+% grained.
+% Alternatively, it gives a tuning in semitones, which can
+% easily be shifted cyclicly. For example: a tuning of -19/20 is more likely to be
+% +1/20 Tuning difference.
+% - parameter.numAdditionalTunings: how many tunings besides the fixed shiftFB ones
+% to test. For example: If set to 3, than three additional tuning settings are
+% tested for, located at 1/4, 2/4 and 3/4 semitones below the reference
+% tuning. If set to 5, then at 1/6, 2/6,..., 5/6 semitones.
+% - parameter.pitchRange specifies which pitches are considered for the
+% tuning estimation.
+% - parameter.pitchWeights: each pitch is considered according to a weight
+% - Middle pitches are considered as being more important per default because
+% here the frequency resolution is high enough. Additionally the piano has
+% a consistent tuning only for middle pitches.
+%
+% Input:
+% f_input
+% parameter.numAdditionalTunings = 0;
+% parameter.pitchRange = [21:108];
+% parameter.pitchWeights = gausswin(length(parameter.pitchRange)).^2;
+% parameter.fftWindowLength = 8192;
+% parameter.windowFunction = @hanning;
+% sideinfo
+%
+% Output:
+% shiftFB
+% centerA4
+% tuningSemitones
+% sideinfo
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Check parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<2
+ parameter=[];
+end
+if nargin<1
+ error('Please specify input data');
+end
+
+if isfield(parameter,'numAdditionalTunings')==0
+ parameter.numAdditionalTunings = 0;
+end
+if isfield(parameter,'pitchRange')==0
+ % Which pitches to consider during the estimation
+ parameter.pitchRange = [21:108];
+end
+if isfield(parameter,'pitchWeights')==0
+ % assign a weight to each pitch specified in parameter.pitchRange to
+ % specify it's importance
+ parameter.pitchWeights = gausswin(length(parameter.pitchRange)).^2;
+end
+
+% the following parameters are only for audio signal input
+if isfield(parameter,'fftWindowLength')==0
+ parameter.fftWindowLength = 8192;
+end
+if isfield(parameter,'windowFunction')==0
+ parameter.windowFunction = @hanning; % only tested with hanning.
+end
+
+if min(size(f_input)) == 1
+ inputIsAudioSignal = 1;
+else
+ inputIsAudioSignal = 0;
+end
+
+if ~inputIsAudioSignal
+ if isfield(parameter,'freqinfo')==0
+ error('When using a spectrogram input you have to set parameter.freqinfo');
+ end
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Main program
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+numTunings = 6 + parameter.numAdditionalTunings;
+referenceFreqsA4 = zeros(numTunings,1);
+tunings = zeros(numTunings,1);
+
+tunings(1) = 0;
+tunings(2) = -1/4;
+tunings(3) = -1/3;
+tunings(4) = -1/2;
+tunings(5) = -2/3;
+tunings(6) = -3/4;
+for k=1:parameter.numAdditionalTunings
+ tunings(k+6) = -k/(parameter.numAdditionalTunings+1);
+end
+referenceFreqsA4 = 2.^((69-69+tunings)/12) * 440;
+
+if inputIsAudioSignal
+ [s,f,t] = spectrogram(f_input, parameter.windowFunction(parameter.fftWindowLength), parameter.fftWindowLength/2, parameter.fftWindowLength, 22050);
+else
+ s = f_input;
+ f = parameter.freqinfo;
+end
+s = abs(s);
+
+directFreqBinSearch = 0;
+if all( (f(2:end)-f(1:end-1)) - (f(2)-f(1)) < eps )
+ directFreqBinSearch = 1;
+end
+
+averagedPowerSpectrogram = sum(s.^2,2);
+totalPitchEnergyViaSpec = zeros(numTunings,1);
+for tu=1:numTunings
+ centerfreqs = 2.^((parameter.pitchRange-69)/12) * referenceFreqsA4(tu);
+ upperborderfreqs = 2.^((parameter.pitchRange-68.5)/12) * referenceFreqsA4(tu);
+ lowerborderfreqs = 2.^((parameter.pitchRange-69.5)/12) * referenceFreqsA4(tu);
+
+ % build triangular filterbank for magnitude spectrogram
+ spectrogramFilter = zeros(length(f),1);
+ for k=1:length(parameter.pitchRange)
+ c = getCorrespondingBin(f,centerfreqs(k),directFreqBinSearch);
+ u = getCorrespondingBin(f,upperborderfreqs(k),directFreqBinSearch);
+ l = getCorrespondingBin(f,lowerborderfreqs(k),directFreqBinSearch);
+
+ % order is important here. If third parameter is < 2, then linspace
+ % returns the second parameter
+ spectrogramFilter(c:u) = parameter.pitchWeights(k) * linspace(1,0,u-c+1);
+ spectrogramFilter(l:c) = parameter.pitchWeights(k) * linspace(0,1,c-l+1);
+ end
+
+ totalPitchEnergyViaSpec(tu) = sum(spectrogramFilter.^2 .* averagedPowerSpectrogram);
+end
+
+[ignoreMe, maxIndex] = max(totalPitchEnergyViaSpec(1:6));
+shiftFB = maxIndex-1;
+
+[ignoreMe, maxIndex] = max(totalPitchEnergyViaSpec);
+centerA4 = referenceFreqsA4(maxIndex);
+tuningSemitones = tunings(maxIndex);
+
+sideinfo.tuning.shiftFB = shiftFB;
+sideinfo.tuning.centerA4 = centerA4;
+sideinfo.tuning.tuningSemitones = tuningSemitones;
+sideinfo.tuning.method = 'estimateTuningV1';
+sideinfo.tuning.numAdditionalTunings = parameter.numAdditionalTunings;
+sideinfo.tuning.pitchRange = parameter.pitchRange;
+sideinfo.tuning.pitchWeights = parameter.pitchWeights;
+sideinfo.tuning.fftWindowLength = parameter.fftWindowLength;
+sideinfo.tuning.windowFunction = parameter.windowFunction;
+sideinfo.tuning.inputWasAudioSignal = inputIsAudioSignal;
+
+end
+
+function index = getCorrespondingBin(x,sval,directSearch)
+% - Finds the entry in x with the smallest absolute distance to sval.
+% - x is assumed to be sorted (ascending)
+% - 'directSearch' means that all values in x are equally spaced
+% - x is assumed to be at least of length 2.
+% - If directSearch==0 then we use binary seach to find the entry
+%
+% You can test the correctness of this procedure by comparing it against
+% the result of: [ignoreMe index] = min(abs(x-sval))
+%
+% Author: Sebastian Ewert
+
+if sval >= x(end)
+ index = length(x);
+ return;
+elseif sval <= x(1)
+ index = 1;
+ return;
+end
+
+
+if directSearch
+ index = round( (sval-x(1)) / (x(2)-x(1))) + 1;
+else
+ from=1;
+ to=length(x);
+
+ while from<=to
+ mid = round((from + to)/2);
+ diff = x(mid)-sval;
+ if diff<0 % x(mid) < sval
+ from=mid;
+ else % x(mid) => sval
+ to=mid;
+ end
+
+ if to-from==1
+ break;
+ end
+ end
+ if abs(x(from)-sval) < abs(x(to)-sval)
+ index = from;
+ else
+ index = to;
+ end
+end
+
+end
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/generateMultiratePitchFilterbank.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/generateMultiratePitchFilterbank.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,134 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Generating filter bank of filters corresponding MIDI pitches
+%
+% Pitches 21-59, fs = 882
+% Pitches 60-95, fs = 4410
+% Pitches 96-120, fs =22050
+%
+% Q (center frequency) / bandwidt, Q > 30 separates notes
+% stop: pass_rel = 1/(2*Q); stop_rel = stop*pass_rel;
+% Rp loses no more than Rp dB in the passband
+% Rs attenuation in the stopband in dB
+%
+% For details to filter desgin use MATLAB help function
+% e.g., "help ellipord" and "help ellip"
+%
+% Attention: Construction of [b,a] may fail if the
+% filter specification are too restrictive
+%
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+clear;
+
+semitoneOffsets = [0, -0.25, -1/3, -0.5, -2/3, -0.75];
+nameSuffixes = {''; '_minusQuarter'; '_minusThird'; '_minusHalf'; '_minusTwoThird'; '_minusThreeQuarters'};
+
+for k=1:length(semitoneOffsets)
+
+
+ midi = (1:128); % midi notes
+ midi_freq = 2.^((midi-69+semitoneOffsets(k))/12)*440; % computing frequencies of midi notes
+ nameSuffix = nameSuffixes{k};
+ h(120)=struct('a',[],'b',[]);
+
+ disp(['Generating Filterbank: ',nameSuffix]);
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % fs = 22005, pitches 96-120
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ fs = 22050;
+ nyq = fs/2;
+ midi_min = 96;
+ midi_max = 120;
+ Q = 25; stop = 2; Rp = 1; Rs = 50;
+ pass_rel = 1/(2*Q);
+ stop_rel = pass_rel*stop;
+
+ for k = midi_min:midi_max;
+ pitch = midi_freq(k);
+ Wp = [pitch-pass_rel*pitch pitch+pass_rel*pitch]/nyq;
+ Ws = [pitch-stop_rel*pitch pitch+stop_rel*pitch]/nyq;
+ [n Wn]=ellipord(Wp,Ws,Rp,Rs);
+ [h(k).b,h(k).a]=ellip(n,Rp,Rs,Wn);
+ end
+ num = midi_max-midi_min+1;
+ h_fvtool = cell(2*num,1);
+ for i = 1:num
+ h_fvtool{2*i-1}=h(midi_min+i-1).b;
+ h_fvtool{2*i}=h(midi_min+i-1).a;
+ end
+ fvtool(h_fvtool{:});
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % fs = 4410, pitches 60-95
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ fs = 4410;
+ nyq = fs/2;
+ midi_min = 60;
+ midi_max = 95;
+ Q = 25; stop = 2; Rp = 1; Rs = 50;
+ pass_rel = 1/(2*Q);
+ stop_rel = pass_rel*stop;
+
+ for k = midi_min:midi_max;
+ pitch = midi_freq(k);
+ Wp = [pitch-pass_rel*pitch pitch+pass_rel*pitch]/nyq;
+ Ws = [pitch-stop_rel*pitch pitch+stop_rel*pitch]/nyq;
+ [n Wn]=ellipord(Wp,Ws,Rp,Rs);
+ [h(k).b,h(k).a]=ellip(n,Rp,Rs,Wn);
+ end
+ num = midi_max-midi_min+1;
+ h_fvtool = cell(2*num,1);
+ for i = 1:num
+ h_fvtool{2*i-1}=h(midi_min+i-1).b;
+ h_fvtool{2*i}=h(midi_min+i-1).a;
+ end
+ fvtool(h_fvtool{:});
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % fs = 882, pitches 21-59
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ fs = 882;
+ nyq = fs/2;
+ midi_min = 21;
+ midi_max = 59;
+ Q = 25; stop = 2; Rp = 1; Rs = 50;
+ pass_rel = 1/(2*Q);
+ stop_rel = pass_rel*stop;
+
+ for k = midi_min:midi_max;
+ pitch = midi_freq(k);
+ Wp = [pitch-pass_rel*pitch pitch+pass_rel*pitch]/nyq;
+ Ws = [pitch-stop_rel*pitch pitch+stop_rel*pitch]/nyq;
+ [n Wn]=ellipord(Wp,Ws,Rp,Rs);
+ [h(k).b,h(k).a]=ellip(n,Rp,Rs,Wn);
+ end
+ num = midi_max-midi_min+1;
+ h_fvtool = cell(2*num,1);
+ for i = 1:num
+ h_fvtool{2*i-1}=h(midi_min+i-1).b;
+ h_fvtool{2*i}=h(midi_min+i-1).a;
+ end
+ fvtool(h_fvtool{:});
+
+
+ save(['MIDI_FB_ellip_pitch_60_96_22050_Q25',nameSuffix],'h','-V6');
+
+end
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/normalizeFeature.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/normalizeFeature.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,52 @@
+function f_featureNorm = normalizeFeature(f_feature,normP, threshold)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: normalizeFeature
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% - Normalizes a feature sequence according to the l^p norm
+% - If the norm falls below threshold for a feature vector, then the
+% normalized feature vector is set to be the unit vector.
+%
+% Input:
+% f_feature
+% normP
+% threshold
+%
+% Output:
+% f_featureNorm
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+f_featureNorm = zeros(size(f_feature));
+
+% normalise the vectors according to the l^p norm
+unit_vec = ones(1,12);
+unit_vec = unit_vec/norm(unit_vec,normP);
+for k=1:size(f_feature,2);
+ n = norm(f_feature(:,k),normP);
+ if n < threshold
+ f_featureNorm(:,k) = unit_vec;
+ else
+ f_featureNorm(:,k) = f_feature(:,k)/n;
+ end
+end
+
+end
\ No newline at end of file
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/pitch_to_CENS.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/pitch_to_CENS.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,176 @@
+function [f_CENS,sideinfo] = pitch_to_CENS(f_pitch,parameter,sideinfo)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: pitch_to_CENS
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% Normalized statistical chroma-based energy distribution feature (CENS).
+% The following is computed:
+% * energy for each chroma band
+% * normalisation of the chroma vectors
+% * local statistics:
+% - component-wise quantisation of the normalized chroma vectors
+% - upfirdn filters and downsamples each column of f_stat_help
+% - normalize each vector with its l^2 norm
+%
+% Remark:
+% * parameter.inputFeatureRate specifies the feature rate of f_pitch. The value
+% is used to derive the output feature rate given via sideinfo.
+%
+% Input:
+% f_pitch
+% parameter.quantSteps = [40 20 10 5] / 100;
+% parameter.quantWeights = [ 1 1 1 1]/4;
+% parameter.normThresh = 0.001;
+% parameter.winLenSmooth = 41;
+% parameter.downsampSmooth = 10;
+% parameter.midiMin = 21;
+% parameter.midiMax = 108;
+% parameter.inputFeatureRate = 0;
+% parameter.save = 0;
+% parameter.saveDir = '';
+% parameter.saveFilename = '';
+% parameter.visualize = 0;
+% sideinfo
+%
+% Output:
+% f_CENS
+% sideinfo
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Check parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<3
+ sideinfo=[];
+end
+if nargin<2
+ parameter=[];
+end
+if nargin<1
+ error('Please specify input data f_pitch');
+end
+
+if isfield(parameter,'quantSteps')==0
+ parameter.quantSteps = [40 20 10 5] / 100;
+end
+if isfield(parameter,'quantWeights')==0
+ parameter.quantWeights = [ 1 1 1 1]/4;
+end
+if isfield(parameter,'normThresh')==0
+ parameter.normThresh = 0.001;
+end
+if isfield(parameter,'winLenSmooth')==0
+ parameter.winLenSmooth = 41;
+end
+if isfield(parameter,'downsampSmooth')==0
+ parameter.downsampSmooth = 10;
+end
+if isfield(parameter,'midiMin')==0
+ parameter.midiMin = 21;
+end
+if isfield(parameter,'midiMax')==0
+ parameter.midiMax = 108;
+end
+if isfield(parameter,'inputFeatureRate')==0
+ parameter.inputFeatureRate = 0;
+end
+if isfield(parameter,'save')==0
+ parameter.save = 0;
+end
+if isfield(parameter,'saveDir')==0
+ parameter.saveDir = '';
+end
+if isfield(parameter,'saveFilename')==0
+ parameter.saveFilename = '';
+end
+if isfield(parameter,'visualize')==0
+ parameter.visualize = 0;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Main program
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+seg_num = size(f_pitch,2);
+
+% calculate energy for each chroma band
+f_chroma_energy = zeros(12,seg_num);
+for p=parameter.midiMin:parameter.midiMax
+ chroma = mod(p,12)+1;
+ f_chroma_energy(chroma,:) = f_chroma_energy(chroma,:)+f_pitch(p,:);
+end
+
+% normalize the chroma vectors
+f_chroma_energy_distr = zeros(12,seg_num);
+for k=1:seg_num
+ if sum(f_chroma_energy(:,k)>parameter.normThresh)>0
+ seg_energy_square = sum(f_chroma_energy(:,k));
+ f_chroma_energy_distr(:,k) = ((f_chroma_energy(:,k))/seg_energy_square);
+ end
+end
+
+% calculate a CENS feature
+
+% component-wise quantisation of the normalized chroma vectors
+f_stat_help = zeros(12,seg_num);
+for n=1:length(parameter.quantSteps)
+ f_stat_help = f_stat_help + (f_chroma_energy_distr>parameter.quantSteps(n))*parameter.quantWeights(n);
+end
+
+% Temporal smoothing and downsampling
+[f_chroma_energy_stat,CENSfeatureRate] = smoothDownsampleFeature(f_stat_help,parameter);
+
+% last step: normalize each vector with its l^2 norm
+f_CENS = normalizeFeature(f_chroma_energy_stat,2, parameter.normThresh);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Update sideinfo
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+sideinfo.CENS.version = 1;
+sideinfo.CENS.midiMin = parameter.midiMin;
+sideinfo.CENS.midiMax = parameter.midiMax;
+sideinfo.CENS.featureRate = CENSfeatureRate;
+sideinfo.CENS.quantSteps = parameter.quantSteps;
+sideinfo.CENS.quantWeights = parameter.quantWeights;
+sideinfo.CENS.normThresh = parameter.normThresh;
+sideinfo.CENS.winLenSmooth = parameter.winLenSmooth;
+sideinfo.CENS.downsampSmooth = parameter.downsampSmooth;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Saving to file
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.save
+ filename = strcat(parameter.saveFilename,'_CENS_',num2str(parameter.winLenSmooth),'_',num2str(parameter.downsampSmooth));
+ save(strcat(parameter.saveDir,filename),'f_CENS','sideinfo');
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.visualize
+ parameterVis.featureRate = CENSfeatureRate;
+ parameterVis.title = 'CENS chromagram';
+ visualizeChroma(f_CENS,parameterVis)
+end
+
+end
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/pitch_to_CRP.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/pitch_to_CRP.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,194 @@
+function [f_CRP,sideinfo] = pitch_to_CRP(f_pitch,parameter,sideinfo)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: pitch_to_CRP
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% - Calculates CRP (Chroma DCT-reduced Log Pitch) Features
+% (see "Towards Timbre-Invariant Audio Features for Harmony-Based Music" by
+% Meinard Mueller and Sebastian Ewert)
+%
+% Remark:
+% - parameter.inputFeatureRate specifies the input feature rate. This value is
+% used to derive the output feature rate.
+%
+% Input:
+% f_pitch
+% parameter.coeffsToKeep = [55:120];
+% parameter.applyLogCompr = 1;
+% parameter.factorLogCompr = 1000;
+% parameter.addTermLogCompr = 1;
+% parameter.normP = 2;
+% parameter.winLenSmooth = 1;
+% parameter.downsampSmooth = 1;
+% parameter.normThresh = 10^-6;
+% parameter.inputFeatureRate = 0;
+% parameter.save = 0;
+% parameter.saveDir = '';
+% parameter.saveFilename = '';
+% parameter.visualize = 0;
+% sideinfo
+%
+% Output:
+% f_CRP
+% sideinfo
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Check parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<3
+ sideinfo=[];
+end
+if nargin<2
+ parameter=[];
+end
+if nargin<1
+ error('Please specify input data f_pitch');
+end
+
+if isfield(parameter,'coeffsToKeep')==0
+ parameter.coeffsToKeep = [55:120];
+end
+if isfield(parameter,'applyLogCompr')==0
+ parameter.applyLogCompr = 1;
+end
+if isfield(parameter,'factorLogCompr')==0
+ parameter.factorLogCompr = 1000;
+end
+if isfield(parameter,'addTermLogCompr')==0
+ parameter.addTermLogCompr = 1;
+end
+if isfield(parameter,'normP')==0
+ parameter.normP = 2;
+end
+if isfield(parameter,'winLenSmooth')==0
+ parameter.winLenSmooth = 1;
+end
+if isfield(parameter,'downsampSmooth')==0
+ parameter.downsampSmooth = 1;
+end
+if isfield(parameter,'normThresh')==0
+ parameter.normThresh = 10^-6;
+end
+if isfield(parameter,'inputFeatureRate')==0
+ parameter.inputFeatureRate = 0;
+end
+if isfield(parameter,'save')==0
+ parameter.save = 0;
+end
+if isfield(parameter,'saveDir')==0
+ parameter.saveDir = '';
+end
+if isfield(parameter,'saveFilename')==0
+ parameter.saveFilename = '';
+end
+if isfield(parameter,'visualize')==0
+ parameter.visualize = 0;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Main program
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+seg_num = size(f_pitch,2);
+
+% log compression
+if parameter.applyLogCompr
+ f_pitch_log = log10(parameter.addTermLogCompr+f_pitch*parameter.factorLogCompr);
+else
+ f_pitch_log = f_pitch;
+end
+
+% DCT based reduction
+DCT = internal_DCT(size(f_pitch_log,1));
+DCTcut = DCT;
+DCTcut(setdiff([1:120],parameter.coeffsToKeep),:) = 0;
+DCT_filter = DCT'*DCTcut;
+f_pitch_log_DCT = DCT_filter*f_pitch_log;
+
+% calculate energy for each chroma band
+f_CRP = zeros(12,seg_num);
+for p=1:120
+ chroma = mod(p,12)+1;
+ f_CRP(chroma,:) = f_CRP(chroma,:)+f_pitch_log_DCT(p,:);
+end
+
+% normalize the vectors according to the norm l^p
+f_CRP = normalizeFeature(f_CRP,parameter.normP, parameter.normThresh);
+
+if (parameter.winLenSmooth ~= 1) || (parameter.downsampSmooth ~= 1)
+ % Temporal smoothing and downsampling
+ [f_CRP,CrpFeatureRate] = smoothDownsampleFeature(f_CRP,parameter);
+
+ % re-normalize the vectors according to the norm l^p
+ f_CRP = normalizeFeature(f_CRP,parameter.normP, parameter.normThresh);
+else
+ CrpFeatureRate = parameter.inputFeatureRate;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Update sideinfo
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+sideinfo.CRP.coeffsToKeep = parameter.coeffsToKeep;
+sideinfo.CRP.applyLogCompr = parameter.applyLogCompr;
+sideinfo.CRP.factorLogCompr = parameter.factorLogCompr;
+sideinfo.CRP.addTermLogCompr = parameter.addTermLogCompr;
+sideinfo.CRP.normP = parameter.normP;
+sideinfo.CRP.winLenSmooth = parameter.winLenSmooth;
+sideinfo.CRP.downsampSmooth = parameter.downsampSmooth;
+sideinfo.CRP.normThresh = parameter.normThresh;
+sideinfo.CRP.featureRate = CrpFeatureRate;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Saving to file
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.save
+ filename = strcat(parameter.saveFilename,'_CRP_',num2str(parameter.winLenSmooth),'_',num2str(parameter.downsampSmooth));
+ save(strcat(parameter.saveDir,filename),'f_CRP','sideinfo');
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.visualize
+ parameterVis.title = 'CRP chromagram';
+ parameterVis.featureRate = CrpFeatureRate;
+ visualizeCRP(f_CRP,parameterVis);
+end
+
+end
+
+function matrix = internal_DCT(l)
+
+matrix = zeros(l,l);
+
+for m = 0:l-1
+ for n = 0:l-1
+ matrix(m+1,n+1) = sqrt(2/l)*cos((m*(n+0.5)*pi)/l);
+ end
+end
+
+matrix(1,:) = matrix(1,:)/sqrt(2);
+
+end
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/pitch_to_chroma.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/pitch_to_chroma.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,179 @@
+function [f_chroma_norm,sideinfo] = pitch_to_chroma(f_pitch,parameter,sideinfo)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: pitch_to_chroma
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% Computes normalized chroma vectors from pitch features
+%
+% Input:
+% f_pitch
+% parameter.applyLogCompr = 0;
+% parameter.factorLogCompr = 100;
+% parameter.addTermLogCompr = 1;
+% parameter.winLenSmooth = 1;
+% parameter.downsampSmooth = 1;
+% parameter.applyNormalization = 1;
+% parameter.normP = 2;
+% parameter.normThresh = 0.001;
+% parameter.midiMin = 1;
+% parameter.midiMax = 120;
+% parameter.inputFeatureRate = 0;
+% parameter.save = 0;
+% parameter.save_dir = '';
+% parameter.save_filename = '';
+% parameter.visualize = 0;
+% sideinfo
+%
+% Output:
+% f_chroma_norm
+% sideinfo
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Check parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<3
+ sideinfo=[];
+end
+if nargin<2
+ parameter=[];
+end
+if nargin<1
+ error('Please specify input data f_pitch');
+end
+
+if isfield(parameter,'applyLogCompr')==0
+ parameter.applyLogCompr = 0;
+end
+if isfield(parameter,'factorLogCompr')==0
+ parameter.factorLogCompr = 100;
+end
+if isfield(parameter,'addTermLogCompr')==0
+ parameter.addTermLogCompr = 1;
+end
+if isfield(parameter,'winLenSmooth')==0
+ parameter.winLenSmooth = 1;
+end
+if isfield(parameter,'downsampSmooth')==0
+ parameter.downsampSmooth = 1;
+end
+if isfield(parameter,'applyNormalization')==0
+ parameter.applyNormalization = 1;
+end
+if isfield(parameter,'normP')==0
+ parameter.normP = 2;
+end
+if isfield(parameter,'normThresh')==0
+ parameter.normThresh = 0.001;
+end
+if isfield(parameter,'midiMin')==0
+ parameter.midiMin = 1;
+end
+if isfield(parameter,'midiMax')==0
+ parameter.midiMax = 120;
+end
+if isfield(parameter,'inputFeatureRate')==0
+ parameter.inputFeatureRate = 0;
+end
+if isfield(parameter,'save')==0
+ parameter.save = 0;
+end
+if isfield(parameter,'save_dir')==0
+ parameter.save_dir = '';
+end
+if isfield(parameter,'save_filename')==0
+ parameter.save_filename = '';
+end
+if isfield(parameter,'visualize')==0
+ parameter.visualize = 0;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Main program
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+seg_num = size(f_pitch,2);
+
+if parameter.applyLogCompr
+ f_pitch = log10(parameter.addTermLogCompr+f_pitch*parameter.factorLogCompr);
+end
+
+% calculate energy for each chroma band
+f_chroma = zeros(12,seg_num);
+for p=parameter.midiMin:parameter.midiMax
+ chroma = mod(p,12)+1;
+ f_chroma(chroma,:) = f_chroma(chroma,:)+f_pitch(p,:);
+end
+
+% Temporal smoothing and downsampling
+[f_chroma,chromaFeatureRate] = smoothDownsampleFeature(f_chroma,parameter);
+
+if parameter.applyNormalization
+ % normalise the chroma vectors according the norm l^p
+ f_chroma_norm = normalizeFeature(f_chroma,parameter.normP, parameter.normThresh);
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Update sideinfo
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+sideinfo.chroma.applyLogCompr = parameter.applyLogCompr;
+sideinfo.chroma.factorLogCompr = parameter.factorLogCompr;
+sideinfo.chroma.addTermLogCompr = parameter.addTermLogCompr;
+sideinfo.chroma.winLenSmooth = parameter.winLenSmooth;
+sideinfo.chroma.downsampSmooth = parameter.downsampSmooth;
+sideinfo.chroma.applyNormalization = parameter.applyNormalization;
+sideinfo.chroma.normP = parameter.normP;
+sideinfo.chroma.normThresh = parameter.normThresh;
+sideinfo.chroma.midiMin = parameter.midiMin;
+sideinfo.chroma.midiMax = parameter.midiMax;
+sideinfo.chroma.chromaFeatureRate = chromaFeatureRate;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Saving to file
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.save == 1
+ filename = strcat(parameter.save_filename,'_chroma');
+ save(strcat(parameter.save_dir,filename),'f_chroma_norm','f_chroma','sideinfo');
+end
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.visualize
+ titleString = 'Chromagram';
+ imagerange = [0 1];
+ if parameter.applyLogCompr
+ titleString = ['Log ', titleString];
+ end
+ if parameter.applyNormalization
+ imagerange = 0;
+ titleString = ['Normalized ', titleString];
+ end
+ parameterVis.imagerange = imagerange;
+ parameterVis.featureRate = chromaFeatureRate;
+ parameterVis.title = titleString;
+ visualizeChroma(f_chroma_norm,parameterVis)
+end
+
+end
\ No newline at end of file
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/smoothDownsampleFeature.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/smoothDownsampleFeature.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,87 @@
+function [f_feature_stat,newFeatureRate] = smoothDownsampleFeature(f_feature,parameter)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: smoothDownsampleFeature
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% - Temporal smoothing and downsampling of a feature sequence
+%
+% Remark:
+% - parameter.featureRate specifies the input feature rate. This value is
+% used to derive the output feature rate.
+%
+% Input:
+% f_feature
+% parameter.winLenSmooth = 1;
+% parameter.downsampSmooth = 1;
+% parameter.inputFeatureRate = 0;
+%
+% Output:
+% f_feature
+% newFeatureRate
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Check parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<2
+ parameter=[];
+end
+if nargin<1
+ error('Please specify input data');
+end
+if isfield(parameter,'winLenSmooth')==0
+ parameter.winLenSmooth = 1;
+end
+if isfield(parameter,'downsampSmooth')==0
+ parameter.downsampSmooth = 1;
+end
+if isfield(parameter,'inputFeatureRate')==0
+ parameter.inputFeatureRate = 0;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Main program
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Temporal Smoothing
+if (parameter.winLenSmooth ~= 1) || (parameter.downsampSmooth ~= 1)
+ winLenSmooth = parameter.winLenSmooth;
+ downsampSmooth = parameter.downsampSmooth;
+ stat_window = hanning(winLenSmooth);
+ stat_window = stat_window/sum(stat_window);
+
+ % upfirdn filters and downsamples each column of f_stat_help
+ f_feature_stat = zeros(size(f_feature));
+ f_feature_stat = (upfirdn(f_feature',stat_window,1,downsampSmooth))';
+ seg_num = size(f_feature,2);
+ stat_num = ceil(seg_num/downsampSmooth);
+ cut = floor((winLenSmooth-1)/(2*downsampSmooth));
+ f_feature_stat = f_feature_stat(:,(1+cut:stat_num+cut)); %adjust group delay
+else
+ f_feature_stat = f_feature;
+end
+
+newFeatureRate = parameter.inputFeatureRate / parameter.downsampSmooth;
+
+end
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_audio_to_pitch.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_audio_to_pitch.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,104 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: test_convert_audio_to_pitchSTMSP.m
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% * Computes pitch subband decomposition of WAV file
+% (default: MIDI pitches 21 to 108)
+% * each pitch subband contains short time mean-square power (STMSP)
+% * Features are computed in a batch modus
+% * Features are stored in folder 'data_feature/'
+%
+% Reference:
+% Details on the feature computation can be found in the following book:
+%
+% Meinard Mueller: Information Retrieval for Music and Motion,
+% Springer 2007
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+clear;
+close all hidden;
+
+dirFileNames = {
+ 'data_WAV/','Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav';
+ 'data_WAV/','Burgmueller_Op100-02-FirstPart_Meinard_SE.wav';
+ 'data_WAV/','Systematic_Cadence-C-Major_Meinard_portato.wav';
+ 'data_WAV/','Systematic_Cadence-C-Major_Meinard_staccato.wav';
+ 'data_WAV/','Systematic_Scale-C-Major_Meinard_fast.wav';
+ 'data_WAV/','Systematic_Scale-C-Major_Meinard_middle.wav';
+ 'data_WAV/','Systematic_Chord-C-Major_Eight-Instruments.wav';
+ };
+
+for n=1:size(dirFileNames,1)
+ clear parameter;
+ parameter.message = 1;
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % Convert WAV to expected audio format (mono, 22050 Hz)
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ [f_audio,sideinfo] = wav_to_audio('', dirFileNames{n,1}, dirFileNames{n,2},parameter);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % Estimation of the global tuning of the recording and selection of
+ % an appropriate filterbank for use in the next step
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ clear parameter
+ shiftFB = estimateTuning(f_audio);
+ fprintf('Using filterbank number: %d\n',shiftFB);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % Compute pitch features
+ %
+ % Input: audio file of format: mono, 22050 Hz
+ %
+ % Output: sequence of pitch vectors
+ % (specified by N x 120 matrix f_pitch)
+ % Only subband for MIDI pitches 21 to 108 are computed, the
+ % other subbands are set to zero.
+ %
+ % Parameter: parameter.win_len specifies window length (in samples)
+ % with window overlap of half size
+ % Example: audio sampling rate: 22050 Hz
+ % parameter.win_len = 4410
+ % Resulting feature rate: 10 Hz
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ clear parameter
+ parameter.winLenSTMSP = 4410;
+ parameter.fs = sideinfo.wav.fs;
+ parameter.save = 1;
+ parameter.saveDir = 'data_feature/';
+ parameter.saveFilename = dirFileNames{n,2}(1:end-4);
+ parameter.shiftFB = shiftFB;
+ parameter.saveAsTuned = 1;
+ [f_pitch,sideinfo] = audio_to_pitch_via_FB(f_audio,parameter,sideinfo);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % Visualization of pitch decomposition (f_pitch)
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ parameter.usePitchNameLabels = 1;
+ parameter.title = 'Logarithmic compression of amplitude';
+ parameter.featureRate = sideinfo.pitch.featureRate;
+ parameter.xlabel = 'Time [Seconds]';
+ parameter.ylabel = 'Pitch';
+ visualizePitch(log(5*f_pitch+1),parameter);
+end
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_pitch_to_CENS.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_pitch_to_CENS.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,75 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: test_convert_pitch_to_CENS.m
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% * Computes CENS features (f_CENS) from pitch features (f_pitch)
+% * CENS is a chroma-like feature
+% (Chroma Energy Normalized Statistics)
+%
+% Reference:
+% Details on the feature computation can be found in the following book:
+%
+% Meinard Mueller: Information Retrieval for Music and Motion,
+% Springer 2007
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+clear;
+%close all hidden;
+
+directory = 'data_feature/';
+
+
+%filename = 'Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav';
+%filename = 'Burgmueller_Op100-02-FirstPart_Meinard_SE.wav';
+%filename = 'Systematic_Cadence-C-Major_Meinard_portato.wav';
+%filename = 'Systematic_Cadence-C-Major_Meinard_staccato.wav';
+%filename = 'Systematic_Scale-C-Major_Meinard_fast.wav';
+%filename = 'Systematic_Scale-C-Major_Meinard_middle.wav';
+filename = 'Systematic_Chord-C-Major_Eight-Instruments.wav';
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Loads pitch features (f_pitch) and computes CENS features (f_CENS)
+%
+% Note: feature filename is specified by WAV filename
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+win_len = 4410;
+filename_pitch = strcat(filename(1:end-4),'_pitch_',num2str(win_len));
+load(strcat(directory,filename_pitch)); % load f_pitch and sideinfo;
+
+parameter.winLenSmooth = 21;
+parameter.downsampSmooth = 5;
+parameter.featureRate = sideinfo.pitch.featureRate;
+[f_CENS,sideinfo] = pitch_to_CENS(f_pitch,parameter,sideinfo);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization of chromagrams (f_CENS,f_chroma)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+parameter.featureRate = sideinfo.CENS.featureRate;
+parameter.xlabel = 'Time [Seconds]';
+parameter.title = sprintf('CENS %d %d chromagram',parameter.winLenSmooth,parameter.downsampSmooth);
+visualizeChroma(f_CENS,parameter);
+
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_pitch_to_CRP.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_pitch_to_CRP.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,79 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: test_convert_pitch_to_CRP.m
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% * Computes CRP features (f_crp) from pitch features (f_pitch)
+% * CRP is a chroma-like feature tuned for timbre-invariance
+%
+% Reference:
+% Details on the feature computation can be found in the following articles:
+%
+% Meinard Mueller, Sebastian Ewert, and Sebastian Kreuzer
+% Making chroma features more robust to timbre changes.
+% Proceedings of IEEE International Conference on Acoustics, Speech, and
+% Signal Processing (ICASSP), Taipei, Taiwan, pp. 1869-1872, 2009.
+%
+% Meinard Mueller, and Sebastian Ewert
+% Towards Timbre-Invariant Audio Features for Harmony-Based Music.
+% IEEE Transactions on Audio, Speach, and Language Processing.
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+clear;
+close all hidden;
+
+directory = 'data_feature/';
+
+
+%filename = 'Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav';
+%filename = 'Burgmueller_Op100-02-FirstPart_Meinard_SE.wav';
+%filename = 'Systematic_Cadence-C-Major_Meinard_portato.wav';
+%filename = 'Systematic_Cadence-C-Major_Meinard_staccato.wav';
+%filename = 'Systematic_Scale-C-Major_Meinard_fast.wav';
+%filename = 'Systematic_Scale-C-Major_Meinard_middle.wav';
+filename = 'Systematic_Chord-C-Major_Eight-Instruments.wav';
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Loads pitch features (f_pitch) and computes CRP features (f_crp)
+%
+% Note: feature filename is specified by WAV filename
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+win_len = 4410;
+filename_pitch = strcat(filename(1:end-4),'_pitch_',num2str(win_len));
+load(strcat(directory,filename_pitch)); % load f_pitch and sideinfo;
+
+parameter.coeffsToKeep = [55:120];
+parameter.applyLogCompr = 1;
+parameter.factorLogCompr = 1000;
+parameter.featureRate = sideinfo.pitch.featureRate;
+[f_crp,sideinfo] = pitch_to_CRP(f_pitch,parameter,sideinfo);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization of CRP chromagram
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+parameter.featureRate = sideinfo.CRP.featureRate;
+parameter.xlabel = 'Time [Seconds]';
+parameter.title = 'CRP chromagram';
+visualizeCRP(f_crp,parameter);
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_pitch_to_chroma.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/test_convert_pitch_to_chroma.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,85 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: test_convert_pitch_to_chroma.m
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% * Computes chroma features (f_chroma) from pitch features (f_pitch)
+%
+% Reference:
+% Details on the feature computation can be found in the following book:
+%
+% Meinard Mueller: Information Retrieval for Music and Motion,
+% Springer 2007
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+clear;
+close all hidden;
+
+directory = 'data_feature/';
+
+
+%filename = 'Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav';
+%filename = 'Burgmueller_Op100-02-FirstPart_Meinard_SE.wav';
+%filename = 'Systematic_Cadence-C-Major_Meinard_portato.wav';
+%filename = 'Systematic_Cadence-C-Major_Meinard_staccato.wav';
+%filename = 'Systematic_Scale-C-Major_Meinard_fast.wav';
+%filename = 'Systematic_Scale-C-Major_Meinard_middle.wav';
+filename = 'Systematic_Chord-C-Major_Eight-Instruments.wav';
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Loads pitch features (f_pitch) and computes chroma features (f_chroma)
+%
+% Note: feature filename is specified by WAV filename
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+win_len = 4410;
+filename_pitch = strcat(filename(1:end-4),'_pitch_',num2str(win_len));
+load(strcat(directory,filename_pitch)); % load f_pitch and sideinfo;
+
+parameter.vis = 0;
+%parameter.save = 1;
+%parameter.save_dir = 'data_feature/';
+%parameter.save_filename = strcat(sideinfo.wav.filename(1:length(sideinfo.wav.filename)-4));
+[f_chroma_norm,sideinfo] = pitch_to_chroma(f_pitch,parameter,sideinfo);
+
+parameter.applyLogCompr = 1;
+parameter.factorLogCompr = 100;
+f_logchroma_norm = pitch_to_chroma(f_pitch,parameter,sideinfo);
+
+parameter.winLenSmooth = 21;
+parameter.downsampSmooth = 5;
+f_logchroma_normSmoothed = pitch_to_chroma(f_pitch,parameter,sideinfo);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization of chromagrams (f_chroma_norm,f_chroma)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+parameter.featureRate = sideinfo.pitch.featureRate;
+parameter.xlabel = 'Time [Seconds]';
+parameter.title = 'Normalized chromagram';
+visualizeChroma(f_chroma_norm,parameter);
+
+parameter.title = 'Normalized log-compressed chromagram';
+visualizeChroma(f_logchroma_norm,parameter);
+
+parameter.title = 'Normalized log-compressed smoothed chromagram';
+visualizeChroma(f_logchroma_normSmoothed,parameter);
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/visualizeCRP.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/visualizeCRP.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,42 @@
+function visualizeCRP(f_crp,parameter)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: visualizeCRP
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% Visualization of CRP features (wrapper around visualize_chroma)
+%
+% Input:
+% f_CRP
+% parameter: is forwarded to visualizeChroma
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if isfield(parameter,'imagerange')==0
+ parameter.imagerange = [-1 1];
+end
+if isfield(parameter,'colormap')==0
+ blueSepia = gray(64).^0.8;
+ blueSepia(:,1:2) = blueSepia(:,1:2) * 0.5;
+ parameter.colormap = [flipud(blueSepia) ; hot(64)];
+end
+
+visualizeChroma(f_crp,parameter);
+
+end
\ No newline at end of file
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/visualizeChroma.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/visualizeChroma.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,141 @@
+function visualizeChroma(f_chroma,parameter)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: visualizeChroma
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% Visualization of f_chroma
+%
+% Input:
+% f_chroma
+% parameter.featureRate = 0; % 0 means unknown
+% parameter.colorbar = 1;
+% parameter.colormap = 'hot';
+% parameter.print = 0;
+% parameter.printFile = 'figure.eps';
+% parameter.printDir = '';
+% parameter.title = '';
+% parameter.xlabel = '';
+% parameter.imagerange = [0 1]; % 0 means automatic
+% parameter.fontSize = 0; % 0 means automatic
+% parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height]
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<2
+ parameter=[];
+end
+
+if isfield(parameter,'featureRate')==0
+ parameter.featureRate = 0;
+end
+if isfield(parameter,'colorbar')==0
+ parameter.colorbar = 1;
+end
+if isfield(parameter,'colormap')==0
+ parameter.colormap = 'hot';
+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,'imagerange')==0
+ parameter.imagerange = [0 1];
+end
+if isfield(parameter,'fontSize')==0
+ % 0 means automatic
+ parameter.fontSize = 0;
+end
+if isfield(parameter,'printPaperPosition')==0
+ parameter.printPaperPosition = [1 10 26 15]; %[left, bottom, width, height]
+end
+if isfield(parameter,'createAxisLabel')==0
+ parameter.createAxisLabel = 1;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+seg_num = size(f_chroma,2);
+
+chroma_names = ['C ';'C#';'D ';'D#';'E ';'F ';'F#';'G ';'G#';'A ';'A#';'B '];
+figure;
+set(gcf,'renderer','painters');
+
+if parameter.featureRate == 0
+ t = (1:seg_num);
+else
+ t = (0:seg_num-1)/parameter.featureRate;
+end
+
+if all(parameter.imagerange == 0)
+ imagesc(t,[1:12],f_chroma);
+else
+ imagesc(t,[1:12],f_chroma,parameter.imagerange);
+end
+set(gca,'YTick',[1:12]);
+set(gca,'YTickLabel',chroma_names);
+set(gca,'YDir','normal');
+if t(end)>t(1)
+ set(gca,'XLim',[t(1),t(end)]);
+end
+
+title(parameter.title);
+xlabel(parameter.xlabel);
+
+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
+
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/visualizePitch.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/visualizePitch.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+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
+
+
diff -r 000000000000 -r b54ee0a0be67 matlab/MATLAB-Chroma-Toolbox_2.0/wav_to_audio.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/MATLAB-Chroma-Toolbox_2.0/wav_to_audio.m Wed Aug 05 21:08:56 2015 +0100
@@ -0,0 +1,201 @@
+function [f_audio,sideinfo] = wav_to_audio(dirAbs,dirRel,wavfilename,parameter)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Name: wav_to_audio
+% Date of Revision: 2011-03
+% Programmer: Meinard Mueller, Sebastian Ewert
+%
+% Description:
+% Loads a Wav file and fills a sideinfo variable according to AGtoolbox
+% specifications. Resampling and single channel conversion is default, but
+% optional.
+%
+% Input:
+% dirAbs
+% dirRel
+% wavfilename
+% parameter.useResampling = 1;
+% parameter.destSamplerate = 22050;
+% parameter.convertToMono = 1;
+% parameter.monoConvertMode = 'downmix';
+% parameter.message = 0;
+% parameter.vis = 0;
+% parameter.save = 0;
+% parameter.saveDir = [dirAbs,dirRel];
+% parameter.saveFilename = wavfilename;
+%
+% Output:
+% f_audio
+% sideinfo.wav.version
+% sideinfo.wav.filename
+% sideinfo.wav.dirRel
+% sideinfo.wav.size
+% sideinfo.wav.duration
+% sideinfo.wav.energy
+% sideinfo.wav.fs
+% sideinfo.wav.nbits
+% sideinfo.wav.channels
+% sideinfo.wav.resampled
+% sideinfo.wav.monoConverted
+% sideinfo.wav.monoConvertMode
+%
+%
+% 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 .
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Check parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if nargin<4
+ parameter=[];
+end
+if nargin<3
+ error('Please specify at least the path and filename of the wav file')
+end
+
+if isfield(parameter,'useResampling')==0
+ parameter.useResampling = 1;
+end
+if isfield(parameter,'destSamplerate')==0
+ parameter.destSamplerate = 22050;
+end
+if isfield(parameter,'convertToMono')==0
+ parameter.convertToMono = 1;
+end
+if isfield(parameter,'monoConvertMode')==0
+ parameter.monoConvertMode = 'downmix';
+end
+if isfield(parameter,'message')==0
+ parameter.message = 0;
+end
+if isfield(parameter,'vis')==0
+ parameter.vis = 0;
+end
+if isfield(parameter,'save')==0
+ parameter.save = 0;
+end
+if isfield(parameter,'saveDir')==0
+ parameter.saveDir = [dirAbs,dirRel];
+end
+if isfield(parameter,'saveFilename')==0
+ parameter.saveFilename = wavfilename;
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Main program
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.message == 1
+ fprintf('wav_to_audio: processing %s, ',wavfilename);
+end
+
+[pathstr,name,ext] = fileparts(wavfilename);
+if strcmp(ext,'.wav')
+ [f_audio,fs,nbits] = wavread(strcat(dirAbs,dirRel,wavfilename));
+else
+ error(['Unknown file format ' ext]);
+end
+
+
+bConverted_to_mono = 0;
+if parameter.convertToMono
+ if size(f_audio,2)>1
+ bConverted_to_mono = 1;
+ if parameter.message == 1
+ fprintf('converting to mono, ');
+ end
+ switch parameter.monoConvertMode
+ case 'leftmost_channel'
+ f_audio= f_audio(:,1);
+ case 'rightmost_channel'
+ f_audio= f_audio(:,size(f_audio,2));
+ case 'downmix'
+ % pay attention to energy loss due to differences in phase
+ % when using this method. This is often the case for bad
+ % stereo mixes
+ nChannels = size(f_audio,2);
+
+ f_audio = sum(f_audio,2);
+ f_audio = f_audio / nChannels;
+ otherwise
+ disp('wav_to_audio: monoConvertMode : Unknown method')
+ end
+ end
+end
+
+bResampled = 0;
+if parameter.useResampling
+ if (fs ~= parameter.destSamplerate)
+ bResampled = 1;
+ if parameter.message == 1
+ fprintf('Resampling to %d, ', parameter.destSamplerate);
+ end
+ f_audio = resample (f_audio,parameter.destSamplerate,fs,100);
+ fs = parameter.destSamplerate;
+ end
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Update sideinfo
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+sideinfo.wav.version = 1;
+sideinfo.wav.filename = wavfilename;
+sideinfo.wav.dirRel = dirRel;
+sideinfo.wav.size = size(f_audio,1);
+sideinfo.wav.duration = (sideinfo.wav.size-1)/fs;
+sideinfo.wav.energy = sum(f_audio.^2);
+sideinfo.wav.fs = fs;
+sideinfo.wav.nbits = nbits;
+sideinfo.wav.channels = size(f_audio,2);
+sideinfo.wav.resampled = bResampled;
+sideinfo.wav.monoConverted = bConverted_to_mono;
+if bConverted_to_mono
+ sideinfo.wav.monoConvertMode = parameter.monoConvertMode;
+else
+ sideinfo.wav.monoConvertMode = 'none';
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Saving data
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.save == 1
+ if parameter.message == 1
+ fprintf('Saving to file, ');
+ end
+ filename = strcat(parameter.saveFilename,'_audio');
+ save(strcat(parameter.saveDir,filename),'f_audio','sideinfo');
+end
+
+if parameter.message == 1
+ fprintf('Done\n');
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Visualization
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if parameter.vis
+ figure;
+ for k=1:sideinfo.wav.channels
+ if sideinfo.wav.channels > 1
+ subplot(sideinfo.wav.channels,1,k);
+ end
+ plot( [0:sideinfo.wav.size-1] / sideinfo.wav.fs , f_audio(:,k));
+ axis tight;
+ end
+end
+
+end
\ No newline at end of file