> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ai-coustics.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C audio analysis

> Collect audio features and run analysis on a separate thread.

All functions on this page are from C SDK **0.24.0**, core **0.24.0**. Include `aic.h` and link the matching native library. Start with the [C integration guide](/reference/sdk/language-bindings/c).

The [pointer and error contract](/reference/sdk/api/c/errors-and-types#pointer-contract) applies to every signature below. Error names in prose omit the `AIC_ERROR_CODE_` prefix. There are no default C arguments; optional pointers are stated explicitly.

Use a compatible [Tyto model](/models/audio-insight/tyto). The collector accepts mono float32 samples; the analyzer reads a snapshot of the collected features. A successful buffering call is not a completed model inference. Read [analysis fields](/reference/sdk/api/c/errors-and-types#AicAnalysisResult) only after a successful analysis call.

<span id="aic_analyzer_pair_create" />

## aic\_analyzer\_pair\_create

```c theme={null}
enum AicErrorCode aic_analyzer_pair_create(struct AicCollector **collector,
                                           struct AicAnalyzer **analyzer,
                                           const struct AicModel *model,
                                           const char *license_key);
```

`collector` and `analyzer` are distinct writable output slots. `model` must be an analysis model; `license_key` is a null-terminated SDK key or supported bearer token. On success, each output is independently owned and must be destroyed. The analyzer retains the model data. Creation allocates; it does not initialize the collector. Returns `SUCCESS`, `NULL_POINTER`, `MODEL_TYPE_UNSUPPORTED`, license errors or `INTERNAL_ERROR`. This API has no OTel configuration parameter and disables optional OTel export for this pair; SDK session requirements remain separate.

<span id="aic_collector_initialize" />

## aic\_collector\_initialize

```c theme={null}
enum AicErrorCode aic_collector_initialize(struct AicCollector *collector,
                                           uint32_t sample_rate,
                                           size_t block_size,
                                           bool variable_block_size);
```

Configures `collector` with `sample_rate` in Hz (8,000–192,000), positive `block_size` in mono samples and fixed (`false`) or variable (`true`) block sizing. Fixed input must match the block size; variable input cannot exceed it. Returns `SUCCESS`, `NULL_POINTER` or `AUDIO_CONFIG_UNSUPPORTED`. Failure leaves the collector uninitialized. Allocate and initialize before starting audio collection; do not reinitialize while collecting.

<span id="aic_collector_buffer" />

## aic\_collector\_buffer

```c theme={null}
enum AicErrorCode aic_collector_buffer(struct AicCollector *collector,
                                       const float *audio_ptr,
                                       size_t audio_len);
```

Copies/accumulates `audio_len` mono float32 samples from the readable `audio_ptr` into the collection pipeline without modifying input. Returns `SUCCESS`, `NULL_POINTER`, `NOT_INITIALIZED` or `AUDIO_CONFIG_MISMATCH`. This collects features; it does not run analysis or return scores. One thread may feed the collector while a separate thread calls the paired analyzer; do not call this function concurrently on one collector.

<span id="aic_collector_destroy" />

## aic\_collector\_destroy

```c theme={null}
void aic_collector_destroy(struct AicCollector *collector);
```

Releases `collector`; `NULL` is a no-op. Stop calls using that handle first. The analyzer is owned separately and is not destroyed by this call. Teardown is outside the audio callback. No return value.

<span id="aic_analyzer_reset" />

## aic\_analyzer\_reset

```c theme={null}
enum AicErrorCode aic_analyzer_reset(const struct AicAnalyzer *analyzer);
```

Requests a reset of the paired collector through `analyzer`. The next collection call clears pending stream state; analysis while the reset is pending uses an empty, padded window. Returns `SUCCESS` or `NULL_POINTER`. Parameters and collector audio configuration are retained. Coordinate unrelated recordings so they do not share a window.

<span id="aic_analyzer_analyze_buffered" />

## aic\_analyzer\_analyze\_buffered

```c theme={null}
enum AicErrorCode aic_analyzer_analyze_buffered(struct AicAnalyzer *analyzer,
                                                struct AicAnalysisResult *result);
```

Runs the model on the latest fixed-size feature window from `analyzer` and writes all seven fields of writable `result` only on success. Early windows are silence-padded; repeated calls without new input can score the same window. This does not consume a caller-owned audio buffer. Returns `SUCCESS`, `NULL_POINTER`, `PROCESSING_NOT_ALLOWED` or `INTERNAL_ERROR` (for example, no usable snapshot). Call off the audio thread and serialize analysis calls. The paired collector can continue feeding from another thread.

<span id="aic_analyzer_terminate_session" />

## aic\_analyzer\_terminate\_session

```c theme={null}
enum AicErrorCode aic_analyzer_terminate_session(struct AicAnalyzer *analyzer);
```

Requests session termination through `analyzer`. Returns `SUCCESS` or `NULL_POINTER`; it does not destroy either handle. Termination is asynchronous and is a no-op if no session exists. Stop analysis explicitly and release both handles when finished. On native targets, terminating the final active session may wait for the shared telemetry tasks to finish. Call it outside the audio callback.

<span id="aic_analyzer_update_bearer_token" />

## aic\_analyzer\_update\_bearer\_token

```c theme={null}
enum AicErrorCode aic_analyzer_update_bearer_token(const struct AicAnalyzer *analyzer,
                                                   const char *token);
```

Updates the analyzer session with null-terminated UTF-8 `token`. Both original and new credentials must use supported JWT form. Returns `SUCCESS`, `NULL_POINTER`, `LICENSE_FORMAT_INVALID`, other license errors or `TOKEN_UPDATE_UNSUPPORTED`. Call on a control thread. Success means local credential replacement, not backend acknowledgment.

<span id="aic_analyzer_destroy" />

## aic\_analyzer\_destroy

```c theme={null}
void aic_analyzer_destroy(struct AicAnalyzer *analyzer);
```

Releases `analyzer`, its model reference and its associated session. `NULL` is a no-op. The collector must be destroyed separately. Stop calls using the analyzer first; destruction can block. No return value.

## Related

[C API index](/reference/sdk/api/c/index) · [C examples](/reference/sdk/examples#c) · [Compatibility](/reference/sdk/compatibility-matrix)

## Example: check an analysis result

Run this helper on the analysis thread after initializing and feeding the paired collector. It copies the headline score only on success.

```c theme={null}
#include "aic.h"

AicErrorCode read_risk(AicAnalyzer *analyzer, float *risk) {
    if (risk == NULL) return AIC_ERROR_CODE_NULL_POINTER;
    AicAnalysisResult result;
    AicErrorCode error = aic_analyzer_analyze_buffered(analyzer, &result);
    if (error == AIC_ERROR_CODE_SUCCESS) *risk = result.risk_score;
    return error;
}
```
