def extract_features(track, fctr=400, fsd=1.0, type=1): """Computes beat-synchronous chroma features. Uses Dan Ellis' chrombeatftrs Matlab function (via the mlabwrap module, which is included with this feature extractor). See http://labrosa.ee.columbia.edu/projects/coversongs for more details. Parameters ---------- track : gordon Track instance fctr : float Center frequency (in Hz) for chromagram weighting. fsd : float Standard deviation (in octaves) for chromagram weighting. type : int Selects chroma calculation type; 1 (default) uses IF; 2 uses all FFT bins, 3 uses only local peaks (a bit like Emilia). Returns ------- chroma : array, shape (n, 12) Feature vector of beat-level chroma features (n time step rows x 12 columns) beats : array, length n Beat times in seconds for each frame of chroma. """ x,fs,svals = track.audio() feats,beats = mlab.chrombeatftrs(x.mean(1)[:,np.newaxis], fs, fctr, fsd, type, nout=2) return feats.T, beats.flatten()
def extract_features(wavfilename, fctr=400, fsd=1.0, type=1): """Computes beat-synchronous chroma features from the given wave file Calls Dan Ellis' chrombeatftrs Matlab function. """ x, fs = mlab.wavread(wavfilename, nout=2) feats, beats = mlab.chrombeatftrs(x, fs, fctr, fsd, type, nout=2) return feats, beats.flatten()
def extract_features(wavfilename, fctr=400, fsd=1.0, type=1): """Computes beat-synchronous chroma features from the given wave file Calls Dan Ellis' chrombeatftrs Matlab function. """ logger.info('Extracting beat-synchronous chroma features from %s', wavfilename) x,fs = mlab.wavread(wavfilename, nout=2) feats,beats = mlab.chrombeatftrs(x.mean(1)[:,np.newaxis], fs, fctr, fsd, type, nout=2) songlen = x.shape[0] / fs return feats, beats.flatten(), songlen
def extract_features(wavfilename, fctr=400, fsd=1.0, type=1): """Computes beat-synchronous chroma features from the given wave file Calls Dan Ellis' chrombeatftrs Matlab function. """ logger.info('Extracting beat-synchronous chroma features from %s', wavfilename) x, fs = mlab.wavread(wavfilename, nout=2) feats, beats = mlab.chrombeatftrs(x.mean(1)[:, np.newaxis], fs, fctr, fsd, type, nout=2) songlen = x.shape[0] / fs return feats, beats.flatten(), songlen
def extract_features(wavfilename, fctr=400, fsd=1.0, type=1): """Computes beat-synchronous chroma features from the given wave file Calls Dan Ellis' chrombeatftrs Matlab function. """ if lower(wavfilename[-4:]) == '.csv': logger.info('CSV filename reading preprocessed features from %s', wavfilename) csvr = csv.reader(open(wavfilename, 'rb'), delimiter=',') feats = np.array([[float(x) for x in row] for row in csvr]) beats = np.arange(len(feats)) * 0.0058 # simple fake frame locations songlen = len(feats) * 0.0058 else: logger.info('Extracting beat-synchronous chroma features from %s', wavfilename) x,fs = mlab.wavread(wavfilename, nout=2) feats,beats = mlab.chrombeatftrs(x.mean(1)[:,np.newaxis], fs, fctr, fsd, type, nout=2) songlen = x.shape[0] / fs return feats, beats.flatten(), songlen