A python class for measuring an impulse response with time-stretched pulse (TSP a.k.a. swept-sine) signal. pyaudio, numpy, and matplotlib are required.
In example.py
, the output file is written in MATLAB/Octave format using scipy.io. imp_fsXXXX_chXX.mat
The main class file is imptsp.py
. The sampling frequency (Hz) and length of TSP signal (samples) must be specified. Please also refer to example.py
for the usage.
First, the class file is imported in your python script:
from imptsp import imptsp
Initialize for the sampling frequency of 48kHz, TSP length of 65536 samples, and 2 channels:
imp = imptsp(48000, 65536, 2)
Measure the impulse response for input channel #1 and #2 and output channel #1:
(ir,tsp) = imp.get_imp([1,2],1)
The impulse response data is stored in ir
and the recorded TSP signal is stored in tsp
for debugging.
Terminate:
imp.terminate()
If you want to check audio device information, run
python check_audio_dev.py
The other configuration for initialization is as follows:
- imptsp(Fs, tsp_len, [nchannel], [dev_id], [dbg_ch], [flg_fig], [flg_dump], [nsync], [flg_ud], [flg_eval])
- Fs: sampling frequency
- tsp_len: TSP length
- nchannel: number of channels
- dev_id: index of audio device
- dbg_ch: channel number for debug
- flg_fig:plot figure flag
- flg_dump: output wavefile flag
- nsync: number of synchronous additions
- flg_ud: TSP up or down (0 or 1)
- flg_eval: TSP evaluation flag
- pyaudio
- numpy
- matplotlib
- scipy (optional)