psiaudio.calibration module
- class BaseCalibration(reference, attrs=None)
Bases:
object
Assumes that the system is linear for a given frequency
- Parameters
frequency (1D array) – Frequencies that system sensitivity was measured at.
sensitivity (1D array) – Sensitivity of system in dB
attrs ({None, dict}) – Information regarding the calibration (e.g., the filename the calibration was loaded from).
- get_attenuation(frequency, voltage, level)
- get_db(frequency, voltage)
- get_gain(frequency, level, attenuation=0)
- get_mean_sf(flb, fub, level, attenuation=0)
- get_sens(frequency)
- get_sf(frequency, level, attenuation=0)
- set_fixed_gain(fixed_gain)
- class BaseFrequencyCalibration(reference, attrs=None)
Bases:
BaseCalibration
- classmethod from_db(frequency, level, vrms=1, **kwargs)
Generates a calibration object based on the recorded level in dB re. reference.
- Parameters
frequency (array-like) – List of frequencies (in Hz)
level (array-like) – List of magnitudes in dB re. reference (e.g., speaker output in SPL) for the specified RMS voltage.
vrms (float) – RMS voltage (in Volts)
initialization. (Additional kwargs are passed to the class) –
- classmethod from_pascals(frequency, magnitude, vrms=1, **kwargs)
Generates a calibration object based on the recorded value (in Pascals)
- Parameters
magnitude (array-like) – List of magnitudes (e.g., speaker output in Pa) for the specified RMS voltage.
frequency ({None, array-like}) – List of frequencies (in Hz)
vrms (float) – RMS voltage (in Volts)
initialization. (Additional kwargs are passed to the class) –
- classmethod from_spl(frequency, spl, vrms=1, **kwargs)
- exception CalibrationError(message)
Bases:
Exception
- exception CalibrationNFError(frequency, snr)
Bases:
CalibrationError
- exception CalibrationTHDError(frequency, thd)
Bases:
CalibrationError
- class FlatCalibration(sensitivity, fixed_gain=0, reference=None, attrs=None)
Bases:
BaseCalibration
- classmethod as_attenuation(vrms=1, **kwargs)
- classmethod from_db(level, vrms=1, **kwargs)
Generates a calibration object based on the recorded level (in dB)
- Parameters
levels (array-like) – List of magnitudes in dB re desired unit (e.g., speaker output in SPL) for the specified RMS voltage.
vrms (float) – RMS voltage (in Volts)
initialization. (Additional kwargs are passed to the class) –
- classmethod from_mv_pa(mv_pa, **kwargs)
- classmethod from_pascals(magnitude, vrms=1, **kwargs)
Generates a calibration object based on the recorded value (in Pascals)
- Parameters
frequency (array-like) – List of freuquencies (in Hz)
magnitude (array-like) – List of magnitudes (e.g., speaker output in Pa) for the specified RMS voltage.
vrms (float) – RMS voltage (in Volts)
initialization. (Additional kwargs are passed to the class) –
- classmethod from_spl(spl, vrms=1, **kwargs)
- get_mean_sf(flb, fub, spl, attenuation=0)
- get_sens(frequency)
- classmethod unity()
Passthrough calibration allowing signal level to be specified in Vrms.
- class InterpCalibration(frequency, sensitivity, fixed_gain=0, phase=None, fill_value=nan, reference=None, attrs=None)
Bases:
BaseFrequencyCalibration
Use when calibration is not flat (i.e., uniform) across frequency.
- Parameters
frequency (array-like, Hz) – Calibrated frequencies (in Hz)
sensitivity (array-like, dB(V/Pa)) – Sensitivity at calibrated frequency in dB(V/Pa) assuming 1 Vrms and 0 dB gain. If you have sensitivity in V/Pa, just pass it in as 20*np.log10(sens).
fixed_gain (float) –
Fixed gain of the input or output. The sensitivity is calculated using a gain of 0 dB, so if the input (e.g. a microphone preamp) or output (e.g. a speaker amplifier) adds a fixed gain, this needs to be factored into the calculation.
For input calibrations, the gain must be negative (e.g. if the microphone amplifier is set to 40 dB gain, then provide -40 as the value).
- get_phase(frequency)
- get_sens(frequency)
- class PointCalibration(frequency, sensitivity, fixed_gain=0, reference=None, attrs=None)
Bases:
BaseFrequencyCalibration