cyndilib.audio_reference#

Utilities for handling NDI® audio reference levels.

New in version 0.0.8.

AudioReference#

class cyndilib.audio_reference.AudioReference(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: IntFlag

An 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.

dBu#

Reference for dBu (+4 dB)

Type:

int

dBVU#

Reference for dBVU (0 dB)

Type:

int

dBFS_smpte#

Reference for dBFS (SMPTE) (-20 dB)

Type:

int

dBFS_ebu#

Reference for dBFS (EBU) (-14 dB)

Type:

int

New in version 0.0.8.

AudioReferenceConverter#

class cyndilib.audio_reference.AudioReferenceConverter#

Bases: object

Convert between different NDI® AudioReference levels.

New in version 0.0.8.

calc_amplitude(self, value_dB: float)#

Calculate the amplitude from a dB value, taking into account the reference level.

This is calculated as:

\[A = 10 ^ {\frac{dB - V_{ref}}{20}}\]

where \(V_{ref}\) is the dB value of the current reference level and \(dB\) is the input value_dB.

calc_dB(self, value_amplitude: float)#

Calculate the dB value from an amplitude, taking into account the reference level.

This is calculated as:

\[dB = 20 * log_{10}(A) + V_{ref}\]

where \(V_{ref}\) is the dB value of the current reference level and \(A\) is the input value_amplitude.

divisor#

The value to convert from the current reference level 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.

is_ndi_native#

Check if the current reference level is the native NDI® level.

multiplier#

The value to convert from NDI® levels to the current reference level.

This is calculated as:

>>> multiplier = self.calc_amplitude(0.0)
reference#

The AudioReference for 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 reference level to another reference level.

This is calculated as:

\[V_{o} = V \cdot \frac{M_{o}}{D_{s}}\]

where \(M_{o}\) is the multiplier of this instance, \(D_{s}\) is the divisor of 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 reference level to another.

Parameters:
  • other – The target AudioReference level.

  • 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 reference level to another.

This is an in-place conversion.

Parameters:
  • other – The target AudioReference level.

  • 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)

value#

The dB value of the reference level.