Пример #1
0
def test_process_multi_summary_param_bool():
    buf = input_data(blocksize * 10)
    results = list(
        vamp.process_audio_multiple_outputs(buf, rate, plugin_key,
                                            ["input-summary"],
                                            {"produce_output": False}))
    assert len(results) == 0
Пример #2
0
def test_process_multi_timestamps():
    buf = input_data(blocksize * 10)
    results = list(vamp.process_audio_multiple_outputs(buf, rate, plugin_key, [ "input-timestamp" ]))
    assert len(results) == 10
    for i in range(len(results)):
        # The timestamp should be the frame number of the first frame in the
        # input buffer
        expected = i * blocksize
        actual = results[i]["input-timestamp"]["values"][0]
        assert actual == expected
Пример #3
0
def test_process_multi_freq_timestamps():
    buf = input_data(blocksize * 10)
    results = list(vamp.process_audio_multiple_outputs(buf, rate, plugin_key_freq, [ "input-timestamp" ], {}))
    assert len(results) == 20
    for i in range(len(results)):
        # The timestamp should be the frame number of the frame just beyond
        # half-way through the input buffer
        expected = i * (blocksize/2) + blocksize/2
        actual = results[i]["input-timestamp"]["values"][0]
        if actual == 2047 and expected == 2048:
            print("This test fails because of a bug in the Vamp plugin SDK. Please update to SDK version 2.6.")
        assert actual == expected
Пример #4
0
def test_process_multi_freq_summary():
    buf = input_data(blocksize * 10)
    results = list(vamp.process_audio_multiple_outputs(buf, rate, plugin_key_freq, [ "input-summary" ], {}))
    assert len(results) == 20
    for i in range(len(results)):
        expected = i * (blocksize/2) + blocksize/2 + 1   # "first" elt
        if (i == len(results)-1):
            expected = 0
        expected = expected + blocksize - 1              # non-zero elts
        actual = results[i]["input-summary"]["values"][0]
        eps = 1e-6
        assert abs(actual - expected) < eps
Пример #5
0
def test_process_multi_timestamps():
    buf = input_data(blocksize * 10)
    results = list(
        vamp.process_audio_multiple_outputs(buf, rate, plugin_key,
                                            ["input-timestamp"]))
    assert len(results) == 10
    for i in range(len(results)):
        # The timestamp should be the frame number of the first frame in the
        # input buffer
        expected = i * blocksize
        actual = results[i]["input-timestamp"]["values"][0]
        assert actual == expected
Пример #6
0
def test_process_multi_summary():
    buf = input_data(blocksize * 10)
    results = list(vamp.process_audio_multiple_outputs(buf, rate, plugin_key, [ "input-summary" ], {}))
    assert len(results) == 10
    for i in range(len(results)):
        #
        # each feature has a single value, equal to the number of non-zero elts
        # in the input block (which is all of them, i.e. the blocksize) plus
        # the first elt (which is i * blockSize + 1)
        #
        expected = blocksize + i * blocksize + 1
        actual = results[i]["input-summary"]["values"][0]
        assert actual == expected
Пример #7
0
def test_process_multi_freq_summary():
    buf = input_data(blocksize * 10)
    results = list(
        vamp.process_audio_multiple_outputs(buf, rate, plugin_key_freq,
                                            ["input-summary"], {}))
    assert len(results) == 20
    for i in range(len(results)):
        expected = i * (blocksize / 2) + blocksize / 2 + 1  # "first" elt
        if (i == len(results) - 1):
            expected = 0
        expected = expected + blocksize - 1  # non-zero elts
        actual = results[i]["input-summary"]["values"][0]
        eps = 1e-6
        assert abs(actual - expected) < eps
Пример #8
0
def test_process_multi_summary():
    buf = input_data(blocksize * 10)
    results = list(
        vamp.process_audio_multiple_outputs(buf, rate, plugin_key,
                                            ["input-summary"], {}))
    assert len(results) == 10
    for i in range(len(results)):
        #
        # each feature has a single value, equal to the number of non-zero elts
        # in the input block (which is all of them, i.e. the blocksize) plus
        # the first elt (which is i * blockSize + 1)
        #
        expected = blocksize + i * blocksize + 1
        actual = results[i]["input-summary"]["values"][0]
        assert actual == expected
Пример #9
0
def test_process_multi_freq_timestamps():
    buf = input_data(blocksize * 10)
    results = list(
        vamp.process_audio_multiple_outputs(buf, rate, plugin_key_freq,
                                            ["input-timestamp"], {}))
    assert len(results) == 20
    for i in range(len(results)):
        # The timestamp should be the frame number of the frame just beyond
        # half-way through the input buffer
        expected = i * (blocksize / 2) + blocksize / 2
        actual = results[i]["input-timestamp"]["values"][0]
        if actual == 2047 and expected == 2048:
            print(
                "This test fails because of a bug in the Vamp plugin SDK. Please update to SDK version 2.6."
            )
        assert actual == expected
Пример #10
0
def test_process_multiple_outputs():
    buf = input_data(blocksize * 10)
    results = list(vamp.process_audio_multiple_outputs(buf, rate, plugin_key, [ "input-summary", "input-timestamp" ], {}))
    assert len(results) == 20
    si = 0
    ti = 0
    for r in results:
        assert "input-summary" in r or "input-timestamp" in r
        if "input-summary" in r:
            expected = blocksize + si * blocksize + 1
            actual = r["input-summary"]["values"][0]
            assert actual == expected
            si = si + 1
        if "input-timestamp" in r:
            expected = ti * blocksize
            actual = r["input-timestamp"]["values"][0]
            assert actual == expected
            ti = ti + 1
Пример #11
0
def test_process_multiple_outputs():
    buf = input_data(blocksize * 10)
    results = list(
        vamp.process_audio_multiple_outputs(
            buf, rate, plugin_key, ["input-summary", "input-timestamp"], {}))
    assert len(results) == 20
    si = 0
    ti = 0
    for r in results:
        assert "input-summary" in r or "input-timestamp" in r
        if "input-summary" in r:
            expected = blocksize + si * blocksize + 1
            actual = r["input-summary"]["values"][0]
            assert actual == expected
            si = si + 1
        if "input-timestamp" in r:
            expected = ti * blocksize
            actual = r["input-timestamp"]["values"][0]
            assert actual == expected
            ti = ti + 1
Пример #12
0
def test_process_multi_summary_param_bool():
    buf = input_data(blocksize * 10)
    results = list(vamp.process_audio_multiple_outputs(buf, rate, plugin_key, [ "input-summary" ], { "produce_output": False }))
    assert len(results) == 0