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