03.05.2014 Views

Computational Models of Music Similarity and their ... - OFAI

Computational Models of Music Similarity and their ... - OFAI

Computational Models of Music Similarity and their ... - OFAI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

20 2 Audio-based <strong>Similarity</strong> Measures<br />

The power spectrum is transformed to the Mel-scale using a filter bank<br />

consisting <strong>of</strong> triangular filters. Each triangular filter defines the response <strong>of</strong><br />

one frequency b<strong>and</strong> <strong>and</strong> is normalized such that the sum <strong>of</strong> weights for each<br />

triangle is the same. In particular, the height <strong>of</strong> each triangle is 2/d where<br />

d is the width <strong>of</strong> the frequency b<strong>and</strong>. The triangles overlap each other such<br />

that the center frequency <strong>of</strong> one triangle is the starting point for the next<br />

triangle, <strong>and</strong> the end point <strong>of</strong> the previous triangle (see Figure 2.5).<br />

The triangular filters can be computed in Matlab as follows. 10 First, the<br />

variables are initialized <strong>and</strong> memory allocated.<br />

01 num_filt = 36; %% number <strong>of</strong> Mel frequency b<strong>and</strong>s (2.4)<br />

02<br />

03 f = linspace(0,fs/2,seg_size/2+1); %% frequency bins <strong>of</strong> P<br />

04 mel = log(1+f/700)*1127.01048;<br />

05 mel_idx = linspace(0,mel(end),num_filt+2);<br />

06 mel_filter = zeros(num_filt,seg_size/2+1);<br />

07<br />

08 f_idx = zeros(num_filt+2,1);<br />

09 for i=1:num_filt+2,<br />

10 [tmp f_idx(i)] = min(abs(mel - mel_idx(i)));<br />

11 end<br />

12 freqs = f(f_idx);<br />

13<br />

14 %% height <strong>of</strong> triangles<br />

15 h = 2./(freqs(3:num_filt+2)-freqs(1:num_filt));<br />

Second, in the main loop for each triangular filter the weights are computed.<br />

16 for i=1:num_filt, (2.5)<br />

17 mel_filter(i,:) = ...<br />

18 (f > freqs(i) & f freqs(i+1) & f < freqs(i+2)).* ...<br />

21 h(i).*(freqs(i+2)-f)/(freqs(i+2)-freqs(i+1));<br />

22 end<br />

10 This code is based on Malcolm Slaney’s Auditory Toolbox.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!