Drag[en]gine Script Module DragonScript 1.32.1
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.

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

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

◆ getFrequencyBandCount()

int Dragengine.Scenery.AudioAnalyzer.getFrequencyBandCount ( )

Count of frequency bands tracked.

◆ 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().

◆ 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().

◆ 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().

◆ 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().

◆ 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().

◆ getHighestFrequency()

float Dragengine.Scenery.AudioAnalyzer.getHighestFrequency ( )

Highest frequency for frequency bands in Hz.

Default is 20000 Hz.

◆ getLowestFrequency()

float Dragengine.Scenery.AudioAnalyzer.getLowestFrequency ( )

Lowest frequency for frequency bands in Hz.

Default is 20 Hz.

◆ getMaxBandEnergy()

float Dragengine.Scenery.AudioAnalyzer.getMaxBandEnergy ( )

Maximum energy of all frequency bands.

◆ getMaxBandMagnitude()

float Dragengine.Scenery.AudioAnalyzer.getMaxBandMagnitude ( )

Maximum magnitude of all frequency bands.

◆ getMelFilterCount()

int Dragengine.Scenery.AudioAnalyzer.getMelFilterCount ( )

Count of mel filter banks.

Default is 26.

◆ getNormalizeMelEnergies()

bool Dragengine.Scenery.AudioAnalyzer.getNormalizeMelEnergies ( )

Normalize mel filter bank energies.

Default is true.

◆ getPeak()

float Dragengine.Scenery.AudioAnalyzer.getPeak ( )

Absolute peak amplitude in range 0 to 1.

◆ getPitch()

float Dragengine.Scenery.AudioAnalyzer.getPitch ( )

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

◆ getPreEmphasisFactor()

float Dragengine.Scenery.AudioAnalyzer.getPreEmphasisFactor ( )

Pre-emphasis filter coefficient.

Default is 0.97.

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

◆ getRMS()

float Dragengine.Scenery.AudioAnalyzer.getRMS ( )

Root mean square amplitude in range 0 to 1.

◆ getSampleRate()

int Dragengine.Scenery.AudioAnalyzer.getSampleRate ( )

Analysis sample rate in Hz.

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

◆ getSpectralCentroid()

float Dragengine.Scenery.AudioAnalyzer.getSpectralCentroid ( )

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

◆ getSpectralFlatness()

float Dragengine.Scenery.AudioAnalyzer.getSpectralFlatness ( )

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

◆ getSpectralFlux()

float Dragengine.Scenery.AudioAnalyzer.getSpectralFlux ( )

Spectral flux measuring rate of spectrum change.

◆ getSpectralPeakCount()

int Dragengine.Scenery.AudioAnalyzer.getSpectralPeakCount ( )

Count of spectral peak frequencies.

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

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

◆ getSpectralRolloff()

float Dragengine.Scenery.AudioAnalyzer.getSpectralRolloff ( )

Spectral roll-off frequency in Hz.

◆ getTotalBandEnergy()

float Dragengine.Scenery.AudioAnalyzer.getTotalBandEnergy ( )

Total energy of all frequency bands.

◆ getTotalBandMagnitude()

float Dragengine.Scenery.AudioAnalyzer.getTotalBandMagnitude ( )

Total magnitude of all frequency bands.

◆ getUseAudioCapture()

bool Dragengine.Scenery.AudioAnalyzer.getUseAudioCapture ( )

Use audio capture as input for analysis.

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

◆ getZeroCrossingRate()

float Dragengine.Scenery.AudioAnalyzer.getZeroCrossingRate ( )

Zero-crossing rate in range 0 to 1.

◆ hashCode()

int Dragengine.Scenery.AudioAnalyzer.hashCode ( )

Hash code.

◆ new()

AudioAnalyzer Dragengine.Scenery.AudioAnalyzer.new ( )

Create audio analyzer.

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

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

◆ setFrequencyBandCount()

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

Set count of frequency bands tracked.

Exceptions
EInvalidParamcount is less than 1.

◆ setFrequencyRange()

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

Set frequency range for frequency bands in Hz.

◆ setMelFilterCount()

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

Set count of mel filter bank filters.

Exceptions
EInvalidParamcount is less than 1.

◆ setNormalizeMelEnergies()

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

Set normalize mel filter bank energies.

◆ setPreEmphasisFactor()

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

Set pre-emphasis filter coefficient.

Factor is clamped to the range from 0 to 1.

◆ setResolution()

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

Set FFT resolution.

Exceptions
EInvalidParamresolution is less than 64.

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

◆ setUseAudioCapture()

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

Set use of audio capture as input for analysis.

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


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