comparison toolboxes/MIRtoolbox1.3.2/MIRToolboxDemos/demo3tempo.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function demo3tempo
2 % To get familiar with tempo estimation from audio using the MIR Toolbox.
3 % To assess the performance of the tempo estimation method.
4
5 % 1. Let's investigate the different stages needed for tempo estimation.
6
7 d = miraudio('ragtime')
8 mirenvelope(d)
9 e = mirenvelope(d,'Halfwavediff')
10
11 % Decompose the audio file with a filter bank.
12 f = mirfilterbank(d)
13
14 % Calculate also a half-wave rectified differentiated envelope.
15 ee = mirenvelope(f,'HalfwaveDiff')
16
17 % Sum the frequency channels.ok
18 s = mirsum(ee,'Centered')
19
20 d2 = miraudio('vivaldi')
21 f2 = mirfilterbank(d2)
22 ee2 = mirenvelope(f2,'HalfwaveDiff')
23 s2 = mirsum(ee2,'Centered')
24
25 % Calculate the autocorrelation function.
26 ac = mirautocor(s)
27
28 % Apply the resonance model to the autocorrelation function.
29 ac = mirautocor(s,'Resonance')
30
31 % Find peaks in the autocorrelation function.
32 p = mirpeaks(ac)
33 mirgetdata(p)
34
35 % Get the period of the peaks.
36 t = mirtempo(p,'Total',1)
37
38 display('Strike any key to continue...');
39 pause
40 close all
41
42 % 2. All the functions we used are integrated into the function tempo.
43 help mirtempo
44
45 % For instance, we can simply write:
46 [t,ac] = mirtempo('ragtime')
47
48 % As you can see in the help, the resonance is integrated by default in the
49 % tempo function. To toggle off the use of the resonance function, type:
50 [t,ac] = mirtempo('ragtime','Resonance',0)
51
52 [t,ac] = mirtempo('ragtime','total',5)
53
54 display('Strike any key to continue...');
55 pause
56 close all
57
58 % 3. The excerpt 'laksin' and 'czardas' have variable tempi. Use frame-
59 % based tempo analysis to estimate the variation of the tempi.
60 % Apply to this end the tempo command with the 'frame' option.
61 [t1,p1] = mirtempo('laksin','Frame')
62 [t2,p2] = mirtempo('czardas','Frame')
63
64 % What is the range of variation of tempi?
65 help mirhisto
66 h1 = mirhisto(t1)
67 h2 = mirhisto(t2)