def test_beat():
    def __test(infile):
        DATA    = load(infile)
        
        (bpm, beats) = librosa.beat.beat_track(y=None, sr=8000, hop_length=32,
                                               onsets=DATA['onsetenv'][0], n_fft=None)

        print beats
        print DATA['beats']
        assert numpy.allclose(librosa.frames_to_time(beats, sr=8000, hop_length=32), DATA['beats'])
        pass
    for infile in files('data/beat-beat-*.mat'):
        yield (__test, infile)
    pass
Ejemplo n.º 2
0
def test_onset_strength():

    def __test(infile):
        DATA    = load(infile)

        # Compute onset envelope using the same spectrogram
        onsets  = librosa.onset.onset_strength(y=None, sr=8000, S=DATA['D'], detrend=True)

        assert numpy.allclose(onsets, DATA['onsetenv'][0])

        pass

    for infile in files('data/beat-onset-*.mat'):
        yield (__test, infile)
    pass
Ejemplo n.º 3
0
def test_tempo():
    def __test(infile):
        DATA = load(infile)

        # Estimate tempo from the given onset envelope
        tempo = librosa.beat.estimate_tempo(DATA['onsetenv'][0],
                                            sr=8000,
                                            hop_length=32,
                                            start_bpm=120.0)

        assert (np.allclose(tempo, DATA['t'][0, 0])
                or np.allclose(tempo, DATA['t'][0, 1]))

    for infile in files('data/beat-tempo-*.mat'):
        yield (__test, infile)
Ejemplo n.º 4
0
def test_tempo():
    def __test(infile):
        DATA = load(infile)

        # Estimate tempo from the given onset envelope
        tempo = librosa.beat.estimate_tempo(
            DATA['onsetenv'][0], sr=8000, hop_length=32, start_bpm=120.0)

        assert (numpy.allclose(tempo, DATA['t'][0, 0])
                or numpy.allclose(tempo, DATA['t'][0, 1]))
        pass

    for infile in files('data/beat-tempo-*.mat'):
        yield (__test, infile)
    pass
Ejemplo n.º 5
0
def test_beat():
    def __test(infile):

        DATA = load(infile)

        (bpm,
         beats) = librosa.beat.beat_track(y=None,
                                          sr=8000,
                                          hop_length=32,
                                          onset_envelope=DATA['onsetenv'][0])

        beat_times = librosa.frames_to_time(beats, sr=8000, hop_length=32)
        assert np.allclose(beat_times, DATA['beats'])

    for infile in files('data/beat-beat-*.mat'):
        yield (__test, infile)
def test_tempo():
    def __test(infile):
        DATA    = load(infile)

        # Estimate tempo from the given onset envelope
        tempo   = librosa.beat.onset_estimate_bpm(  DATA['onsetenv'][0], 
                                                    120.0,  # starting bpm
                                                    8000 / 32)

        assert  (numpy.allclose(tempo, DATA['t'][0,0]) or 
                 numpy.allclose(tempo, DATA['t'][0,1]))
        pass

    for infile in files('data/beat-tempo-*.mat'):
        yield (__test, infile)
    pass
Ejemplo n.º 7
0
def test_onset_strength():
    def __test(infile):
        DATA = load(infile)

        # Compute onset envelope using the same spectrogram
        onsets = librosa.onset.onset_strength(y=None,
                                              sr=8000,
                                              S=DATA['D'],
                                              centering=False,
                                              detrend=True)

        assert np.allclose(onsets[1:], DATA['onsetenv'][0])

        pass

    for infile in files('data/beat-onset-*.mat'):
        yield (__test, infile)