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