-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcreate_probe_sweep.py
executable file
·49 lines (42 loc) · 2.18 KB
/
create_probe_sweep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!env python3
# The file creates wav-file with a probe impulse to be played through speakers.
import numpy as np
import scipy.signal
import math
import scipy.io.wavfile
import sys
from optparse import OptionParser
from room_response_estimator import *
#######################################################################################################################
def create_probe(RIR_estimator, filename):
'''
Generates probe signal, store it to a wav-file, and return its waveform.
'''
estimator = RoomResponseEstimator(options.duration, options.lowfreq, options.highfreq)
# Store probe signal in wav file.
x = np.append( np.zeros(round((RIR_estimator.Fs))), estimator.probe_pulse * 0.1 )
scipy.io.wavfile.write(filename, round(RIR_estimator.Fs), x)
#######################################################################################################################
if __name__ == "__main__":
parser = OptionParser()
parser.add_option( "-d", "--duration", action="store",
type="float", dest="duration",
default=10,
help="Duration of probe impulse.")
parser.add_option( "-b", "--low-freq", action="store",
type="float", dest="lowfreq",
default=100,
help="The lowest detected frequency [Hz].")
parser.add_option( "-e", "--high-freq", action="store",
type="float", dest="highfreq",
default=15000,
help="The highest frequency in probe impulse [Hz].")
parser.add_option( "-p", "--probe-file", action="store",
type="string", dest="probe_filename",
default="test_sweep.wav",
help="The probe sweep wave file name.")
(options, args) = parser.parse_args()
print("Storing probe signale to \"{}\"\nFrequency range [{}-{}], duration {}s".format(\
options.probe_filename, options.lowfreq, options.highfreq, options.duration))
estimator = RoomResponseEstimator(options.duration, options.lowfreq, options.highfreq)
create_probe(estimator, options.probe_filename)