mi@0
|
1 """
|
mi@0
|
2 Foote method for segmentation, published here:
|
mi@0
|
3
|
mi@0
|
4 Foote, J. (2000). Automatic Audio Segmentation Using a Measure Of Audio
|
mi@0
|
5 Novelty. In Proc. of the IEEE International Conference of Multimedia and Expo
|
mi@0
|
6 (pp. 452-455). New York City, NY, USA.
|
mi@0
|
7 """
|
mi@0
|
8
|
mi@0
|
9 __author__ = "Oriol Nieto"
|
mi@0
|
10 __copyright__ = "Copyright 2014, Music and Audio Research Lab (MARL)"
|
mi@0
|
11 __license__ = "GPL"
|
mi@0
|
12 __version__ = "1.0"
|
mi@0
|
13 __email__ = "oriol@nyu.edu"
|
mi@0
|
14
|
mi@0
|
15 # Local stuff
|
mi@0
|
16 from utils import SegUtil
|
mi@0
|
17
|
mitian@7
|
18 M = 2 # Median filter for the audio features (in beats)
|
mitian@7
|
19 Mg = 32 # Gaussian kernel size
|
mitian@7
|
20 L = 16 # Size of the median filter for the adaptive threshold
|
mi@0
|
21
|
mi@0
|
22 def segmentation(F, M, Mg, L, plot=False):
|
mi@0
|
23 """Computes the Foote segmentator.
|
mi@0
|
24
|
mi@0
|
25 Parameters
|
mi@0
|
26 ----------
|
mi@0
|
27 F : np.array((N,M))
|
mi@0
|
28 Features matrix of N beats x M features.
|
mi@0
|
29 M : int
|
mi@0
|
30 Median filter size for the audio features (in beats).
|
mi@0
|
31 Mg : int
|
mi@0
|
32 Gaussian kernel size (in beats).
|
mi@0
|
33 L : int
|
mi@0
|
34 Median filter size for the adaptive threshold
|
mi@0
|
35
|
mi@0
|
36 Return
|
mi@0
|
37 ------
|
mi@0
|
38 bound_idx : np.array
|
mi@0
|
39 Array containing the indices of the boundaries.
|
mi@0
|
40 """
|
mi@0
|
41 # Filter
|
mitian@1
|
42 F = SegUtil.median_filter(F, M=M)
|
mi@0
|
43
|
mi@0
|
44 # Self Similarity Matrix
|
mitian@1
|
45 S = SegUtil.compute_ssm(F)
|
mi@0
|
46
|
mi@0
|
47 # Compute gaussian kernel
|
mitian@1
|
48 G = SegUtil.compute_gaussian_krnl(Mg)
|
mi@0
|
49
|
mi@0
|
50 # Compute the novelty curve
|
mitian@1
|
51 nc = SegUtil.compute_nc(S, G)
|
mi@0
|
52
|
mi@0
|
53 # Find peaks in the novelty curve
|
mitian@1
|
54 return SegUtil.pick_peaks(nc, L=L, plot=plot)
|