Skip to main content

Audio wav file test module

Project description

Copyright (c) 2021 lorry_rui

//////////usage://///////////////

for test sweep tone WAV file only

audio file analyze USE only @ Lorry RUi
Mail to: lorryruizhihua@gmail.com lrui@logitech.com

https://pypi.org/project/LvAut

https://github.com/Lorrytoolcenter/LvAut

|tests| |coverage| |docs| |python-versions| |license|  

The Python package audio_wav handles all kind of audio files

sample code:

.. code:: python

   import LvAut.lvaut_THD as AUT 
   filename='yourfile.wav' 
   signal, sample_rate, channels=AUT.load(filename) 

change master speaker volume

.. code:: python

	import LvAut.lvaut_THD as AUT  
	AUT.setspeakervolume(40)  ## set master speaker volume from 0 to 100

play master speaker

.. code:: python

	import LvAut.lvaut_THD as AUT
	AUT.playsoundWin('yourfile.wav')

list all speaker and mics devices

.. code:: python

	import LvAut1.device as sd
	print(sd.query_devices())

recording master speaker

.. code:: python

	import LvAut.device as sd
	import LvAut.lvaut_THD as AUT
	fs = 44100  # Sample rate
	seconds = 5  # Duration of recording
	myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=1)  # using default mic
	#myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=1, device="Microphone (Logitech Webcam C930e), Windows DirectSound")
	sd.wait()  # Wait until recording is finished
	AUT.write("test.wav",myrecording,fs)

analyze_sweep tone

.. code-block:: python

	import LvAut.lvaut_THD as AUT  
	filename='Device_Mic_THD_R_3.wav'  
	trigeFrequncy=400  ## this need sweep from high(above 400) to low sweep tone  
	stopananlysis=100   ## stop analyze_sweep  
	channaelselect=1 ### if recording is dual channel ,leftchannel=1, rightchannel=2, otherwise no need to define  
	freq,thdh,thd_N,power,Freq_THD,thd_data,Freq_Power,PowerS,RubBuzz_data=AUT.analyze_sweep(filename, trigeFrequncy,stopananlysis,channaelselect) 
	print('FFT Frequency:   %.1f Hz' % freq)  
	print("Sweep Max THD:   %.4f%% " %thdh)  
	print("Sweep Max THD+N: %.4f%%      Note, this is single tone use only " %thd_N)  
	print("spectrum Max Power:       %.2fdB " %power)     

output explain

1)freq  means: single tone , measured frequency  
1.1)thd_N   means: single Max THD+N  	
2)thdh   means: Sweep Max THD  
3)Freq_THD, measure THD's frequency
4)thd_data, measure THD's data
5)Freq_Power,measure Power's frequency
6)PowerS,  measure Power's data
7)RubBuzz_data    measure RB's data

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

LvAut-2021.1.1.tar.gz (1.4 MB view hashes)

Uploaded Source

Built Distribution

LvAut-2021.1.1-py3-none-any.whl (1.4 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page