Commit b16bb79d authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'ci/renderer-tests-with-sampling-rates' into 'main'

[CI] add renderer tests with sampling rates other than 48

See merge request !2166
parents fa0c0a5f 8a6d52a0
Loading
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
from pathlib import Path
from scipy.io.wavfile import read, write
import numpy as np

MAX_NUM_CH = 20  # number of channel indices in file
MIN_DURATION_MS = 1200  # minimum duration needed for all indices at 16kHz
TESTV_DIR = Path(__file__).parent.joinpath("testv")


def create_vector(fs: int, num_ch: int):
    in_file = TESTV_DIR / f"spectral_{fs}.wav"

    # requires spectral_{16,32,48}.wav
    if not in_file.exists():
        raise FileNotFoundError(f"Source file {in_file} not found!")
    # validate num_ch
    if num_ch > MAX_NUM_CH or num_ch < 1:
        raise ValueError(
            f"Requested channel count of {num_ch} channels is invalid. Must be between 1 and {MAX_NUM_CH}!"
        )

    _, data = read(in_file)

    # split source file into parts
    part_len = data.shape[0] // MAX_NUM_CH
    parts = data.reshape(MAX_NUM_CH, part_len).T

    duration = fs * MIN_DURATION_MS
    out = np.zeros([duration, num_ch], dtype=np.int16)

    # populate output vector, loop over the channel indices
    # until the duration is reached
    for i in range(duration // part_len):
        for ch in range(num_ch):
            if i % num_ch == ch:
                out[i * part_len : (i + 1) * part_len, ch] = parts[:, ch]

    write(TESTV_DIR / f"spectral_test_{num_ch}ch_{fs}kHz.wav", fs * 1000, out)


def main():
    for fs in [16, 32, 48]:
        for ch in range(1, 21):
            create_vector(fs, ch)


if __name__ == "__main__":
    main()
+24 −0
Original line number Diff line number Diff line
mixed_mc714_foa_masa2_ism4_16.wav
7
MC
1
7_1_4
SBA
13
1
MASA
17
2
stv2MASA2TC16c.met
ISM
19
stvISM1.csv
ISM
20
stvISM2.csv
ISM
21
stvISM3.csv
ISM
22
stvISM4.csv
+132 B

File added.

No diff preview for this file type.

+24 −0
Original line number Diff line number Diff line
mixed_mc714_foa_masa2_ism4_32.wav
7
MC
1
7_1_4
SBA
13
1
MASA
17
2
stv2MASA2TC32c.met
ISM
19
stvISM1.csv
ISM
20
stvISM2.csv
ISM
21
stvISM3.csv
ISM
22
stvISM4.csv
+132 B

File added.

No diff preview for this file type.

Loading