Class GraphicMeter

All Implemented Interfaces:
LXComponent.Renamable, LXLoopTask, LXPath, LXSerializable, LXOscComponent, LXNormalizedParameter, LXParameter, LXParameterListener
Direct Known Subclasses:
LXAudioEngine.Meter

public class GraphicMeter extends DecibelMeter
A graphic meter splits the signal into frequency bands and computes envelopes for each of the bands independently. It can also give the overall level, just like a normal decibel meter. Since energy is not typically evenly distributed through the spectrum, a slope can be applied to the equalizer to even out the levels, typically something like 4.5 dB/octave is used, though this varies by recording.
  • Field Details

  • Constructor Details

    • GraphicMeter

      public GraphicMeter(LXAudioComponent component)
    • GraphicMeter

      public GraphicMeter(LXAudioBuffer buffer)
      Default graphic equalizer with 2 bands per octave
      Parameters:
      buffer - Audio buffer
    • GraphicMeter

      public GraphicMeter(String label, LXAudioBuffer buffer)
      Default graphic equalizer with 2 bands per octave
      Parameters:
      label - Label
      buffer - Audio buffer
    • GraphicMeter

      public GraphicMeter(LXAudioBuffer buffer, int numBands)
      Makes a graphic equalizer with a default slope of 4.5 dB/octave
      Parameters:
      buffer - Audio buffer to monitor
      numBands - Number of bands
    • GraphicMeter

      public GraphicMeter(String label, LXAudioBuffer buffer, int numBands)
      Makes a graphic equalizer with a default slope of 4.5 dB/octave
      Parameters:
      label - Label
      buffer - Audio buffer to monitor
      numBands - Number of bands
  • Method Details

    • addProcessor

      public final void addProcessor(GraphicMeter.Processor processor)
    • removeProcessor

      public final void removeProcessor(GraphicMeter.Processor processor)
    • onAudioFrame

      protected void onAudioFrame()
      Description copied from class: DecibelMeter
      Compute new values when a frame of audio input is received. This is called by the thread that has filled the audio buffer.
      Overrides:
      onAudioFrame in class DecibelMeter
    • onStop

      protected void onStop()
      Description copied from class: LXRunnableComponent
      Optional subclass method when stop happens.
      Overrides:
      onStop in class DecibelMeter
    • getRaw

      public float getRaw(int i)
      Get most recent raw unsmoothed RMS amplitude of band i
      Parameters:
      i - Raw band index
      Returns:
      Raw value of band i
    • getDecibels

      public double getDecibels(int i)
      Parameters:
      i - Which frequency band to access
      Returns:
      Level of that band in decibels
    • getDecibelsf

      public float getDecibelsf(int i)
      Parameters:
      i - Which frequency band to access
      Returns:
      Level of that band in decibels as a float
    • getNumBands

      public int getNumBands()
      Number of bands on the meter
      Returns:
      Number of bands
    • getBand

      public double getBand(int i)
      Parameters:
      i - Which frequency band to retrieve
      Returns:
      The value of the ith frequency band
    • getBandf

      public float getBandf(int i)
      Parameters:
      i - Which frequency band to retrieve
      Returns:
      The value of that band, as a float
    • getSquare

      public double getSquare(int i)
      Gets the squared value of the i-th band
      Parameters:
      i - Frequency band
      Returns:
      Squared normalized value
    • getSquaref

      public float getSquaref(int i)
      Gets the squared value of the i-th band
      Parameters:
      i - Frequency band
      Returns:
      Squared normalized value as a float
    • getAverage

      public double getAverage(int minBand, int avgBands)
      Averages the value of a set of bands
      Parameters:
      minBand - The first band to start at
      avgBands - How many bands to average
      Returns:
      Average value of all these bands
    • getAveragef

      public float getAveragef(int minBand, int avgBands)
      Averages the value of a set of bands
      Parameters:
      minBand - The first band to start at
      avgBands - How many bands to average
      Returns:
      Average value of all these bands as a float
    • dispose

      public void dispose()
      Description copied from class: LXComponent
      Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally call super.dispose() at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.
      Specified by:
      dispose in interface LXParameter
      Overrides:
      dispose in class LXComponent