Chris@0
|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
2 % Name: test_convert_audio_to_pitchSTMSP.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 pitch subband decomposition of WAV file
|
Chris@0
|
8 % (default: MIDI pitches 21 to 108)
|
Chris@0
|
9 % * each pitch subband contains short time mean-square power (STMSP)
|
Chris@0
|
10 % * Features are computed in a batch modus
|
Chris@0
|
11 % * Features are stored in folder 'data_feature/'
|
Chris@0
|
12 %
|
Chris@0
|
13 % Reference:
|
Chris@0
|
14 % Details on the feature computation can be found in the following book:
|
Chris@0
|
15 %
|
Chris@0
|
16 % Meinard Mueller: Information Retrieval for Music and Motion,
|
Chris@0
|
17 % Springer 2007
|
Chris@0
|
18 %
|
Chris@0
|
19 % License:
|
Chris@0
|
20 % This file is part of 'Chroma Toolbox'.
|
Chris@0
|
21 %
|
Chris@0
|
22 % 'Chroma Toolbox' is free software: you can redistribute it and/or modify
|
Chris@0
|
23 % it under the terms of the GNU General Public License as published by
|
Chris@0
|
24 % the Free Software Foundation, either version 2 of the License, or
|
Chris@0
|
25 % (at your option) any later version.
|
Chris@0
|
26 %
|
Chris@0
|
27 % 'Chroma Toolbox' is distributed in the hope that it will be useful,
|
Chris@0
|
28 % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
30 % GNU General Public License for more details.
|
Chris@0
|
31 %
|
Chris@0
|
32 % You should have received a copy of the GNU General Public License
|
Chris@0
|
33 % along with 'Chroma Toolbox'. If not, see <http://www.gnu.org/licenses/>.
|
Chris@0
|
34 %
|
Chris@0
|
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
36 clear;
|
Chris@0
|
37 close all hidden;
|
Chris@0
|
38
|
Chris@0
|
39 dirFileNames = {
|
Chris@0
|
40 'data_WAV/','Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav';
|
Chris@0
|
41 'data_WAV/','Burgmueller_Op100-02-FirstPart_Meinard_SE.wav';
|
Chris@0
|
42 'data_WAV/','Systematic_Cadence-C-Major_Meinard_portato.wav';
|
Chris@0
|
43 'data_WAV/','Systematic_Cadence-C-Major_Meinard_staccato.wav';
|
Chris@0
|
44 'data_WAV/','Systematic_Scale-C-Major_Meinard_fast.wav';
|
Chris@0
|
45 'data_WAV/','Systematic_Scale-C-Major_Meinard_middle.wav';
|
Chris@0
|
46 'data_WAV/','Systematic_Chord-C-Major_Eight-Instruments.wav';
|
Chris@0
|
47 };
|
Chris@0
|
48
|
Chris@0
|
49 for n=1:size(dirFileNames,1)
|
Chris@0
|
50 clear parameter;
|
Chris@0
|
51 parameter.message = 1;
|
Chris@0
|
52
|
Chris@0
|
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
54 % Convert WAV to expected audio format (mono, 22050 Hz)
|
Chris@0
|
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
56
|
Chris@0
|
57 [f_audio,sideinfo] = wav_to_audio('', dirFileNames{n,1}, dirFileNames{n,2},parameter);
|
Chris@0
|
58
|
Chris@0
|
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
60 % Estimation of the global tuning of the recording and selection of
|
Chris@0
|
61 % an appropriate filterbank for use in the next step
|
Chris@0
|
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
63 clear parameter
|
Chris@0
|
64 shiftFB = estimateTuning(f_audio);
|
Chris@0
|
65 fprintf('Using filterbank number: %d\n',shiftFB);
|
Chris@0
|
66
|
Chris@0
|
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
68 % Compute pitch features
|
Chris@0
|
69 %
|
Chris@0
|
70 % Input: audio file of format: mono, 22050 Hz
|
Chris@0
|
71 %
|
Chris@0
|
72 % Output: sequence of pitch vectors
|
Chris@0
|
73 % (specified by N x 120 matrix f_pitch)
|
Chris@0
|
74 % Only subband for MIDI pitches 21 to 108 are computed, the
|
Chris@0
|
75 % other subbands are set to zero.
|
Chris@0
|
76 %
|
Chris@0
|
77 % Parameter: parameter.win_len specifies window length (in samples)
|
Chris@0
|
78 % with window overlap of half size
|
Chris@0
|
79 % Example: audio sampling rate: 22050 Hz
|
Chris@0
|
80 % parameter.win_len = 4410
|
Chris@0
|
81 % Resulting feature rate: 10 Hz
|
Chris@0
|
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
83
|
Chris@0
|
84 clear parameter
|
Chris@0
|
85 parameter.winLenSTMSP = 4410;
|
Chris@0
|
86 parameter.fs = sideinfo.wav.fs;
|
Chris@0
|
87 parameter.save = 1;
|
Chris@0
|
88 parameter.saveDir = 'data_feature/';
|
Chris@0
|
89 parameter.saveFilename = dirFileNames{n,2}(1:end-4);
|
Chris@0
|
90 parameter.shiftFB = shiftFB;
|
Chris@0
|
91 parameter.saveAsTuned = 1;
|
Chris@0
|
92 [f_pitch,sideinfo] = audio_to_pitch_via_FB(f_audio,parameter,sideinfo);
|
Chris@0
|
93
|
Chris@0
|
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
95 % Visualization of pitch decomposition (f_pitch)
|
Chris@0
|
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
97
|
Chris@0
|
98 parameter.usePitchNameLabels = 1;
|
Chris@0
|
99 parameter.title = 'Logarithmic compression of amplitude';
|
Chris@0
|
100 parameter.featureRate = sideinfo.pitch.featureRate;
|
Chris@0
|
101 parameter.xlabel = 'Time [Seconds]';
|
Chris@0
|
102 parameter.ylabel = 'Pitch';
|
Chris@0
|
103 visualizePitch(log(5*f_pitch+1),parameter);
|
Chris@0
|
104 end
|