Daniel@0: function demo3tempo Daniel@0: % To get familiar with tempo estimation from audio using the MIR Toolbox. Daniel@0: % To assess the performance of the tempo estimation method. Daniel@0: Daniel@0: % 1. Let's investigate the different stages needed for tempo estimation. Daniel@0: Daniel@0: d = miraudio('ragtime') Daniel@0: mirenvelope(d) Daniel@0: e = mirenvelope(d,'Halfwavediff') Daniel@0: Daniel@0: % Decompose the audio file with a filter bank. Daniel@0: f = mirfilterbank(d) Daniel@0: Daniel@0: % Calculate also a half-wave rectified differentiated envelope. Daniel@0: ee = mirenvelope(f,'HalfwaveDiff') Daniel@0: Daniel@0: % Sum the frequency channels.ok Daniel@0: s = mirsum(ee,'Centered') Daniel@0: Daniel@0: d2 = miraudio('vivaldi') Daniel@0: f2 = mirfilterbank(d2) Daniel@0: ee2 = mirenvelope(f2,'HalfwaveDiff') Daniel@0: s2 = mirsum(ee2,'Centered') Daniel@0: Daniel@0: % Calculate the autocorrelation function. Daniel@0: ac = mirautocor(s) Daniel@0: Daniel@0: % Apply the resonance model to the autocorrelation function. Daniel@0: ac = mirautocor(s,'Resonance') Daniel@0: Daniel@0: % Find peaks in the autocorrelation function. Daniel@0: p = mirpeaks(ac) Daniel@0: mirgetdata(p) Daniel@0: Daniel@0: % Get the period of the peaks. Daniel@0: t = mirtempo(p,'Total',1) Daniel@0: Daniel@0: display('Strike any key to continue...'); Daniel@0: pause Daniel@0: close all Daniel@0: Daniel@0: % 2. All the functions we used are integrated into the function tempo. Daniel@0: help mirtempo Daniel@0: Daniel@0: % For instance, we can simply write: Daniel@0: [t,ac] = mirtempo('ragtime') Daniel@0: Daniel@0: % As you can see in the help, the resonance is integrated by default in the Daniel@0: % tempo function. To toggle off the use of the resonance function, type: Daniel@0: [t,ac] = mirtempo('ragtime','Resonance',0) Daniel@0: Daniel@0: [t,ac] = mirtempo('ragtime','total',5) Daniel@0: Daniel@0: display('Strike any key to continue...'); Daniel@0: pause Daniel@0: close all Daniel@0: Daniel@0: % 3. The excerpt 'laksin' and 'czardas' have variable tempi. Use frame- Daniel@0: % based tempo analysis to estimate the variation of the tempi. Daniel@0: % Apply to this end the tempo command with the 'frame' option. Daniel@0: [t1,p1] = mirtempo('laksin','Frame') Daniel@0: [t2,p2] = mirtempo('czardas','Frame') Daniel@0: Daniel@0: % What is the range of variation of tempi? Daniel@0: help mirhisto Daniel@0: h1 = mirhisto(t1) Daniel@0: h2 = mirhisto(t2)