Loading ci/generate_delay_measurement_signal.py 0 → 100644 +58 −0 Original line number Diff line number Diff line import argparse import numpy as np OC_TO_NCHANNELS = { "MONO": 1, "STEREO": 2, "BINAURAL": 2, "BINAURAL_ROOM": 2, "5_1": 6, "7_1": 8, "5_1_2": 8, "5_1_4": 10, "7_1_4": 12, "FOA": 4, "HOA2": 9, "HOA3": 16, "EXT": 1, "ISM1": 1, "ISM2": 2, "ISM3": 3, "ISM4": 4, "MASA1TC": 1, "MASA2TC": 2, } SIGNAL_SOURCE = "scripts/testv/stv48c.pcm" CUT_LEN_SECS = 1 FS = 48000 def main(args): channels = OC_TO_NCHANNELS[ args.outformat ] outfile = args.outfile signal = gen_signal(channels) # write out interleaved signal.reshape(-1, 1).tofile(outfile) def gen_signal(channels:int) -> np.ndarray: # get the measurement signal from the source file (mono file) signal = np.fromfile(SIGNAL_SOURCE, dtype=np.int16) # shorten to one second signal = signal[:FS * CUT_LEN_SECS] # create other channels with same signal signal = np.repeat(signal.reshape((-1, 1)), channels, axis=1) return signal if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("outformat", type=str, choices=list(OC_TO_NCHANNELS.keys()), help="output format to generate for") parser.add_argument("outfile", help="output .pcm file with measurement signal") args = parser.parse_args() main(args) No newline at end of file Loading
ci/generate_delay_measurement_signal.py 0 → 100644 +58 −0 Original line number Diff line number Diff line import argparse import numpy as np OC_TO_NCHANNELS = { "MONO": 1, "STEREO": 2, "BINAURAL": 2, "BINAURAL_ROOM": 2, "5_1": 6, "7_1": 8, "5_1_2": 8, "5_1_4": 10, "7_1_4": 12, "FOA": 4, "HOA2": 9, "HOA3": 16, "EXT": 1, "ISM1": 1, "ISM2": 2, "ISM3": 3, "ISM4": 4, "MASA1TC": 1, "MASA2TC": 2, } SIGNAL_SOURCE = "scripts/testv/stv48c.pcm" CUT_LEN_SECS = 1 FS = 48000 def main(args): channels = OC_TO_NCHANNELS[ args.outformat ] outfile = args.outfile signal = gen_signal(channels) # write out interleaved signal.reshape(-1, 1).tofile(outfile) def gen_signal(channels:int) -> np.ndarray: # get the measurement signal from the source file (mono file) signal = np.fromfile(SIGNAL_SOURCE, dtype=np.int16) # shorten to one second signal = signal[:FS * CUT_LEN_SECS] # create other channels with same signal signal = np.repeat(signal.reshape((-1, 1)), channels, axis=1) return signal if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("outformat", type=str, choices=list(OC_TO_NCHANNELS.keys()), help="output format to generate for") parser.add_argument("outfile", help="output .pcm file with measurement signal") args = parser.parse_args() main(args) No newline at end of file