cyndilib.audio_reference¶
Utilities for handling NDI® audio reference levels.
Added in version 0.0.8.
AudioReference¶
- class cyndilib.audio_reference.AudioReference(*values)¶
Bases:
IntFlagAn enum for NDI® Audio Reference Levels
The member values correspond to the normalized (+/- 1.0) values described in the Dynamic Range section of the documentation.
Added in version 0.0.8.
AudioReferenceConverter¶
- class cyndilib.audio_reference.AudioReferenceConverter¶
Bases:
objectConvert between different NDI®
AudioReferencelevels.Added in version 0.0.8.
- calc_amplitude(self, value_dB: float)¶
Calculate the amplitude from a dB value, taking into account the
referencelevel.This is calculated as:
\[A = 10 ^ {\frac{dB - V_{ref}}{20}}\]where \(V_{ref}\) is the dB value of the current
referencelevel and \(dB\) is the input value_dB.
- calc_dB(self, value_amplitude: float)¶
Calculate the dB value from an amplitude, taking into account the
referencelevel.This is calculated as:
\[dB = 20 * log_{10}(A) + V_{ref}\]where \(V_{ref}\) is the dB value of the current
referencelevel and \(A\) is the input value_amplitude.
- divisor¶
The value to convert from the current
referencelevel to NDI® levels.This is calculated as:
>>> divisor = 1 / self.multiplier
- from_ndi_array(self, src: float[:, _:], dest: float[:, _:])¶
Convert a 2D array of values from NDI® levels.
- Parameters:
src – The 2D source array of values.
dest – The 2D destination array for the converted values.
- multiplier¶
The value to convert from NDI® levels to the current
referencelevel.This is calculated as:
>>> multiplier = self.calc_amplitude(0.0)
- reference¶
The
AudioReferencefor this converter.
- to_ndi_array(self, src: float[:, _:], dest: float[:, _:])¶
Convert a 2D array of values to NDI® levels.
- Parameters:
src – The 2D source array of values.
dest – The 2D destination array for the converted values.
- to_other(self, other: AudioReference, value: float, force: bool = False)¶
Convert an amplitude value from the current
referencelevel to another reference level.This is calculated as:
\[V_{o} = V \cdot \frac{M_{o}}{D_{s}}\]where \(M_{o}\) is the
multiplierof this instance, \(D_{s}\) is thedivisorof other, \(V\) is the input value, and \(V_{o}\) is the output value.
- to_other_array(self, other: AudioReference, src: float[:, _:], dst: float[:, _:])¶
Convert a 2D array of values from the current
referencelevel to another.- Parameters:
other – The target
AudioReferencelevel.src – The 2D source array of values.
dst – The 2D destination array for the converted values.
- to_other_array_in_place(self, other: AudioReference, value: float[:, _:], force: bool = False)¶
Convert a 2D array of values from the current
referencelevel to another.This is an in-place conversion.
- Parameters:
other – The target
AudioReferencelevel.value – The 2D array of values to convert.
force (bool, optional) – Whether to force the conversion even if the levels are the same. Default is False. (This is mainly used for testing)