Example #1
0
 def test_againstLIBROSA_beethoven(self):
     my_val = extractor.rms(beet, win_length=n_fft / sr, decomposition=True)
     lib_val = librosa.feature.rmse(y=beet,
                                    n_fft=n_fft,
                                    hop_length=n_fft / 2)
     corr = calculateZcorr(my_val, retrieveLibrosaValue(lib_val))
     assert corr >= 0.95  # assert 95% correlation b/w zscores
Example #2
0
 def test_againstMIR_testalt(self):
     val = extractor.rms(test_alt, decomposition=False)
     npt.assert_almost_equal(
         val,
         0.61381,
         decimal=4,
         err_msg='Returned value not within 4 decimal places of MIR output')
Example #3
0
 def test_againstMIR_beethoven(self):
     val = extractor.rms(beet, decomposition=False)
     npt.assert_almost_equal(
         val,
         0.073394,
         decimal=4,
         err_msg='Returned value not within 4 decimal places of MIR output')
Example #4
0
    def rms(self, use_librosa=False, decomposition=True, hop_length=None,
            n_fft=None):
        """
        Get the root mean square (RMS) energy feature.
            :parameters:
                - use_librosa : boolean. Whether to use librosa or extractor
                    feature extraction function. Default False.
                - 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.
                - n_fft : integer. The window length [samples].
                          Default 2048 [samples].
        """

        if n_fft is None:
            n_fft = self.n_fft
        if hop_length is None:
            hop_length = int(n_fft / 2)
        if use_librosa:
            tmp = librosa.feature.rmse(self.audio, n_fft=n_fft,
                                        hop_length=hop_length)
            self.insertFeature(tmp, 'RMS', hop_length, full=False)
            self.insertExtractionParameters('RMS',
                                            dict(n_fft=n_fft, librosa=use_librosa,
											hop_length=hop_length, decomposition=True))
        else:
            tmp = extractor.rms(self.audio, sr=self.sr, n_fft=n_fft, hop_length=hop_length,
                                        pad=self.pad, decomposition=decomposition)
            self.insertFeature(tmp, 'RMS', hop_length, full=not decomposition)
            self.insertExtractionParameters('RMS',
                                            dict(n_fft=n_fft, hop_length=hop_length,
											pad=self.pad, decomposition=decomposition,
											librosa=use_librosa))
        return tmp
Example #5
0
 def test_simple_array(self):
     val = extractor.rms(np.array([1, 2, 3, 4, 5]), decomposition=False)
     npt.assert_equal(val, 3.3166247903554)
Example #6
0
 def test_ones(self):
     npt.assert_equal(extractor.rms(np.ones(100), decomposition=False), 1)