# HG changeset patch # User Chris Cannam # Date 1436358734 -3600 # Node ID ee085cf5832d64f6546481450449553c5eb105ac # Parent 72d6b86f8ce0f36804169816e2cd575c85bf9897 Tests for process with step & block size params diff -r 72d6b86f8ce0 -r ee085cf5832d test/test_process.py --- a/test/test_process.py Wed Jul 08 12:47:07 2015 +0100 +++ b/test/test_process.py Wed Jul 08 13:32:14 2015 +0100 @@ -224,6 +224,19 @@ print("This test fails because of a bug in the Vamp plugin SDK. Please update to SDK version 2.6.") assert actual == expected +def test_process_freq_shift_timestamps(): + buf = input_data(blocksize * 10) + results = list(vamp.process_audio(buf, rate, plugin_key_freq, "input-timestamp", process_timestamp_method = vamp.vampyhost.SHIFT_DATA)) + assert len(results) == 20 + for i in range(len(results)): + # The timestamp should be the frame number of the frame at the start of + # the input buffer + expected = i * (blocksize/2) + actual = results[i]["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 + 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" ], {})) @@ -237,6 +250,39 @@ print("This test fails because of a bug in the Vamp plugin SDK. Please update to SDK version 2.6.") assert actual == expected +def test_process_blocksize_timestamps(): + buf = input_data(blocksize * 10) + results = list(vamp.process_audio(buf, rate, plugin_key, "input-timestamp", {}, block_size = blocksize * 2)) # step size defaults to block size + assert len(results) == 5 + for i in range(len(results)): + # The timestamp should be the frame number of the first frame in the + # input buffer + expected = i * blocksize * 2 + actual = results[i]["values"][0] + assert actual == expected + +def test_process_stepsize_timestamps(): + buf = input_data(blocksize * 10) + results = list(vamp.process_audio(buf, rate, plugin_key, "input-timestamp", {}, step_size = blocksize / 2)) + assert len(results) == 20 + for i in range(len(results)): + # The timestamp should be the frame number of the first frame in the + # input buffer + expected = (i * blocksize) / 2 + actual = results[i]["values"][0] + assert actual == expected + +def test_process_stepsize_blocksize_timestamps(): + buf = input_data(blocksize * 10) + results = list(vamp.process_audio(buf, rate, plugin_key, "input-timestamp", {}, block_size = blocksize * 2, step_size = blocksize / 2)) + assert len(results) == 20 + for i in range(len(results)): + # The timestamp should be the frame number of the first frame in the + # input buffer + expected = (i * blocksize) / 2 + actual = results[i]["values"][0] + assert actual == expected + 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" ], {}))