2019-12-26 15:04:49 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import argparse
|
|
|
|
import numpy as np
|
2021-05-05 17:48:04 +00:00
|
|
|
import sys, logging, os, argparse
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
import multiprocessing
|
|
|
|
from lasp.lasp_multiprocessingpatch import apply_patch
|
2021-05-07 20:53:29 +00:00
|
|
|
from lasp.lasp_avstream import StreamManager
|
|
|
|
from lasp.lasp_common import AvType
|
2021-05-05 17:48:04 +00:00
|
|
|
from lasp.lasp_siggen import Siggen, SignalType, SiggenData
|
|
|
|
from lasp.device import DaqConfigurations
|
2019-12-26 15:04:49 +00:00
|
|
|
|
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
multiprocessing.set_start_method('forkserver', force=True)
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='Play a sine wave'
|
|
|
|
)
|
|
|
|
device_help = 'DAQ Device to play to'
|
|
|
|
parser.add_argument('--device', '-d', help=device_help, type=str,
|
|
|
|
default='Default')
|
2019-12-26 15:04:49 +00:00
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
args = parser.parse_args()
|
2019-12-26 15:04:49 +00:00
|
|
|
|
|
|
|
|
2021-05-05 17:48:04 +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}')
|
|
|
|
|
|
|
|
choosen_index = input('Number of configuration to use: ')
|
|
|
|
try:
|
|
|
|
daqindex = int(choosen_index)
|
|
|
|
except:
|
|
|
|
sys.exit(0)
|
|
|
|
|
2019-12-26 15:04:49 +00:00
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
choosen_key = config_keys[daqindex]
|
2021-05-07 20:53:29 +00:00
|
|
|
daqconfig = configs[choosen_key].output_config
|
2019-12-26 15:04:49 +00:00
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
print(f'Choosen configuration: {choosen_key}')
|
2019-12-26 15:04:49 +00:00
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
try:
|
2021-05-07 20:53:29 +00:00
|
|
|
streammgr = StreamManager()
|
|
|
|
outq = streammgr.getOutputQueue()
|
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
siggendata = SiggenData(
|
|
|
|
fs=48e3,
|
2021-05-07 20:53:29 +00:00
|
|
|
nframes_per_block=2048,
|
2021-05-05 17:48:04 +00:00
|
|
|
dtype=np.dtype(np.int16),
|
|
|
|
eqdata=None,
|
|
|
|
level_dB=-20,
|
|
|
|
signaltype=SignalType.Periodic,
|
|
|
|
signaltypedata=(1000.,)
|
|
|
|
)
|
2021-05-07 20:53:29 +00:00
|
|
|
siggen = Siggen(outq, siggendata)
|
2019-12-26 15:04:49 +00:00
|
|
|
|
2021-05-07 20:53:29 +00:00
|
|
|
streammgr.activateSiggen()
|
2019-12-26 15:04:49 +00:00
|
|
|
|
2021-05-07 20:53:29 +00:00
|
|
|
streammgr.startStream(AvType.audio_output, daqconfig)
|
2019-12-26 15:04:49 +00:00
|
|
|
|
2021-05-05 17:48:04 +00:00
|
|
|
input('Press any key to stop...')
|
2021-05-07 20:53:29 +00:00
|
|
|
streammgr.stopStream(AvType.audio_output)
|
2021-05-05 17:48:04 +00:00
|
|
|
finally:
|
2021-05-07 20:53:29 +00:00
|
|
|
siggen.cleanup()
|
|
|
|
streammgr.cleanup()
|
2019-12-26 15:04:49 +00:00
|
|
|
|
|
|
|
|