#!/usr/bin/python3 import sys, logging, os, argparse logging.basicConfig(level=logging.DEBUG) import multiprocessing from lasp.lasp_multiprocessingpatch import apply_patch from lasp.device import DaqConfigurations from lasp.lasp_avstream import AvStream, AvType from lasp.lasp_record import Recording if __name__ == '__main__': multiprocessing.set_start_method('forkserver', force=True) apply_patch() parser = argparse.ArgumentParser( description='Acquire data and store a measurement file' ) parser.add_argument('filename', type=str, help='File name to record to.' ' Extension is automatically added.') parser.add_argument('--duration', '-d', type=float, help='The recording duration in [s]') device_help = 'DAQ Device to record from' parser.add_argument('--input-daq', '-i', help=device_help, type=str, default='Default') args = parser.parse_args() configs = DaqConfigurations.loadConfigs() config_keys = [key for key in configs.keys()] for i, key in enumerate(config_keys): print(f'{i:2} : {key}') choosen_index = input('Number of configuration to use: ') try: daqindex = int(choosen_index) except: sys.exit(0) choosen_key = config_keys[daqindex] config = configs[choosen_key].input_config config.__reduce__() print(f'Choosen configuration: {choosen_key}') try: stream = AvStream( AvType.audio_input, config) # stream.start() rec = Recording(args.filename, stream, args.duration) # input('Stream started, press any key to start record') finally: try: stream.cleanup() del stream except NameError: pass