Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Scenery.AudioAnalyzer Class Reference

Audio analyzer resource. More...

Inheritance diagram for Dragengine.Scenery.AudioAnalyzer:

Public Member Functions

Constructors
AudioAnalyzer new ()
 Create audio analyzer.
Management
bool getUseAudioCapture ()
 Use audio capture as input for analysis.
void setUseAudioCapture (bool useAudioCapture)
 Set use of audio capture as input for analysis.
int getSampleRate ()
 Analysis sample rate in Hz.
void setSampleRate (int sampleRate)
 Set analysis sample rate in Hz.
int getResolution ()
 FFT resolution (window size in samples).
void setResolution (int resolution)
 Set FFT resolution.
int getFrequencyBandCount ()
 Count of frequency bands tracked.
void setFrequencyBandCount (int count)
 Set count of frequency bands tracked.
float getLowestFrequency ()
 Lowest frequency for frequency bands in Hz.
float getHighestFrequency ()
 Highest frequency for frequency bands in Hz.
void setFrequencyRange (float lowestFrequency, float highestFrequency)
 Set frequency range for frequency bands in Hz.
bool getEnablePreEmphasis ()
 Apply pre-emphasis filter before FFT.
void setEnablePreEmphasis (bool enable)
 Set apply pre-emphasis filter before FFT.
float getPreEmphasisFactor ()
 Pre-emphasis filter coefficient.
void setPreEmphasisFactor (float factor)
 Set pre-emphasis filter coefficient.
bool getEnableMelFiltering ()
 Apply mel filter banks after FFT.
void setEnableMelFiltering (bool enable)
 Set apply mel filter banks after FFT.
int getMelFilterCount ()
 Count of mel filter banks.
void setMelFilterCount (int count)
 Set count of mel filter bank filters.
bool getNormalizeMelEnergies ()
 Normalize mel filter bank energies.
void setNormalizeMelEnergies (bool normalize)
 Set normalize mel filter bank energies.
void updateResults ()
 Update results.
Time-Domain Results
float getRMS ()
 Root mean square amplitude in range 0 to 1.
float getPeak ()
 Absolute peak amplitude in range 0 to 1.
float getZeroCrossingRate ()
 Zero-crossing rate in range 0 to 1.
Frequency-Domain Results
float getSpectralCentroid ()
 Spectral centroid (center of mass of spectrum) in Hz.
float getSpectralFlatness ()
 Spectral flatness in range 0 (tonal) to 1 (noise-like).
float getSpectralFlux ()
 Spectral flux measuring rate of spectrum change.
float getSpectralRolloff ()
 Spectral roll-off frequency in Hz.
int getSpectralPeakCount ()
 Count of spectral peak frequencies.
float getSpectralPeakFrequencyAt (int index)
 Spectral peak frequency in Hz at index.
float getSpectralPeakMagnitudeAt (int index)
 Spectral peak magnitude at index.
float getFrequencyBandMagnitudeAt (int index)
 Magnitude of frequency band at index.
float getFrequencyBandEnergyAt (int index)
 Energy of frequency band at index.
float getFrequencyBandLowestFrequencyAt (int index)
 Lowest frequency of frequency band at index in Hz.
float getFrequencyBandHighestFrequencyAt (int index)
 Highest frequency of frequency band at index in Hz.
float getFrequencyBandMfccAt (int index)
 Mel Frequency Cepstral Coefficient of the frequency band at index.
float getMaxBandMagnitude ()
 Maximum magnitude of all frequency bands.
float getMaxBandEnergy ()
 Maximum energy of all frequency bands.
float getTotalBandMagnitude ()
 Total magnitude of all frequency bands.
float getTotalBandEnergy ()
 Total energy of all frequency bands.
float getPitch ()
 Estimated pitch (fundamental frequency) in Hz or 0 if not detected.
Operators
bool equals (Object obj)
 Audio analyzers are equal.
int hashCode ()
 Hash code.

Detailed Description

Audio analyzer resource.

Version
1.32

Analyzes audio data providing time-domain and frequency-domain results. To use create an AudioAnalyzer instance and configure the analysis parameters. Audio analysis is performed by the synthesizer module asynchronously. Call updateResults() periodically (for example each frame update or using a timer) to retrieve the accumulated analysis results.

Time-domain results include the root mean square amplitude (RMS), absolute peak amplitude and the zero-crossing rate. Frequency-domain results include the spectral centroid, spectral flatness, spectral flux, spectral roll-off frequency, individual spectral peaks and frequency band energy levels as well as the estimated fundamental pitch.

This is a native class.

Member Function Documentation

◆ equals()

bool Dragengine.Scenery.AudioAnalyzer.equals ( Object obj)

Audio analyzers are equal.

Referenced by hashCode().

◆ getEnableMelFiltering()

bool Dragengine.Scenery.AudioAnalyzer.getEnableMelFiltering ( )

Apply mel filter banks after FFT.

If enabled changes frequency bands from logarithmically spaced to mel-scale spaced triangular filters. This produces a perceptually-motivated band distribution closer to how humans perceive pitch and timbre.

Default is false.

References getPreEmphasisFactor().

Referenced by setMelFilterCount().

◆ getEnablePreEmphasis()

bool Dragengine.Scenery.AudioAnalyzer.getEnablePreEmphasis ( )

Apply pre-emphasis filter before FFT.

If enabled pre-emphasis filter is applied to the input samples before the FFT calculation. This boosts high frequencies to improve analysis quality.

Default is true.

References getHighestFrequency(), and setFrequencyRange().

Referenced by getPreEmphasisFactor().

◆ getFrequencyBandCount()

int Dragengine.Scenery.AudioAnalyzer.getFrequencyBandCount ( )

Count of frequency bands tracked.

Referenced by setFrequencyBandCount().

◆ getFrequencyBandEnergyAt()

float Dragengine.Scenery.AudioAnalyzer.getFrequencyBandEnergyAt ( int index)

Energy of frequency band at index.

Bands are logarithmically spaced within the frequency range set by setFrequencyRange(float,float).

Exceptions
EInvalidParamindex is less than 0
EInvalidParamindex is greater than or equal to getFrequencyBandsCount().

References getSpectralPeakCount(), and getSpectralRolloff().

Referenced by getPitch().

◆ getFrequencyBandHighestFrequencyAt()

float Dragengine.Scenery.AudioAnalyzer.getFrequencyBandHighestFrequencyAt ( int index)

Highest frequency of frequency band at index in Hz.

Bands are logarithmically spaced within the frequency range set by setFrequencyRange(float,float).

Exceptions
EInvalidParamindex is less than 0
EInvalidParamindex is greater than or equal to getFrequencyBandsCount().

References getSpectralPeakMagnitudeAt().

Referenced by hashCode().

◆ getFrequencyBandLowestFrequencyAt()

float Dragengine.Scenery.AudioAnalyzer.getFrequencyBandLowestFrequencyAt ( int index)

Lowest frequency of frequency band at index in Hz.

Bands are logarithmically spaced within the frequency range set by setFrequencyRange(float,float).

Exceptions
EInvalidParamindex is less than 0
EInvalidParamindex is greater than or equal to getFrequencyBandsCount().

References getSpectralPeakFrequencyAt().

Referenced by hashCode().

◆ getFrequencyBandMagnitudeAt()

float Dragengine.Scenery.AudioAnalyzer.getFrequencyBandMagnitudeAt ( int index)

Magnitude of frequency band at index.

Bands are logarithmically spaced within the frequency range set by setFrequencyRange(float,float).

Exceptions
EInvalidParamindex is less than 0
EInvalidParamindex is greater than or equal to getFrequencyBandsCount().

References getSpectralFlatness(), and getSpectralFlux().

Referenced by getMaxBandEnergy().

◆ getFrequencyBandMfccAt()

float Dragengine.Scenery.AudioAnalyzer.getFrequencyBandMfccAt ( int index)

Mel Frequency Cepstral Coefficient of the frequency band at index.

Returns the DCT coefficient of the log mel energies corresponding to this band. Only valid if mel filtering is enabled otherwise 0.

Exceptions
EInvalidParamindex is less than 0
EInvalidParamindex is greater than or equal to getFrequencyBandsCount().

Referenced by hashCode().

◆ getHighestFrequency()

float Dragengine.Scenery.AudioAnalyzer.getHighestFrequency ( )

Highest frequency for frequency bands in Hz.

Default is 20000 Hz.

Referenced by getEnablePreEmphasis().

◆ getLowestFrequency()

float Dragengine.Scenery.AudioAnalyzer.getLowestFrequency ( )

Lowest frequency for frequency bands in Hz.

Default is 20 Hz.

References setFrequencyBandCount().

Referenced by setFrequencyRange().

◆ getMaxBandEnergy()

float Dragengine.Scenery.AudioAnalyzer.getMaxBandEnergy ( )

Maximum energy of all frequency bands.

References getFrequencyBandMagnitudeAt().

Referenced by hashCode().

◆ getMaxBandMagnitude()

float Dragengine.Scenery.AudioAnalyzer.getMaxBandMagnitude ( )

Maximum magnitude of all frequency bands.

Referenced by hashCode().

◆ getMelFilterCount()

int Dragengine.Scenery.AudioAnalyzer.getMelFilterCount ( )

Count of mel filter banks.

Default is 26.

Referenced by setNormalizeMelEnergies().

◆ getNormalizeMelEnergies()

bool Dragengine.Scenery.AudioAnalyzer.getNormalizeMelEnergies ( )

Normalize mel filter bank energies.

Default is true.

Referenced by getZeroCrossingRate().

◆ getPeak()

float Dragengine.Scenery.AudioAnalyzer.getPeak ( )

Absolute peak amplitude in range 0 to 1.

Referenced by getSpectralPeakFrequencyAt().

◆ getPitch()

float Dragengine.Scenery.AudioAnalyzer.getPitch ( )

Estimated pitch (fundamental frequency) in Hz or 0 if not detected.

References getFrequencyBandEnergyAt().

Referenced by hashCode().

◆ getPreEmphasisFactor()

float Dragengine.Scenery.AudioAnalyzer.getPreEmphasisFactor ( )

Pre-emphasis filter coefficient.

Default is 0.97.

References getEnablePreEmphasis().

Referenced by getEnableMelFiltering().

◆ getResolution()

int Dragengine.Scenery.AudioAnalyzer.getResolution ( )

FFT resolution (window size in samples).

Higher values give better frequency resolution at the cost of more processing time and higher latency.

Default is 1024.

Referenced by setResolution().

◆ getRMS()

float Dragengine.Scenery.AudioAnalyzer.getRMS ( )

Root mean square amplitude in range 0 to 1.

References setMelFilterCount().

Referenced by getSpectralPeakFrequencyAt().

◆ getSampleRate()

int Dragengine.Scenery.AudioAnalyzer.getSampleRate ( )

Analysis sample rate in Hz.

Downsamples input from input sample rate to analysis sample rate. Default is 16000.

References getSampleRate().

Referenced by getSampleRate().

◆ getSpectralCentroid()

float Dragengine.Scenery.AudioAnalyzer.getSpectralCentroid ( )

Spectral centroid (center of mass of spectrum) in Hz.

References setNormalizeMelEnergies().

Referenced by getSpectralPeakMagnitudeAt().

◆ getSpectralFlatness()

float Dragengine.Scenery.AudioAnalyzer.getSpectralFlatness ( )

Spectral flatness in range 0 (tonal) to 1 (noise-like).

Referenced by getFrequencyBandMagnitudeAt().

◆ getSpectralFlux()

float Dragengine.Scenery.AudioAnalyzer.getSpectralFlux ( )

Spectral flux measuring rate of spectrum change.

Referenced by getFrequencyBandMagnitudeAt().

◆ getSpectralPeakCount()

int Dragengine.Scenery.AudioAnalyzer.getSpectralPeakCount ( )

Count of spectral peak frequencies.

References updateResults().

Referenced by getFrequencyBandEnergyAt().

◆ getSpectralPeakFrequencyAt()

float Dragengine.Scenery.AudioAnalyzer.getSpectralPeakFrequencyAt ( int index)

Spectral peak frequency in Hz at index.

Exceptions
EInvalidParamindex is less than 0
EInvalidParamindex is greater than or equal to getSpectralPeaksCount().

Spectral peaks are sorted from strongest to weakest.

References getPeak(), and getRMS().

Referenced by getFrequencyBandLowestFrequencyAt().

◆ getSpectralPeakMagnitudeAt()

float Dragengine.Scenery.AudioAnalyzer.getSpectralPeakMagnitudeAt ( int index)

Spectral peak magnitude at index.

Exceptions
EInvalidParamindex is less than 0
EInvalidParamindex is greater than or equal to getSpectralPeaksCount().

Spectral peaks are sorted from strongest to weakest.

References getSpectralCentroid(), and getZeroCrossingRate().

Referenced by getFrequencyBandHighestFrequencyAt().

◆ getSpectralRolloff()

float Dragengine.Scenery.AudioAnalyzer.getSpectralRolloff ( )

Spectral roll-off frequency in Hz.

Referenced by getFrequencyBandEnergyAt().

◆ getTotalBandEnergy()

float Dragengine.Scenery.AudioAnalyzer.getTotalBandEnergy ( )

Total energy of all frequency bands.

Referenced by hashCode().

◆ getTotalBandMagnitude()

float Dragengine.Scenery.AudioAnalyzer.getTotalBandMagnitude ( )

Total magnitude of all frequency bands.

Referenced by hashCode().

◆ getUseAudioCapture()

bool Dragengine.Scenery.AudioAnalyzer.getUseAudioCapture ( )

Use audio capture as input for analysis.

Default is true. Has no effect unless AudioSystem.startAudioCapture() is called.

References getUseAudioCapture().

Referenced by getUseAudioCapture().

◆ getZeroCrossingRate()

float Dragengine.Scenery.AudioAnalyzer.getZeroCrossingRate ( )

Zero-crossing rate in range 0 to 1.

References getNormalizeMelEnergies().

Referenced by getSpectralPeakMagnitudeAt().

◆ hashCode()

◆ new()

AudioAnalyzer Dragengine.Scenery.AudioAnalyzer.new ( )

Create audio analyzer.

References new().

Referenced by new().

◆ setEnableMelFiltering()

void Dragengine.Scenery.AudioAnalyzer.setEnableMelFiltering ( bool enable)

Set apply mel filter banks after FFT.

If enabled changes frequency bands from logarithmically spaced to mel-scale spaced triangular filters. This produces a perceptually-motivated band distribution closer to how humans perceive pitch and timbre.

References setPreEmphasisFactor().

Referenced by setNormalizeMelEnergies().

◆ setEnablePreEmphasis()

void Dragengine.Scenery.AudioAnalyzer.setEnablePreEmphasis ( bool enable)

Set apply pre-emphasis filter before FFT.

If enabled pre-emphasis filter is applied to the input samples before the FFT calculation. This boosts high frequencies to improve analysis quality.

Referenced by setPreEmphasisFactor().

◆ setFrequencyBandCount()

void Dragengine.Scenery.AudioAnalyzer.setFrequencyBandCount ( int count)

Set count of frequency bands tracked.

Exceptions
EInvalidParamcount is less than 1.

References getFrequencyBandCount(), and setResolution().

Referenced by getLowestFrequency().

◆ setFrequencyRange()

void Dragengine.Scenery.AudioAnalyzer.setFrequencyRange ( float lowestFrequency,
float highestFrequency )

Set frequency range for frequency bands in Hz.

References getLowestFrequency().

Referenced by getEnablePreEmphasis().

◆ setMelFilterCount()

void Dragengine.Scenery.AudioAnalyzer.setMelFilterCount ( int count)

Set count of mel filter bank filters.

Exceptions
EInvalidParamcount is less than 1.

References getEnableMelFiltering().

Referenced by getRMS().

◆ setNormalizeMelEnergies()

void Dragengine.Scenery.AudioAnalyzer.setNormalizeMelEnergies ( bool normalize)

Set normalize mel filter bank energies.

References getMelFilterCount(), and setEnableMelFiltering().

Referenced by getSpectralCentroid().

◆ setPreEmphasisFactor()

void Dragengine.Scenery.AudioAnalyzer.setPreEmphasisFactor ( float factor)

Set pre-emphasis filter coefficient.

Factor is clamped to the range from 0 to 1.

References setEnablePreEmphasis().

Referenced by setEnableMelFiltering().

◆ setResolution()

void Dragengine.Scenery.AudioAnalyzer.setResolution ( int resolution)

Set FFT resolution.

Exceptions
EInvalidParamresolution is less than 64.

References getResolution().

Referenced by setFrequencyBandCount().

◆ setSampleRate()

void Dragengine.Scenery.AudioAnalyzer.setSampleRate ( int sampleRate)

Set analysis sample rate in Hz.

Exceptions
EInvalidParamsampleRate is less than 1.

Downsamples input from input sample rate to analysis sample rate.

References setSampleRate().

Referenced by setSampleRate().

◆ setUseAudioCapture()

void Dragengine.Scenery.AudioAnalyzer.setUseAudioCapture ( bool useAudioCapture)

Set use of audio capture as input for analysis.

References setUseAudioCapture().

Referenced by setUseAudioCapture().

◆ updateResults()

void Dragengine.Scenery.AudioAnalyzer.updateResults ( )

Update results.

Fetch asynchronously accumulated analysis results from synthesizer module. The results stay valid until the next call to updateResults(). The time interval betwen calling updateResults() affects the granularity of the results.

Referenced by getSpectralPeakCount().


The documentation for this class was generated from the following file: