更新UCD-API库及文档
This commit is contained in:
51
docs/UCD-API文档/examples/work_with_audio_capturer.py
Normal file
51
docs/UCD-API文档/examples/work_with_audio_capturer.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# To initialize UniTAP library wrapper user should create UniTAP.TsiLib() object.
|
||||
#
|
||||
lUniTAP = UniTAP.TsiLib()
|
||||
|
||||
#
|
||||
# For opening device, please, put serial number of the device as 8 symbol str or put index of device.
|
||||
#
|
||||
# dev = lUniTAP.open("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# For UCD-500 available following roles:
|
||||
# UniTAP.dev.UCD500.DPSourceDPSink, USBCSourceUSBCSink, DPSourceUSBCSink and USBCSourceDPSink
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# First variant of capturing = set frame count number
|
||||
role.dprx.audio_capturer.start(frames_count=1)
|
||||
role.dprx.audio_capturer.stop()
|
||||
result = role.dprx.audio_capturer.capture_result
|
||||
|
||||
# Second variant of capturing = set number of millisecond
|
||||
# role.dprx.audio_capturer.start(m_sec=1000)
|
||||
# role.dprx.audio_capturer.stop()
|
||||
# result = role.dprx.audio_capturer.capture_result
|
||||
|
||||
# Third variant of capturing = capturing with user's stop command (without predefined number of frames or second)
|
||||
# role.dprx.audio_capturer.start()
|
||||
# result = role.dprx.audio_capturer.pop_element_as_result_object()
|
||||
# role.dprx.audio_capturer.stop()
|
||||
|
||||
# Save captured frames
|
||||
# file_format - BIN and WAV
|
||||
# path - full path to save the audio
|
||||
result.save_to_file(file_format=UniTAP.AudioFileFormat.WAV,
|
||||
path="audio")
|
||||
|
||||
#
|
||||
# Since the 3.5 version, TsiLib and TSIDevice objects have the option to be closed earlier.
|
||||
# TSIDevice can be closed with the TsiLib method close(). TsiLib can be closed with cleanup().
|
||||
# Clean up will close all opened devices and block ability to open any devices
|
||||
# with same TsiLib object.
|
||||
#
|
||||
lUniTAP.close(dev)
|
||||
|
||||
lUniTAP.cleanup()
|
||||
Reference in New Issue
Block a user