-
Notifications
You must be signed in to change notification settings - Fork 2
/
getVals.m
51 lines (45 loc) · 1.61 KB
/
getVals.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [res, yinres, spec]=getVals(filename, midifile, audiofile, sr, hop)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [res, yinres]=getVals(filename, midifile, audiofile, sr, hop)
%
% Description:
% Gets values for DTW alignment and YIN analysis of specified audio
% signal and MIDI file
%
% Inputs:
% filename
% midifile, audiofile, sr, hop
%
% Outputs:
% res
% res.on list of DTW predicted onset times in seconds
% res.off list of DTW predicted offset times in seconds
% yinres (below are the two elements that are used)
% yinres.ap aperiodicty estimates for each frame
% yinres.pwr power estimates for each frame
%
% Dependencies:
% de Cheveigné, A. 2002. YIN MATLAB implementation Available from:
% http://audition.ens.fr/adc/sw/yin.zip
% Toiviainen, P. and T. Eerola. 2006. MIDI Toolbox. Available from:
% https://www.jyu.fi/hum/laitokset/musiikki/en/research/coe/materials...
% /miditoolbox/
%
% Automatic Music Performance Analysis and Analysis Toolkit (AMPACT)
% http://www.ampact.org
% (c) copyright 2011 Johanna Devaney (j@devaney.ca), all rights reserved.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% run the dyanamic time warping alignment
[res,spec] = runDTWAlignment(filename, midifile, 0.025);
% noramlize audio file
audiofile=audiofile/sqrt(mean(audiofile.^2));
% read MIDI file
nmat=readmidi(midifile);
% define parameters for YIN analysis
P.thresh = 0.01;
P.sr = sr;
P.hop = hop;
P.maxf0 = max(midi2hz(nmat(:,4)+2));
P.minf0 = min(midi2hz(nmat(:,4)-1));
% run YIN on audiofile
yinres=yin(audiofile,P);