view foote.py @ 19:890cfe424f4a tip

added annotations
author mitian
date Fri, 11 Dec 2015 09:47:40 +0000
parents 294f66d285af
children
line wrap: on
line source
"""
Foote method for segmentation, published here:

Foote, J. (2000). Automatic Audio Segmentation Using a Measure Of Audio
Novelty. In Proc. of the IEEE International Conference of Multimedia and Expo
(pp. 452-455). New York City, NY, USA.
"""

__author__ = "Oriol Nieto"
__copyright__ = "Copyright 2014, Music and Audio Research Lab (MARL)"
__license__ = "GPL"
__version__ = "1.0"
__email__ = "oriol@nyu.edu"

# Local stuff
from utils import SegUtil

M = 2           # Median filter for the audio features (in beats)
Mg = 32         # Gaussian kernel size
L = 16          # Size of the median filter for the adaptive threshold

def segmentation(F, M, Mg, L, plot=False):
    """Computes the Foote segmentator.

    Parameters
    ----------
    F : np.array((N,M))
        Features matrix of N beats x M features.
    M : int
        Median filter size for the audio features (in beats).
    Mg : int
        Gaussian kernel size (in beats).
    L : int
        Median filter size for the adaptive threshold

    Return
    ------
    bound_idx : np.array
        Array containing the indices of the boundaries.
    """
    # Filter
    F = SegUtil.median_filter(F, M=M)

    # Self Similarity Matrix
    S = SegUtil.compute_ssm(F)

    # Compute gaussian kernel
    G = SegUtil.compute_gaussian_krnl(Mg)

    # Compute the novelty curve
    nc = SegUtil.compute_nc(S, G)

    # Find peaks in the novelty curve
    return SegUtil.pick_peaks(nc, L=L, plot=plot)