Example #1
0
    def spectralFlatness(self, decomposition=True, n_fft=None,
                            hop_length=None): #win_length=None
        """
        Get spectral flatness feature.
        :parameters:
            - decomposition : boolean. Whether to look at a time-series or
                an overall root mean square analysis of the piece.
            - win_length : float. Window length for the frames in the
                time series analysis. [seconds]. Default is 0.05 s.
            - hop_length : float. Hop length (i.e. overlap) between the
                frames in the time series analysis [samples].
                Default is half-overlap.
        """
        if n_fft is None:
            n_fft = self.n_fft
        # if win_length is None:
        #     win_length = self.n_fft / self.sr
        if hop_length is None:
            hop_length = int(self.n_fft / 2)

        tmp = extractor.spectralFlatness(self.audio, sr=self.sr,
                            n_fft=n_fft, hop_length=hop_length,
                            pad=self.pad, decomposition=decomposition) # win_length=win_length,

        self.insertFeature(tmp, 'spectralFlatness', hop_length, full=not decomposition)
        self.insertExtractionParameters('spectralFlatness',
                                        dict(hop_length=hop_length,
										n_fft=n_fft, pad=self.pad,
										decomposition=decomposition, librosa=False)) # win_length=win_length
        return tmp
Example #2
0
 def test_againstMIR_test_alt(self):
     val = extractor.spectralFlatness(test_alt, sr, decomposition=False)
     MIRVAL = 4.0096e-05
     assert np.abs(val - MIRVAL) <= 0.15 * MIRVAL
Example #3
0
 def test_againstMIR_beethoven(self):
     val = extractor.spectralFlatness(beet, sr, decomposition=False)
     MIRVAL = 0.024353
     assert np.abs(val - MIRVAL) <= 0.15 * MIRVAL