EnergyDetection: Energy Detection
Integration Guide
EnergyDetection must be explicitly enabled during engine initialization by:
- Initializing a PryonLiteEnergyDetectionConfig struct to the appropriate values. Set enableGate to 1.
- Initializing a PryonLiteVadConfig struct. Set the energyDetection pointer in the PryonLiteVadConfig to point to the first step's PryonLiteEnergyDetectionConfig struct.
- Setting vad in PryonLiteV2Config to the above PryonLiteVadConfig.
- (optional) Enabling the PryonLiteVadEvent, if a notification when the EnergyDetection state changes is desired.
See the api sample included in your release for a full example.
// Optionally define a VAD event callback
// if enabled, the callback will be called when the EnergyDetection state changes
// Client will have until next frame to potentially scale CPU frequency
static void vadEventHandler(PryonLiteV2Handle *handle, const PryonLiteVadEvent* vadEvent)
{
printf("VAD state %d\n", (int) vadEvent->vadState);
// perform a change in CPU clock speed if necessary
}
// Event handler
// Must be passed to PryonLite_Initialize
static void handleEvent(PryonLiteV2Handle *handle, const PryonLiteV2Event* event)
{
if (event->vadEvent != NULL)
{
vadEventHandler(handle, event->vadEvent);
}
// ... handle other events here
}
void init()
{
PryonLiteV2EventConfig engineEventConfig = {0};
PryonLiteV2Config engineConfig = {0};
// Initialize the VAD Configuration to use energy detection.
PryonLiteVadConfig vadConfig = PryonLiteVadConfig_Default;
PryonLiteEnergyDetectionConfig energyDetection = PryonLiteEnergyDetectionConfig_Default;
energyDetection.enableGate = 1; ///< When used inline with any other functionality, true to prevent continued processing of non voice frames
vadConfig.energyDetection = &energyDetection;
engineConfig.vad = &vadConfig;
// Optionally enable the VAD event to receive EnergyDetection state changes notifications
engineEventConfig.enableVadEvent = true;
// ... rest of init code
}