def test_sawtooth_add(): st1 = noise.SawtoothWave(100, 1, 1) st2 = noise.SawtoothWave(90, 0.8, 2) w1 = st1 + st2 waves = w1.get_waves() assert isinstance(w1, noise.ComplexWave) for wave in st1.get_waves(): assert any(wave == w for w in waves) for wave in st2.get_waves(): assert any(wave == w for w in waves)
def test_baliset_play(): b1 = noise.Baliset() b1.next_notes([("1:1", 1, 0.2), ("2:1", 0.5, 0.8)]) bwave = b1.play() wave1 = noise.SawtoothWave(196, 0.2, 1).play() wave2 = noise.SawtoothWave(392, 0.8, 0.5).play() np.testing.assert_allclose(bwave[:len(wave1) - 10], wave1[:-10], atol=0.0001) np.testing.assert_allclose(bwave[-len(wave2) + 10:], wave2[10:], atol=0.0001)
def test_sawtooth_simplify(): st1 = noise.SawtoothWave(500, 100, 1) st1.simplify() assert st1.complexity() == 10
def test_sawtooth_get_duration(): st1 = noise.SawtoothWave(500, 100, 1) assert abs(st1.get_duration() - 100) < 0.0001
def test_sawtooth_play(): st1 = noise.SawtoothWave(100, 1, 3) assert st1.play().max() <= 1 assert st1.play().min() >= -1
def test_sawtooth_complexity(): st1 = noise.SawtoothWave(100, 1, 1) assert st1.complexity() == 10
def test_sawtooth_get_waves(): st1 = noise.SawtoothWave(500, 100, 1) assert st1.get_waves() == st1.waves