annotate toolboxes/MIRtoolbox1.3.2/MIRToolboxDemos/demo3tempo.m @ 0:cc4b1211e677 tip

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