clarity.evaluator.msbg.msbg module¶
Implementation of the MSBG hearing loss model.
- class clarity.evaluator.msbg.msbg.Ear(src_pos: str = 'ff', sample_rate: float = 44100.0, equiv_0db_spl: float = 100.0, ahr: float = 20.0)[source]¶
Bases:
object
Representation of a pairs of ears.
- static get_src_correction(src_pos: str) ndarray [source]¶
Select relevant external field to eardrum correction.
- Parameters:
src_pos (str) – Position of src. One of ff, df or ITU
- make_calibration_signal(ref_rms_db: float, n_channels: int = 1) tuple[ndarray, ndarray] [source]¶
Add the calibration signal to the start of the signal.
- Parameters:
ref_rms_db (float) – reference rms level in dB
- Returns:
tuple[ndarray, ndarray] - pre and post calibration signals
- process(signal: ndarray, add_calibration: bool = False) list[ndarray] [source]¶
Run the hearing loss simulation.
- Parameters:
signal (ndarray) – signal to process, shape either N, Nx1, Nx2
add_calibration (bool) – prepend calibration tone and speech-shaped noise (default: False)
- Returns:
the processed signal
- Return type:
np.ndarray
- static src_to_cochlea_filt(input_signal: ndarray, src_correction: ndarray, sample_rate: float, backward: bool = False) ndarray [source]¶
Simulate middle and outer ear transfer functions.
Made more general, Mar2012, to include diffuse field as well as ITU reference points, that were included in DOS-versions of recruitment simulator, released ca 1999-2001, and on hearing group website, Mar2012 variable [src_pos] takes one of 3 values: ‘ff’, ‘df’ and ‘ITU’ free-field to cochlea filter forwards or backward direction, depends on ‘backward’ switch. NO LONGER via 2 steps. ff to eardrum and then via middle ear: use same length FIR 5-12-97.
- Parameters:
input_signal (ndarray) – signal to process
src_correction (np.ndarray) – correction to make for src position as an array returned by get_src_correction(src_pos) where src_pos is one of ff, df or ITU
sample_rate (int) – sampling frequency
backward (bool, optional) – if true then cochlea to src (default: False)
- Returns:
the processed signal
- Return type:
np.ndarray