def test_samples_per_beat(): click = Click(filename, 44100, 60, False) assert click.samples_per_beat() == 44100 click = Click(filename, 44100, 120, False) assert click.samples_per_beat() == 22050 click = Click(filename, 22050, 120, False) assert click.samples_per_beat() == 11025
def test_seconds_per_beat(): click = Click(filename, 44100, 60, False) assert click.seconds_per_beat() == 1 click = Click(filename, 44100, 120, False) assert click.seconds_per_beat() == 0.5 click = Click(filename, 22050, 120, False) assert click.seconds_per_beat() == 0.5
def test_from_click(): filename = os.path.join(os.path.dirname(__file__), 'fixtures/click.wav') click = Click(filename, 44100, 120, False) precount = Precount.from_click(click, 4, 2, 0) expected_shape = (click.audio.data.shape[0], click.audio.data.shape[1] * Precount.n_beats(4, 2, 0)) assert precount.audio.data.shape == expected_shape
def test_precountify_with_bpm(): bpm = 120 meter = 4 measure = 2 upbeat = 0 filename = librosa.util.example_audio_file() precountified = precountify(filename, bpm=bpm, meter=meter, measure=measure, upbeat=upbeat) music = Music.from_file(filename).trimmed() click = Click(Click.preset(), music.audio.sr, bpm) precount = Precount.from_click(click, meter, measure, upbeat) expected_shape = (2, precount.audio.data.shape[1] + music.audio.data.shape[1]) assert precountified.data.shape == expected_shape
def test_init_mono(): click = Click(filename, 44100, 120, True) assert isinstance(click.audio, Mono) assert click.sr == 44100 assert click.bpm == 120 assert click.audio.data.shape == (click.samples_per_beat(), )
def test_preset(): assert os.path.exists(Click.preset())
def test_init_stereo(): click = Click(filename, 44100, 120, False) assert isinstance(click.audio, Stereo) assert click.sr == 44100 assert click.bpm == 120 assert click.audio.data.shape == (2, click.samples_per_beat())