Table of Contents

Method CalculateRms

Namespace
LMKit.Media.Audio
Assembly
LM-Kit.NET.dll

CalculateRms(CancellationToken)

Calculates the Root Mean Square (RMS) energy of the entire audio.

public float CalculateRms(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Token to cancel the operation.

Returns

float

The RMS value. Returns 0 if no samples are available.

Remarks

RMS (Root Mean Square) is a statistical measure of the magnitude of a varying quantity. For audio signals, RMS represents the average power or perceived loudness of the signal. It is calculated as the square root of the mean of the squared sample values.

RMS values typically range from 0 (silence) to 1 (maximum amplitude for normalized audio). Common reference points:

  • 0.0: Complete silence
  • 0.01-0.02: Very quiet audio, near silence
  • 0.1-0.3: Normal speech levels
  • 0.5-0.7: Loud audio
  • 1.0: Maximum amplitude (clipping threshold)

CalculateRms(TimeSpan, TimeSpan, CancellationToken)

Calculates the Root Mean Square (RMS) energy for a specific time range.

public float CalculateRms(TimeSpan start, TimeSpan end, CancellationToken cancellationToken = default)

Parameters

start TimeSpan

Start time of the segment.

end TimeSpan

End time of the segment.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

float

The RMS value for the specified range. Returns 0 if the range is invalid or empty.

Remarks

RMS (Root Mean Square) is a statistical measure of the magnitude of a varying quantity. For audio signals, RMS represents the average power or perceived loudness of the signal. It is calculated as the square root of the mean of the squared sample values.

CalculateRms(int, int, CancellationToken)

Calculates the Root Mean Square (RMS) energy for a specific sample range.

public float CalculateRms(int startSample, int endSample, CancellationToken cancellationToken = default)

Parameters

startSample int

Start sample index (0-based).

endSample int

End sample index (exclusive).

cancellationToken CancellationToken

Token to cancel the operation.

Returns

float

The RMS value for the specified range. Returns 0 if the range is invalid or empty.

Remarks

RMS (Root Mean Square) is a statistical measure of the magnitude of a varying quantity. For audio signals, RMS represents the average power or perceived loudness of the signal. It is calculated as the square root of the mean of the squared sample values.