Commit 2e4e6822 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

add back the truncate_signal() function - it's needed for some CI tests

parent 2b9dd87c
Loading
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -147,6 +147,25 @@ def check_xfail(
            "unsupported framing: LCLD codec doesn't support aggregation. Pre-renderer (ISAR) frame size must match LCLD frame size."
        )

def truncate_signal(
    in_file: Path,
    out_file: Path,
) -> None:
    """
    Truncate the signal in in_file to maximum INPUT_DURATION_SEC seconds,
    and write the truncated signal to out_file
    """
    data, fs = readfile(in_file)

    if data.ndim == 1:
        data_out = data[: INPUT_DURATION_SEC * fs]
    elif data.ndim == 2:
        data_out = data[: INPUT_DURATION_SEC * fs, :]
    else:
        raise ValueError(f"Cannot truncate data with dimension of {data.ndim}")

    writefile(out_file, data_out, fs)

def run_full_chain_split_rendering(
    record_property,
    props_to_record,
@@ -225,6 +244,8 @@ def run_full_chain_split_rendering(
        if test_info.config.option.create_ref or test_info.config.option.create_cut:
            in_file = FORMAT_TO_FILE_COMPARETEST[in_fmt]
            cut_in_file = in_file.with_stem(in_file.stem + "_cut")
            if not os.path.exists(cut_in_file)
                truncate_signal(in_file, cut_in_file)
            enc_cmd[3] = str(cut_in_file)
        else:
            enc_cmd[3] = str(FORMAT_TO_FILE_SMOKETEST[in_fmt])
@@ -395,6 +416,8 @@ def run_external_split_rendering(
        if test_info.config.option.create_ref or test_info.config.option.create_cut:
            in_file = FORMAT_TO_FILE_COMPARETEST[in_fmt]
            cut_in_file = in_file.with_stem(in_file.stem + "_cut")
            if not os.path.exists(cut_in_file)
                truncate_signal(in_file, cut_in_file)           
            split_pre_cmd[6] = str(cut_in_file)
        else:
            split_pre_cmd[6] = str(FORMAT_TO_FILE_SMOKETEST[in_fmt])