Commit 2eb1c75c authored by Jan Kiene's avatar Jan Kiene
Browse files

allow for length as cmdl param

parent 87883231
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ TEST_VECTOR_DIR = HERE.joinpath("../scripts/testv").resolve()

NUM_CHANNELS = "4"  # currently only FOA
CUT_FROM = "0.0"
CUT_LEN = "5.0"

FILE_IDS = ["stvFOA", "stv2OA", "stv3OA", "stv51MC", "stv71MC", "stv512MC", "stv514MC", "stv714MC", "ISM", "MASA"]
GAINS = ["1.0", "16.0", ".004"]
@@ -59,7 +58,7 @@ def collect_files(file_ids):
    return files


def create_short_testvectors(which="foa"):
def create_short_testvectors(which="foa", cut_len=5.0):
    file_ids = []
    if which == "all":
        file_ids = FILE_IDS
@@ -73,12 +72,22 @@ def create_short_testvectors(which="foa"):
                suffix += f"_{g}"

            out_file = f.parent.joinpath(f.stem + suffix + f.suffix)
            cut_samples(f, out_file, NUM_CHANNELS, CUT_FROM, CUT_LEN, g)
            cut_samples(f, out_file, NUM_CHANNELS, CUT_FROM, f"{cut_len}", g)


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("which", choices=["foa", "all"])

    def positive_float(x: str) -> float:
        x = float(x)
        if x < 0.0:
            raise ValueError("Value for cut_len needs to be positive!")
        return x

    parser.add_argument("--cut_len", type=positive_float, default=5.0)
    args = parser.parse_args()
    sys.exit(create_short_testvectors(args.which))
    which = args.which
    cut_len = args.cut_len
    sys.exit(create_short_testvectors(which=args.which, cut_len=cut_len))