changeset 7:294f66d285af

some previous changes
author mitian
date Tue, 05 May 2015 08:54:09 +0100
parents 719b4ff8e9c9
children a34f9c5d0cd9
files SegEval.py cnmf.py foote.py novelty.py sf.py
diffstat 5 files changed, 36 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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
--- 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.
--- 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)
 	
--- 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