treble_tsdk.results.base_ir¶
Base impulse response classes and utilities.
Provides the BaseIR class for working with impulse response data, which is the base class for MonoIR, SpatialIR and DeviceIR. It contains the basic functionality for working with impulse response data, such as filtering, resampling, and convolution.
Classes
Base class for impulse response handling |
|
A class representing the energy drop of an EDC curve, in dB |
- class treble_tsdk.results.base_ir.EnergyDrop¶
A class representing the energy drop of an EDC curve, in dB
- class treble_tsdk.results.base_ir.BaseIR¶
Base class for impulse response handling
- __init__(data: ndarray, sampling_rate: float, time: ndarray | None = None, source: list[Source] | None = None, receiver: list[Receiver] | None = None, zero_pad_samples: int = 0, normalization_coefficient: float | None = None)¶
A Class handling all mono impulse response related actions
- Parameters:
data (np.ndarray) – The time domain impulse response
sampling_rate (float) – The sampling rate of the impulse response
source (Source | None) – Information on source, defaults to None
receiver (Receiver | None) – Information on receiver, defaults to None
zero_pad_samples (int) – The number of samples that have been zero padded in the beginning, defaults to 0
normalization_coefficient (float | None) – The coefficient used to normalize the data
- property frequency: ndarray¶
Frequency vector for the frequency domain representation.
- Returns np.ndarray:
Frequency values in Hz.
- property frequency_response: ndarray¶
Frequency domain representation of the impulse response.
- Returns np.ndarray:
Complex frequency response.
- write_to_file(file_path: str | Path) None¶
Write the impulse response to an HDF5 file
- Parameters:
file_path (str | Path) – The path to the HDF5 file
- unpadded_data() ndarray¶
Returns the impulse response without zero padding
- Return np.ndarray:
The impulse response without zero padding
- unpadded_time() ndarray¶
Returns the time vector without zero padding
- Return np.ndarray:
The time vector without zero padding
- write_to_wav(path_to_file: str | Path, normalize: bool = True, unpad_data: bool = True) float¶
Write the data out to a .wav file
- Parameters:
path_to_file (str | Path) – Where to store the file (the directory needs to exist)
normalize (bool) – Whether to normalize the data before writing to .wav if the impulse response object contains a normalization coefficient this one will be used otherwise it will be the absolute maximum of the data times two, defaults to True
unpad_data (bool) – Whether to unpad the data before writing to .wav, defaults to True
- Return float:
The normalization coefficient used
- filter(filter_definition: FilterDefinition | list[FilterDefinition] | Callable[[ndarray, int], ndarray] | list[Callable[[ndarray, int], ndarray]]) MonoIR | SpatialIR | DeviceIR | AudioSignal | ConvolvedAudioSignal¶
- :param FilterDefinition
- list[FilterDefinition]Callable[[np.ndarray, int], np.ndarray]list[Callable[[np.ndarray, int], np.ndarray]]
- : The filter definition to use, either a class inheriting from FilterDefinition or
a function that accepts two arguments [numpy.ndarry, int] and returns [numpy.array]
- Return “MonoIR | SpatialIR | DeviceIR | AudioSignal | ConvolvedAudioSignal”:
The filtered impulse response
- resample(requested_sampling_rate: float = 32000) MonoIR | SpatialIR | DeviceIR | AudioSignal | ConvolvedAudioSignal¶
resample the data to a new sampling rate
- Parameters:
requested_sampling_rate (int) – The new sampling rate
- Return “MonoIR | SpatialIR | DeviceIR | AudioSignal | ConvolvedAudioSignal”:
The returned audio signal
- playback(channel: int | None = None) Audio¶
Play back the audio using the ipython display module
- Parameters:
channel (int | None) – select that channel you want to play back, if None is selected stereo will be played back if there are two channels, defaults to None
- Return ipd.Audio:
IPython audio object
- convolve_with_audio_signal(audio: AudioSignal) ConvolvedAudioSignal¶
Convolve the impulse response with an audio signal to get a convolved audio signal
- Parameters:
audio (AudioSignal) – signal to be convolved with the IR
- Return AudioSignal:
The convolved audio signal