lasp/scripts/lasp_record

65 lines
1.8 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python3
import sys, logging, os, argparse
logging.basicConfig(level=logging.DEBUG)
import multiprocessing
from lasp.lasp_multiprocessingpatch import apply_patch
2019-10-27 13:19:26 +00:00
from lasp.device import Daq, DaqChannel, DaqConfigurations
2019-12-22 14:00:50 +00:00
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')
2019-10-27 13:19:26 +00:00
args = parser.parse_args()
2019-10-27 13:19:26 +00:00
configs = DaqConfigurations.loadConfigs()
config_keys = [key for key in configs.keys()]
for i, key in enumerate(config_keys):
print(f'{i:2} : {key}')
2019-10-27 13:19:26 +00:00
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