コード例 #1
0
def test_equalizer(mix_and_sources, check_against_regression_data):
    bands = [{
        "chn": [0, 1],
        "f": i,
        "w": (5 * np.log2(i)),
        "g": 5,
        "t": 0
    } for i in [110, 440, 10000]]

    signal, _ = mix_and_sources
    filters = [effects.equalizer(bands)]
    augmented_signal = effects.apply_effects_ffmpeg(signal, filters)

    reg_path = path.join(REGRESSION_PATH, "equalizer.json")
    fx_regression(augmented_signal.audio_data, reg_path,
                  check_against_regression_data)
コード例 #2
0
def test_misc_param_check():
    with pytest.raises(ValueError):
        effects.vibrato(-1, 1)
    with pytest.raises(ValueError):
        effects.vibrato(1, -1)

    with pytest.raises(ValueError):
        effects.tremolo(-1, 1)
    with pytest.raises(ValueError):
        effects.tremolo(1, -1)

    with pytest.raises(ValueError):
        effects.chorus([1], [2, 3], [45, 6], [4])
    with pytest.warns(UserWarning):
        effects.chorus([2000], [.5], [.7], [.4])
    with pytest.raises(ValueError):
        effects.chorus([1], [30], [.7], [.4], in_gain=-1)

    with pytest.raises(ValueError):
        effects.phaser(in_gain=-1)
    with pytest.raises(ValueError):
        effects.phaser(out_gain=-1)
    with pytest.raises(ValueError):
        effects.phaser(decay=-1)
    with pytest.raises(ValueError):
        effects.phaser(type_="fail")

    with pytest.raises(ValueError):
        effects.flanger(delay=-1)
    with pytest.raises(ValueError):
        effects.flanger(depth=-1)
    with pytest.raises(ValueError):
        effects.flanger(regen=-100)
    with pytest.raises(ValueError):
        effects.flanger(width=-1)
    with pytest.raises(ValueError):
        effects.flanger(speed=-1)
    with pytest.raises(ValueError):
        effects.flanger(shape="fail")
    with pytest.raises(ValueError):
        effects.flanger(interp="fail")
    with pytest.raises(ValueError):
        effects.flanger(phase=-1)

    with pytest.raises(ValueError):
        effects.emphasis(1, 1, type_="fail")
    with pytest.raises(ValueError):
        effects.emphasis(1, 1, mode="fail")
    with pytest.raises(ValueError):
        effects.emphasis(1, -1)

    band = {'chn': [0], 'f': 300, 'w': 10, 'g': 10, 't': 5}
    with pytest.raises(ValueError):
        effects.equalizer([band])
    band["g"] = -1
    with pytest.raises(ValueError):
        effects.equalizer([band])
    band["w"] = -1
    with pytest.raises(ValueError):
        effects.equalizer([band])
    band["f"] = -1
    with pytest.raises(ValueError):
        effects.equalizer([band])
    band["chn"].append(-1)
    with pytest.raises(ValueError):
        effects.equalizer([band])

    with pytest.raises(ValueError):
        effects.SoXFilter('fail')