Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
ear_inference.h File Reference

Bounded PCM classification without allowing model latency to stall ALSA capture. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for ear_inference.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ear_inference_result
 One classified audio window; probability and measured level are different evidence. More...

Functions

bool ear_inference_configure (const char *settings, unsigned rate, bool *enabled, char *error, size_t capacity)
 Select the explicit detector and qualify an ONNX PCM contract before capture starts.
bool ear_inference_start (char *error, size_t capacity)
 Start the sole classifier thread after successful ONNX configuration.
void ear_inference_push (const int16_t *samples, size_t count, uint64_t end_us, uint64_t error_us)
 Supply capture samples without waiting for model execution or a busy model mailbox.
bool ear_inference_take (struct ear_inference_result *result)
 Consume at most one completed original-window result without blocking capture.
void ear_inference_discontinuity (void)
 Invalidate queued/completed evidence after capture continuity breaks, including in-flight generations.
void ear_inference_stop (void)
 Request termination, join the classifier and release its model; repeat calls are harmless.
int ear_inference_file (const char *filename)
 Classify exact whole windows from a regular little-endian signed-16 mono PCM file.

Detailed Description

Bounded PCM classification without allowing model latency to stall ALSA capture.

Definition in file ear_inference.h.

Function Documentation

◆ ear_inference_configure()

bool ear_inference_configure ( const char * settings,
unsigned rate,
bool * enabled,
char * error,
size_t capacity )

Select the explicit detector and qualify an ONNX PCM contract before capture starts.

Parameters
settingsEARcam application settings path.
rateExact capture sample rate; no implicit resampling is performed.
enabledSet true for ONNX, false for a successfully selected native detector.
errorWritable failure diagnostic.
capacityAvailable bytes in error.
Returns
True for an accepted native or ONNX selection; false never means native fallback.
Precondition
No inference thread or previously configured model is active.

Definition at line 69 of file ear_inference.c.

◆ ear_inference_discontinuity()

void ear_inference_discontinuity ( void )

Invalidate queued/completed evidence after capture continuity breaks, including in-flight generations.

Definition at line 209 of file ear_inference.c.

◆ ear_inference_file()

int ear_inference_file ( const char * filename)

Classify exact whole windows from a regular little-endian signed-16 mono PCM file.

Parameters
filenameImmutable replay input; no hardware or simulated exposure timing is invented.
Returns
Zero after complete replay, otherwise one for invalid input or model failure.
Precondition
The model is configured but its capture worker is not running.

Definition at line 233 of file ear_inference.c.

◆ ear_inference_push()

void ear_inference_push ( const int16_t * samples,
size_t count,
uint64_t end_us,
uint64_t error_us )

Supply capture samples without waiting for model execution or a busy model mailbox.

Parameters
samplesBorrowed signed mono PCM; no pointer survives this call.
countNumber of samples in this continuous capture chunk.
end_usCapture end of the chunk in CLOCK_MONOTONIC microseconds, or zero when unknown.
error_usBound on capture-window timing uncertainty, not inference duration.

Complete windows may replace pending work; overload loses evidence rather than blocking ALSA.

Precondition
One capture producer owns push/discontinuity calls until stop begins.

Definition at line 166 of file ear_inference.c.

◆ ear_inference_start()

bool ear_inference_start ( char * error,
size_t capacity )

Start the sole classifier thread after successful ONNX configuration.

Parameters
errorWritable failure diagnostic.
capacityAvailable bytes in error.
Returns
True after thread creation, not proof of a classified acoustic event.

Definition at line 155 of file ear_inference.c.

◆ ear_inference_stop()

void ear_inference_stop ( void )

Request termination, join the classifier and release its model; repeat calls are harmless.

Precondition
The capture producer has stopped supplying new chunks.

Definition at line 219 of file ear_inference.c.

◆ ear_inference_take()

bool ear_inference_take ( struct ear_inference_result * result)

Consume at most one completed original-window result without blocking capture.

Parameters
resultWritable destination, unchanged when no result is available.
Returns
True for a newly consumed completion; its window time is not its inference completion time.

Definition at line 199 of file ear_inference.c.