# HG changeset patch # User mitian # Date 1430812449 -3600 # Node ID 294f66d285af581a4244b77119440b6d6b0c2e62 # Parent 719b4ff8e9c909658cef01718493fb4e683bf7ac some previous changes diff -r 719b4ff8e9c9 -r 294f66d285af SegEval.py --- a/SegEval.py Thu Apr 09 19:22:39 2015 +0100 +++ b/SegEval.py Tue May 05 08:54:09 2015 +0100 @@ -423,8 +423,8 @@ gammatone_novelty, smoothed_gammatone_novelty, gammatone_novelty_idxs = novelty_S.process(ao.gammatone_ssm, self.kernel_size, peak_picker) timbre_novelty, smoothed_timbre_novelty, timbre_novelty_idxs = novelty_S.process(ao.timbre_ssm, self.kernel_size, peak_picker) - tempo_novelty, smoothed_harmonic_novelty, tempo_novelty_idxs = novelty_S.process(ao.tempo_ssm, self.kernel_size, peak_picker) - harmonic_novelty, smoothed_tempo_novelty, harmonic_novelty_idxs = novelty_S.process(ao.harmonic_ssm, self.kernel_size, peak_picker) + tempo_novelty, smoothed_tempo_novelty, tempo_novelty_idxs = novelty_S.process(ao.tempo_ssm, self.kernel_size, peak_picker) + harmonic_novelty, smoothed_harmonic_novelty, harmonic_novelty_idxs = novelty_S.process(ao.harmonic_ssm, self.kernel_size, peak_picker) gammatone_cnmf_idxs = cnmf_S.segmentation(ao.gammatone_features, rank=rank, R=R, h=h, niter=300) timbre_cnmf_idxs = cnmf_S.segmentation(ao.timbre_features, rank=rank, R=R, h=h, niter=300) diff -r 719b4ff8e9c9 -r 294f66d285af cnmf.py --- a/cnmf.py Thu Apr 09 19:22:39 2015 +0100 +++ b/cnmf.py Tue May 05 08:54:09 2015 +0100 @@ -18,6 +18,12 @@ # Local stuff from utils import SegUtil +# Algorithm params +h = 8 # Size of median filter for features in C-NMF +R = 15 # Size of the median filter for the activation matrix C-NMF +rank = 4 # Rank of decomposition for the boundaries +rank_labels = 6 # Rank of decomposition for the labels +R_labels = 6 # Size of the median filter for the labels def cnmf(S, rank, niter=500): """(Convex) Non-Negative Matrix Factorization. @@ -88,7 +94,7 @@ return G.flatten() -def segmentation(X, rank, R, h, niter=300): +def segmentation(X, rank=4, R=15, h=8, niter=300): """ Gets the segmentation (boundaries and labels) from the factorization matrices. @@ -138,4 +144,4 @@ else: break - return bound_idxs + return G, bound_idxs diff -r 719b4ff8e9c9 -r 294f66d285af foote.py --- a/foote.py Thu Apr 09 19:22:39 2015 +0100 +++ b/foote.py Tue May 05 08:54:09 2015 +0100 @@ -15,6 +15,9 @@ # 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. diff -r 719b4ff8e9c9 -r 294f66d285af novelty.py --- a/novelty.py Thu Apr 09 19:22:39 2015 +0100 +++ b/novelty.py Tue May 05 08:54:09 2015 +0100 @@ -11,9 +11,25 @@ import numpy as np from scipy.signal import correlate2d, convolve2d import matplotlib.pyplot as plt +from utils.PeakPickerUtil import PeakPicker -# from utils.PeakPickerUtil import PeakPicker - + +peak_picker = PeakPicker() +peak_picker.params.alpha = 9.0 # Alpha norm +peak_picker.params.delta = 0.0 # Adaptive thresholding delta +peak_picker.params.QuadThresh_a = (100 - 20.0) / 1000.0 +peak_picker.params.QuadThresh_b = 0.0 +peak_picker.params.QuadThresh_c = (100 - 20.0) / 1500.0 +peak_picker.params.rawSensitivity = 20 +peak_picker.params.aCoeffs = [1.0000, -0.5949, 0.2348] +peak_picker.params.bCoeffs = [0.1600, 0.3200, 0.1600] +peak_picker.params.preWin = 5 +peak_picker.params.postWin = 5 + 1 +peak_picker.params.LP_on = True +peak_picker.params.Medfilt_on = True +peak_picker.params.Polyfit_on = True +peak_picker.params.isMedianPositive = False + def getNoveltyCurve(ssm, kernel_size, normalise=False): '''Return novelty score from ssm.''' @@ -61,8 +77,11 @@ return kernel -def process(ssm, kernel_size, peak_picker, normalise=False, plot=False): +def segmentation(ssm, peak_picker=peak_picker, kernel_size=48, normalise=False, plot=False): '''Detect segment boundaries in the ssm.''' + # peak_picker for the 1st round boudary detection + + novelty = getNoveltyCurve(ssm, kernel_size, normalise=False) smoothed_novelty, novelty_peaks = peak_picker.process(novelty) diff -r 719b4ff8e9c9 -r 294f66d285af sf.py --- a/sf.py Thu Apr 09 19:22:39 2015 +0100 +++ b/sf.py Tue May 05 08:54:09 2015 +0100 @@ -153,4 +153,4 @@ if len(est_bound_idxs) == 0: est_bound_idxs = np.asarray([0]) # Return first one - return est_bound_idxs + return nc, est_bound_idxs