treble_tsdk.results.device_ir
Device impulse response handling.
Provides the DeviceIR class for working with device-rendered impulse responses from spatial audio data.
Classes
Device impulse response class for handling device impulse response data |
- class treble_tsdk.results.device_ir.DeviceIR
Device impulse response class for handling device impulse response data
- __init__(data: np.ndarray, sampling_rate: float, spatial_ir: SpatialIR = None, time: np.ndarray = None, data_fd: tuple[np.ndarray, np.ndarray] = None, source: list['SourceResults'] = None, receiver: list['ReceiverResults'] = None, zero_pad_samples: int = 0, normalization_coefficient: float = None, labels: list[str] = None)
Class containing everything related to device impulse responses.
- Parameters:
data (np.ndarray) – The time domain device rendered impulse response
sampling_rate (float) – Sampling rate of impulse response
spatial_ir (SpatialIR | None) – The SpatialIR object associated with the Device impulse response
time (np.ndarray | None) – Time vector for the time series
data_fd (np.ndarray | None) – The device rendered transfer function and the frequency vector , defaults to None
source (SourceDto | None) – The source associated with the IR, defaults to None
receiver (ReceiverDto | None) – The receiver associated with the IR
normalization_coefficient (float | None) – Coefficient used to normalize data when written to .wav
- change_device(device: DeviceDefinition, orientation: Rotation = Rotation(azimuth=0.0, elevation=0.0, roll=0.0), ignore_max_frequency: bool = False) DeviceIR
Render a new device impulse response
- Parameters:
device (DeviceDefinition) – An object representing a device/head related transfer function
Rotation – orientation rotation of the device in orientation, defaults to 0.0
ignore_max_frequency (bool) – Whether to ignore the maximum frequency of the device (if it contains a maximum valid frequency)
- Return DeviceIR:
The resulting impulse response object for the device
- 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
- filter(filter_definition: FilterDefinition | list[FilterDefinition] | Callable[[np.ndarray, int], np.ndarray] | list[Callable[[np.ndarray, int], np.ndarray]]) MonoIR | SpatialIR | DeviceIR | AudioSignal | ConvolvedAudioSignal
- Parameters:
filter_definition – The filter definition to use. Either a class inheriting from
FilterDefinition, or a callable that accepts(numpy.ndarray, int)and returns anumpy.ndarray. A single value or a list of either type is accepted.- Returns:
The filtered impulse response.
- classmethod from_file(filepath: str | Path, channel: int = None, zero_pad_samples: int = 0) AudioSignal
Create from a wav file
- playback(channel: int | None = None) IPython.display.Audio
Play back the audio using the ipython display module
- Parameters:
channel (int | None) – select the 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
- plot(comparison: dict[str, DeviceIR] | None = None, label: str | None = None)
Create a plot widget for the device 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
- strip_first_samples(n_samples: int) numpy.ndarray
Returns an array with the first n_samples removed
- unpadded_data() numpy.ndarray
Returns the impulse response without zero padding
- Return np.ndarray:
The impulse response without zero padding
- unpadded_time() numpy.ndarray
Returns the time vector without zero padding
- Return np.ndarray:
The time vector without zero padding
- 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
- 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
- property frequency: numpy.ndarray
Frequency vector for the frequency domain representation.
- Returns np.ndarray:
Frequency values in Hz.
- property frequency_response: numpy.ndarray
Frequency domain representation of the impulse response.
- Returns np.ndarray:
Complex frequency response.