helper module
- freqrir.helper.distance_for_permutations(receiver, source, room_dimensions, vector_triplet)
Computes the distances between the reciever and the eight image source permutations.
- Parameters
receiver (list[float]) – Reciever position.
source (list[float]) – Source position.
room_dimensions (list[float]) – Room dimensions.
vector_triplet (list[float]) – Vector triplet (n,l,m) (Allen 1979).
- Returns
The distances between the reciever and the eight image source permutations.
- Return type
distances (list[float] with shape (8,))
Examples
>>> distance_for_permutations(np.array([0,0,0]), np.array([1,1,1]), np.array([5,5,5]), np.array([0,0,0]))[0] 1.7320508075688772 # Take the first element of the list.
- freqrir.helper.distance_from_offset(r, offset=[0, 0, 0])
Compute the distances for the reciever locations from the offset.
This method generates a density plot for the distances from the offset. The purpose of this method is to verify that the distances are being generated with a uniformly distributed magnitude from the offset (i.e. the center of the point cloud).
- Parameters
r (Array-like) – Array of reciever locations.
offset (list[float]) – Offset from origin for center of point cloud. Default is [0, 0, 0] (origin).
- Returns
Array of distances.
- Return type
d (Array-like)
- freqrir.helper.meters_to_sample_periods(x, sample_rate, c=304.8)
Convert a measurement from meters to sample periods.
- Parameters
x (float) – A measurement in meters (m).
c (float) – Speed of sound (m/s). Defaults to 304.8 m/s (i.e. 1 ft/ms).
T (float) – Sampling period (s). Defaults to 1E-4 s (i.e. 0.1 ms).
- Returns
A measurement in sample periods (s).
- Return type
x (float)
Examples
>>> meters_to_sample_periods(3.048, 8000) # 1.2 meters (m) 80 # sample periods (s)
- freqrir.helper.plot_frequency_rir(rir, points, frequency, save=None)
Plot room impulse repsonse in the frequency domain.
- Parameters
rir (list[complex]) – A pressure wave in the frequency domain.
points (int) – The number of points.
frequency (int) – Sampling rate (Hz)
save (str, optional) – Path to save file to. Defaults to None.
- freqrir.helper.plot_recievers(r, projection='2d')
Plot the reciever locations.
- Parameters
r (Array-like) – Array of reciever locations.
projection (str) – Projection of the reciever locations. Default is 2d.
- freqrir.helper.plot_time_rir(rir, points, f, rt60, save=None)
Plot room impulse repsonse in the time domain.
- Parameters
rir (list[complex]) – A pressure wave in the frequency domain.
points (int) – The number of points.
rt60 (float) – The reverberation time (RT60) of the room.
f (int) – Sampling rate (Hz)
save (str, optional) – Save the plot to a file.
- freqrir.helper.sample_period_to_feet(x, sample_frequency, c=1000)
Convert a measurement from sample periods to meters.
- Parameters
x (float) – A measurement in sample periods.
sample_frequency (int) – Sampling rate (Hz).
c (float, optional) – Speed of sound (ft/s). Defaults to 1000 ft/ms (i.e. 304.8 m/s SI).
- Returns
A measurement in meters (feet).
- Return type
x (float)
Examples
>>> sample_period_to_feet(80,8000) # 80 sample periods (s) 10 # ft
- freqrir.helper.sample_period_to_meters(x, sample_rate, c=304.8)
Convert a measurement from sample periods to meters.
- Parameters
x (float) – A measurement in sample periods.
sample_rate (int) – Sampling rate (Hz).
c (float) – Speed of sound (m/s). Defaults to 304.8 m/s (i.e. 1 ft/ms).
- Returns
A measurement in meters (m).
- Return type
x (float)
Examples
>>> sample_period_to_meters(80, 8000) # 80 sample periods (s) at 8 kHZ 3.048 # meters (m)
- freqrir.helper.sample_random_receiver_locations(n, radius, offset=[0, 0, 0])
Sample a random reciever location from within a spherical point cloud.
- Parameters
n (int) – number of receiver locations to sample.
radius (float) – radius of the point cloud.
offset (list[float], optional) – offset from origin for center of point cloud. Default is [0, 0, 0] (origin).
- Returns
Array of reciever locations.
- Return type
r (Array-like)