class_docstr: Measure of audio loudness using standard ITU-R BS.1770-3
  
  WARNING: Sampling frequencies other that 44100Hz and 48000Hz are not fully supported
  
  Outputs: 
  Gated Loudness
  Relative Threshold
  Block Loudness    
class_docstr_tok: ["Measure","of","audio","loudness","using","standard","ITU-R","BS.1770-3","WARNING",":","Sampling","frequencies","other","that","44100Hz","and","48000Hz","are","not","fully","supported","Outputs",":","Gated","Loudness","Relative","Threshold","Block","Loudness"]
code: def post_process(self):
      # remove last block in case it has been filled with zeros by the host, according to the standard specification
      self.z = np.array(
          self.z
      )  # self.z was a list, make it a numpy array.
      self.z = self.z[:, :-1]
      self.l = self.l[:-1]
  
      # Absolute Gating
      Jg = np.greater(self.l, self.absoluteThreshold)
      SumTerm = 0
      for n in range(0, self.input_channels):
          zi = np.array(self.z[n])
          zi_Jg = (
              zi * Jg
          )  # These two lines could be compressed in one : zi_Jg = zi[Jg]
          zi_Jg = zi_Jg[zi_Jg > 0]
          if len(zi_Jg):
              SumTerm += self.weights[n] * sum(zi_Jg) / len(zi_Jg)
      SumTerm = max(SumTerm, 1e-10)  # avoid division by zero in log10
      Gamma_r = -0.691 + 10 * np.log10(SumTerm) + self.relativeThreshold
  
      # Relative Gating
      Jg = np.greater(self.l, Gamma_r)
      SumTerm = 0
      for n in range(0, self.input_channels):
          zi = np.array(self.z[n])
          zi_Jg = zi * Jg
          zi_Jg = zi_Jg[zi_Jg > 0]
          if len(zi_Jg):
              SumTerm += self.weights[n] * sum(zi_Jg) / len(zi_Jg)
  
      SumTerm = max(SumTerm, 1e-10)  # avoid division by zero in log10
      GatedLoudness = -0.691 + 10 * np.log10(SumTerm)
  
      # Output result
  
      gated_loudness = self.new_result(
          data_mode="value", time_mode="global"
      )
      gated_loudness.data_object.value = GatedLoudness
      gated_loudness.id_metadata.id += ".gated_loudness"
      gated_loudness.id_metadata.name += "Gated Loudness"
      self.add_result(gated_loudness)
  
      relative_threshold = self.new_result(
          data_mode="value", time_mode="global"
      )
      relative_threshold.data_object.value = Gamma_r
      relative_threshold.id_metadata.id += ".relative_threshold"
      relative_threshold.id_metadata.name += "Relative Threshold"
      self.add_result(relative_threshold)
  
      block_loudness = self.new_result(
          data_mode="value", time_mode="framewise"
      )
      block_loudness.data_object.value = self.l
      block_loudness.id_metadata.id += ".block_loudness"
      block_loudness.id_metadata.name += " Block Loudness"
      self.add_result(block_loudness)
  
file_path: TimeSide/timeside/plugins/analyzer/loudness_ITU.py
imports: from timeside.core import implements, interfacedoc
  from timeside.core.analyzer import Analyzer
  from timeside.core.api import IAnalyzer
  from timeside.core.tools.parameters import HasTraits
  from timeside.core.preprocessors import downmix_to_mono, frames_adapter
  import numpy
  import numpy
  from scipy.signal import lfilter
  import warnings
  from timeside.core.grapher import DisplayAnalyzer
label_desc: Use image node_id 8 for calling the LoudnessITU obj's underlying member method code with example usage: obj.post_process() without return types