Package heronarts.lx.audio
Class DecibelMeter
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.LXRunnableComponent
heronarts.lx.modulator.LXModulator
heronarts.lx.audio.DecibelMeter
- All Implemented Interfaces:
LXComponent.Renamable,LXLoopTask,LXPath,LXSerializable,LXOscComponent,LXNormalizedParameter,LXParameter,LXParameterListener
- Direct Known Subclasses:
GraphicMeter
A DecibelMeter is a modulator that returns the level of an audio signal. Gain
may be applied to the signal. A decibel range is given in which values are
normalized from 0 to 1. Raw decibel values can be accessed if desired.
-
Nested Class Summary
Nested classes/interfaces inherited from class heronarts.lx.modulator.LXModulator
LXModulator.Device, LXModulator.Global, LXModulator.Placeholder, LXModulator.ResetButton, LXModulator.TriggerButtonNested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Author, LXComponent.Description, LXComponent.Hidden, LXComponent.Name, LXComponent.PluginRequired, LXComponent.Renamable, LXComponent.TagsNested classes/interfaces inherited from interface heronarts.lx.parameter.LXNormalizedParameter
LXNormalizedParameter.OscModeNested classes/interfaces inherited from interface heronarts.lx.parameter.LXParameter
LXParameter.Collection, LXParameter.Formatter, LXParameter.Monitor, LXParameter.MultiMonitor, LXParameter.Polarity, LXParameter.UnitsNested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CompoundParameterMeter attack time, in millisecondsprotected doubleprotected LXAudioBufferfinal CompoundParameterGain of the meter, in decibelsprotected static final doublefinal CompoundParameterRange of the meter, in decibels.protected static final doublefinal CompoundParameterMeter release time, in millisecondsprotected doubleFields inherited from class heronarts.lx.modulator.LXModulator
crashed, midiFilter, midiSourceFields inherited from class heronarts.lx.LXRunnableComponent
reset, runMs, running, triggerFields inherited from class heronarts.lx.LXComponent
childArrays, children, internalParameters, KEY_CHILDREN, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_INTERNAL, KEY_PARAMETER_PATH, KEY_PARAMETERS, KEY_PATH, KEY_RESET, label, legacyInternalParameters, legacyParameters, lx, modulationColor, modulationControlsExpanded, modulationsExpanded, parameters, presetFileFields inherited from interface heronarts.lx.LXPath
DEFAULT_SEPARATOR, ROOT, ROOT_PREFIX, ROOT_SLASH -
Constructor Summary
ConstructorsConstructorDescriptionDecibelMeter(LXAudioBuffer buffer) Default constructor, creates a meter with unity gain and 72dB dynamic rangeDecibelMeter(String label, LXAudioBuffer buffer) Default constructor, creates a meter with unity gain and 72dB dynamic rangeDecibelMeter(String label, LXAudioBuffer buffer, heronarts.lx.audio.DecibelMeter.Parameters params) DecibelMeter(String label, LXAudioBuffer buffer, CompoundParameter gain, CompoundParameter range, CompoundParameter attack, CompoundParameter release) -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleamplitudeToDecibels(double amplitude) Converts an amplitude (normalized 0-1, typically RMS) to decibels, negative value up to 0dbFSprotected doublecomputeValue(double deltaMs) Implementation method to advance the modulator's internal state.intdoublefloatdoubleGets the exponent used for scaling this parameter across its normalized range.doubleGets the value of the parameter in a normalized space from 0 to 1floatGets the value of the parameter in a normalized space as a floatdoublegetPeak()floatgetPeakf()floatgetRaw()Return raw underlying levels, no attack/gain smoothingintdoublefloatprotected voidCompute new values when a frame of audio input is received.protected voidonStop()Optional subclass method when stop happens.final DecibelMetersetBuffer(LXAudioBuffer buffer) setNormalized(double value) Sets the value or the parameter in normalized space from 0 to 1Methods inherited from class heronarts.lx.modulator.LXModulator
autostart, disableAutoStart, getCrash, getCrashStackTrace, getFormatter, getIndex, getOscAddress, getOscPath, getPath, getPolarity, getUnits, getValue, isMappingSource, loop, onSetValue, run, setComponent, setFormatter, setIndex, setMappingSource, setPolarity, setUnits, setValue, setValue, updateValueMethods inherited from class heronarts.lx.LXRunnableComponent
isRunning, onParameterChanged, onReset, onStart, onTrigger, postRun, reset, start, stop, toggle, triggerMethods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addInternalParameters, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, assertDisposed, contains, copyParameters, dispose, getCategory, getChild, getComponentDescription, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscLabel, getParameter, getParameters, getParent, handleOscMessage, hasParameter, isSnapshotControl, isValidOscParameter, load, loadParameters, loadPreset, removeParameter, removeParameter, removeParameter, removeParameter, save, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface heronarts.lx.parameter.LXNormalizedParameter
getBaseNormalized, getBaseNormalizedf, getOscMode, getValueFromNormalized, isWrappableMethods inherited from interface heronarts.lx.osc.LXOscComponent
getOscAddress, handleOscMessageMethods inherited from interface heronarts.lx.parameter.LXParameter
dispose, getBaseValue, getBaseValuef, getFormatter, getLabel, getParentParameter, getPolarity, getUnits, getValue, getValuef, isMappable, reset, setComponent, setFormatter, setMappable, setValueMethods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, getDescription, getParent, getPath, isDescendant
-
Field Details
-
LOG_10
protected static final double LOG_10 -
RATIO_20_LOG10
protected static final double RATIO_20_LOG10 -
buffer
-
gain
Gain of the meter, in decibels -
range
Range of the meter, in decibels. -
attack
Meter attack time, in milliseconds -
release
Meter release time, in milliseconds -
attackGain
protected double attackGain -
releaseGain
protected double releaseGain
-
-
Constructor Details
-
DecibelMeter
Default constructor, creates a meter with unity gain and 72dB dynamic range- Parameters:
buffer- Audio buffer to meter
-
DecibelMeter
Default constructor, creates a meter with unity gain and 72dB dynamic range- Parameters:
label- Labelbuffer- Audio buffer to meter
-
DecibelMeter
public DecibelMeter(String label, LXAudioBuffer buffer, heronarts.lx.audio.DecibelMeter.Parameters params) -
DecibelMeter
public DecibelMeter(String label, LXAudioBuffer buffer, CompoundParameter gain, CompoundParameter range, CompoundParameter attack, CompoundParameter release)
-
-
Method Details
-
setBuffer
-
getBufferSize
public int getBufferSize() -
getSampleRate
public int getSampleRate() -
getExponent
public double getExponent()Description copied from interface:LXNormalizedParameterGets the exponent used for scaling this parameter across its normalized range. Default is 1 which means linear scaling.- Specified by:
getExponentin interfaceLXNormalizedParameter- Returns:
- scaling exponent
-
amplitudeToDecibels
public static double amplitudeToDecibels(double amplitude) Converts an amplitude (normalized 0-1, typically RMS) to decibels, negative value up to 0dbFS- Parameters:
amplitude- Normalized amplitude, 0-1- Returns:
- Decibel value, negative infinity -> max 0dBFS
-
getRaw
public float getRaw()Return raw underlying levels, no attack/gain smoothing- Returns:
- Raw RMS value
-
getDecibels
public double getDecibels()- Returns:
- Raw decibel value of the meter
-
getDecibelsf
public float getDecibelsf()- Returns:
- Raw decibel value of the meter as a float
-
getSquare
public double getSquare()- Returns:
- A value for the audio meter from 0 to 1 with quadratic scaling
-
getSquaref
public float getSquaref()- Returns:
- Quadratic scaled value as a float
-
onAudioFrame
protected void onAudioFrame()Compute new values when a frame of audio input is received. This is called by the thread that has filled the audio buffer. -
computeValue
protected double computeValue(double deltaMs) Description copied from class:LXModulatorImplementation method to advance the modulator's internal state. Subclasses must provide and update value appropriately.- Specified by:
computeValuein classLXModulator- Parameters:
deltaMs- Number of milliseconds to advance by- Returns:
- Computed value
-
onStop
protected void onStop()Description copied from class:LXRunnableComponentOptional subclass method when stop happens.- Overrides:
onStopin classLXRunnableComponent
-
setNormalized
Description copied from interface:LXNormalizedParameterSets the value or the parameter in normalized space from 0 to 1- Specified by:
setNormalizedin interfaceLXNormalizedParameter- Parameters:
value- The normalized value, from 0 to 1- Returns:
- this, for method chaining
-
getPeak
public double getPeak() -
getPeakf
public float getPeakf() -
getNormalized
public double getNormalized()Description copied from interface:LXNormalizedParameterGets the value of the parameter in a normalized space from 0 to 1- Specified by:
getNormalizedin interfaceLXNormalizedParameter- Returns:
- Value of parameter, normalized to range from 0 to 1
-
getNormalizedf
public float getNormalizedf()Description copied from interface:LXNormalizedParameterGets the value of the parameter in a normalized space as a float- Specified by:
getNormalizedfin interfaceLXNormalizedParameter- Returns:
- Normalized value of parameter, in range from 0 to 1
-