A collection of loaders for real (recorded) impulse response databases, because apparently people cannot to stick to a single way of storing audio data.
Use pip install realrirs
. Depending on what databases you want to use, you will have to install additional dependencies. To install all dependencies, use pip install realrirs[full]
.
import pathlib
import realrirs.datasets
aachen_impulse_response_database = realrirs.datasets.AIRDataset(
pathlib.Path("/path/to/AIR_1_4") # Can also pass simple str
)
# List all IRs in database, tuples of (name, n_channels, n_samples, sample_rate)
aachen_impulse_response_database.list_irs()
# => [(PosixPath('/path/to/AIR_1_4/air_phone_stairway_hfrp_1.mat'), 1, 144000, 48000),
# (PosixPath('/path/to/AIR_1_4/air_binaural_booth_1_1_1.mat'), 1, 32767, 48000)],
# ...]
# Get single IR, ndarray of shape (n_channels, n_samples)
aachen_impulse_response_database[aachen_impulse_response_database.list_irs()[0][0]]
# => array([[ 1.32764243e-07, -2.18957279e-08, 1.28081465e-07, ...,
# 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])
# Get all IRs, much faster than using [] (__getitem__) multiple times
aachen_impulse_response_database.getall()
# => <generator object FileIRDataset.getall at 0x11af88e40>
# Generator contains (name, sample_rate, ir) tuples.
next(aachen_impulse_response_database.getall())
# => (PosixPath('/path/to/AIR_1_4/air_binaural_aula_carolina_0_1_1_90_3.mat'), 48000,
# array([[-2.73920884e-06, -3.49019781e-06, -1.70998298e-06, ..., -7.13979890e-11]]))