# Detecting energy

The ADI service is capable of running an energy detector that examines the in-band signal and reports energy and silence transitions.

Note: Do not use the energy detector if you are using voice activity detection.

This topic presents:

- Starting energy detection

- Stopping energy detection

## Starting energy detection

adiStartEnergyDetector takes the following qualification time parameters:

Parameter | Description
--- | ---
energyqual | Energy qualification time; the time, in milliseconds, that energy must be present to report an energy event.
silencequal | Silence qualification time; the time, in milliseconds, that energy must be absent to report a silence event.

You can modify the energy detector's default behavior by specifying the following parameters (stored in ADI_ENERGY_PARMS) when invoking adiStartEnergyDetector:

Parameter | Description
--- | ---
thresholdampl | Threshold amplitude; the noise level, in dBm, below which is considered silence. Noise above this level is further qualified as energy.
deglitch | Deglitch time; the minimum time, in milliseconds, before a transition between energy and silence is recognized.
autostop | Automatic stop; controls whether the energy detector continues running after the first event. By default, automatic stop is enabled.

The following illustration shows the energy detection parameters:

The energy detector generates the following events:

- ADIEVN_SILENCE_DETECTED

- ADIEVN_ENERGY_DETECTED

- ADIEVN_ENERGY_DETECT_DONE

## Stopping energy detection

adiStopEnergyDetector immediately terminates energy and silence detection. The ADI service generates ADIEVN_ENERGYDETECT_DONE with the value set to CTA_REASON_STOPPED, which means that the operation was stopped by application request.

The ADI service also generates ADIEVN_ENERGYDETECT_DONE, and ADIERR_xxx, CTAERR_xxx, or CTA_REASON_FINISHED. When set to autostop (one-shot), the value is set to CTA_REASON_FINISHED and the size field contains either ADIEVN_ENERGY_DETECTED or ADIEVN_SILENCE_DETECTED.