2019-12-18 09:02:20 +00:00
|
|
|
#!/usr/bin/python3
|
2021-05-04 13:10:13 +00:00
|
|
|
import sys, logging, os, argparse
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
import multiprocessing
|
|
|
|
from lasp.lasp_multiprocessingpatch import apply_patch
|
2018-07-31 11:09:42 +00:00
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
from lasp.device import DaqConfigurations
|
2019-12-22 14:00:50 +00:00
|
|
|
from lasp.lasp_avstream import AvStream, AvType
|
2019-12-18 09:02:20 +00:00
|
|
|
from lasp.lasp_record import Recording
|
2020-09-18 06:52:56 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
multiprocessing.set_start_method('forkserver', force=True)
|
|
|
|
apply_patch()
|
2020-09-18 06:52:56 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
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]')
|
2020-09-18 06:52:56 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
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
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
args = parser.parse_args()
|
2019-10-27 13:19:26 +00:00
|
|
|
|
2019-12-18 09:02:20 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
configs = DaqConfigurations.loadConfigs()
|
2019-12-18 09:02:20 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
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
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
choosen_index = input('Number of configuration to use: ')
|
|
|
|
try:
|
|
|
|
daqindex = int(choosen_index)
|
|
|
|
except:
|
|
|
|
sys.exit(0)
|
2019-12-18 09:02:20 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
choosen_key = config_keys[daqindex]
|
|
|
|
config = configs[choosen_key].input_config
|
2018-09-13 11:56:05 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
print(f'Choosen configuration: {choosen_key}')
|
2019-12-18 09:02:20 +00:00
|
|
|
|
2021-05-04 13:10:13 +00:00
|
|
|
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
|
2019-12-18 09:02:20 +00:00
|
|
|
|