Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Name: test_convert_audio_to_pitchSTMSP.m Chris@0: % Date of Revision: 2011-03 Chris@0: % Programmer: Meinard Mueller, Sebastian Ewert Chris@0: % Chris@0: % Description: Chris@0: % * Computes pitch subband decomposition of WAV file Chris@0: % (default: MIDI pitches 21 to 108) Chris@0: % * each pitch subband contains short time mean-square power (STMSP) Chris@0: % * Features are computed in a batch modus Chris@0: % * Features are stored in folder 'data_feature/' Chris@0: % Chris@0: % Reference: Chris@0: % Details on the feature computation can be found in the following book: Chris@0: % Chris@0: % Meinard Mueller: Information Retrieval for Music and Motion, Chris@0: % Springer 2007 Chris@0: % Chris@0: % License: Chris@0: % This file is part of 'Chroma Toolbox'. Chris@0: % Chris@0: % 'Chroma Toolbox' is free software: you can redistribute it and/or modify Chris@0: % it under the terms of the GNU General Public License as published by Chris@0: % the Free Software Foundation, either version 2 of the License, or Chris@0: % (at your option) any later version. Chris@0: % Chris@0: % 'Chroma Toolbox' is distributed in the hope that it will be useful, Chris@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: % GNU General Public License for more details. Chris@0: % Chris@0: % You should have received a copy of the GNU General Public License Chris@0: % along with 'Chroma Toolbox'. If not, see . Chris@0: % Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: clear; Chris@0: close all hidden; Chris@0: Chris@0: dirFileNames = { Chris@0: 'data_WAV/','Bach_BWV988-Aria-Measures1-4_Meinard_fast.wav'; Chris@0: 'data_WAV/','Burgmueller_Op100-02-FirstPart_Meinard_SE.wav'; Chris@0: 'data_WAV/','Systematic_Cadence-C-Major_Meinard_portato.wav'; Chris@0: 'data_WAV/','Systematic_Cadence-C-Major_Meinard_staccato.wav'; Chris@0: 'data_WAV/','Systematic_Scale-C-Major_Meinard_fast.wav'; Chris@0: 'data_WAV/','Systematic_Scale-C-Major_Meinard_middle.wav'; Chris@0: 'data_WAV/','Systematic_Chord-C-Major_Eight-Instruments.wav'; Chris@0: }; Chris@0: Chris@0: for n=1:size(dirFileNames,1) Chris@0: clear parameter; Chris@0: parameter.message = 1; Chris@0: Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Convert WAV to expected audio format (mono, 22050 Hz) Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: [f_audio,sideinfo] = wav_to_audio('', dirFileNames{n,1}, dirFileNames{n,2},parameter); Chris@0: Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Estimation of the global tuning of the recording and selection of Chris@0: % an appropriate filterbank for use in the next step Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: clear parameter Chris@0: shiftFB = estimateTuning(f_audio); Chris@0: fprintf('Using filterbank number: %d\n',shiftFB); Chris@0: Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Compute pitch features Chris@0: % Chris@0: % Input: audio file of format: mono, 22050 Hz Chris@0: % Chris@0: % Output: sequence of pitch vectors Chris@0: % (specified by N x 120 matrix f_pitch) Chris@0: % Only subband for MIDI pitches 21 to 108 are computed, the Chris@0: % other subbands are set to zero. Chris@0: % Chris@0: % Parameter: parameter.win_len specifies window length (in samples) Chris@0: % with window overlap of half size Chris@0: % Example: audio sampling rate: 22050 Hz Chris@0: % parameter.win_len = 4410 Chris@0: % Resulting feature rate: 10 Hz Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: clear parameter Chris@0: parameter.winLenSTMSP = 4410; Chris@0: parameter.fs = sideinfo.wav.fs; Chris@0: parameter.save = 1; Chris@0: parameter.saveDir = 'data_feature/'; Chris@0: parameter.saveFilename = dirFileNames{n,2}(1:end-4); Chris@0: parameter.shiftFB = shiftFB; Chris@0: parameter.saveAsTuned = 1; Chris@0: [f_pitch,sideinfo] = audio_to_pitch_via_FB(f_audio,parameter,sideinfo); Chris@0: Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Visualization of pitch decomposition (f_pitch) Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: parameter.usePitchNameLabels = 1; Chris@0: parameter.title = 'Logarithmic compression of amplitude'; Chris@0: parameter.featureRate = sideinfo.pitch.featureRate; Chris@0: parameter.xlabel = 'Time [Seconds]'; Chris@0: parameter.ylabel = 'Pitch'; Chris@0: visualizePitch(log(5*f_pitch+1),parameter); Chris@0: end