> ## 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 enhancement and processor control

> Create and initialize an enhancement processor, process mono audio and control stream state.

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.

<span id="AicProcessorParameter" />

## AicProcessorParameter

<span id="AIC_PROCESSOR_PARAMETER_BYPASS" />

<span id="AIC_PROCESSOR_PARAMETER_ENHANCEMENT_LEVEL" />

| Constant                                    | Value | Range and default                                                                                                                              |
| ------------------------------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `AIC_PROCESSOR_PARAMETER_BYPASS`            | 0     | Value 0 disables bypass; any value greater than 0 and at most 1 enables it. Default: off. Getter returns 0 or 1. Bypass keeps delay alignment. |
| `AIC_PROCESSOR_PARAMETER_ENHANCEMENT_LEVEL` | 1     | 0–1 inclusive. Default comes from model metadata, falling back to 1. The model can also scale the effective strength.                          |

Use normalized mono float32 samples, nominally -1.0 to 1.0. Keep audio storage valid during each call. [Audio format](/reference/concepts/audio-format) explains block sizing; [streams and state](/reference/concepts/streams-and-state) explains discontinuities.

<span id="aic_processor_create" />

## aic\_processor\_create

```c theme={null}
enum AicErrorCode aic_processor_create(struct AicProcessor **processor,
                                       const struct AicModel *model,
                                       const char *license_key,
                                       const struct AicOtelConfig *otel_config);
```

`processor` is a writable output slot. `model` must be an enhancement or bypass model; `license_key` is a null-terminated SDK key or supported bearer token. `otel_config` may be `NULL` to use environment defaults, or point to [AicOtelConfig](/reference/sdk/api/c/models-and-config#AicOtelConfig). The function copies configuration strings and retains model data internally. On success, destroy the owned processor handle separately. Errors include `NULL_POINTER`, `MODEL_TYPE_UNSUPPORTED`, license errors and `INTERNAL_ERROR`. Construction allocates resources and may start session work; keep it outside an audio callback.

<span id="aic_processor_destroy" />

## aic\_processor\_destroy

```c theme={null}
void aic_processor_destroy(struct AicProcessor *processor);
```

Releases `processor` and its model reference and ends its associated session. `NULL` is a no-op. Stop processing and other calls that use this handle first. Context handles are independent and must be destroyed separately. Teardown can block; keep it outside an audio callback. No return value.

<span id="aic_processor_initialize" />

## aic\_processor\_initialize

```c theme={null}
enum AicErrorCode aic_processor_initialize(struct AicProcessor *processor,
                                           uint32_t sample_rate,
                                           size_t block_size,
                                           bool variable_block_size);
```

Configures `processor` for `sample_rate` in Hz (8,000–192,000 inclusive), a positive `block_size` in mono samples and `variable_block_size`. With `false`, every call must supply exactly `block_size`; with `true`, that value is the maximum per call. Reinitialization resets processing state. Returns `SUCCESS`, `NULL_POINTER` or `AUDIO_CONFIG_UNSUPPORTED`. A failed initialization leaves the object uninitialized; initialize successfully before processing again. Allocates internal buffers; do not call concurrently with processing.

<span id="aic_processor_process" />

## aic\_processor\_process

```c theme={null}
enum AicErrorCode aic_processor_process(struct AicProcessor *processor,
                                        float *audio_ptr,
                                        size_t audio_len);
```

`audio_ptr` points to `audio_len` writable contiguous mono float32 samples. Processing modifies the buffer in place, retains stream state and returns only after using the buffer. Keep one processor per independent stream. Returns `SUCCESS`, `NULL_POINTER`, `NOT_INITIALIZED`, `AUDIO_CONFIG_MISMATCH` or `PROCESSING_NOT_ALLOWED` (and internal failures). A disallowed call can already have advanced buffering or written delayed input; do not treat error output as enhanced audio. Do not process the same object concurrently.

<span id="aic_processor_terminate_session" />

## aic\_processor\_terminate\_session

```c theme={null}
enum AicErrorCode aic_processor_terminate_session(struct AicProcessor *processor);
```

Requests termination of the session associated with `processor`. Returns `SUCCESS` after requesting it, or `NULL_POINTER`. Termination is handled asynchronously; a successful return does not prove remote acknowledgment or immediate processing denial. For credentials with no telemetry session, this is a no-op. It does not destroy the handle. Stop application processing explicitly and destroy the object 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_processor_context_create" />

## aic\_processor\_context\_create

```c theme={null}
enum AicErrorCode aic_processor_context_create(struct AicProcessorContext **context,
                                               const struct AicProcessor *processor);
```

`context` is a writable output slot; `processor` is the source object. Returns a separately owned context with shared control state. It can outlive the source object, but no new audio is processed after the source is destroyed. Returns `SUCCESS` or `NULL_POINTER`. Allocate outside the callback and destroy the context separately.

<span id="aic_processor_context_destroy" />

## aic\_processor\_context\_destroy

```c theme={null}
void aic_processor_context_destroy(struct AicProcessorContext *context);
```

Releases `context`; `NULL` is a no-op. Stop users of this context handle first. This does not destroy the processing object. No return value.

<span id="aic_processor_context_reset" />

## aic\_processor\_context\_reset

```c theme={null}
enum AicErrorCode aic_processor_context_reset(const struct AicProcessorContext *context);
```

Requests a reset of the stream buffers and model state, applied at the next processing call. Audio configuration and parameter values remain in place. `context` must be valid. Returns `SUCCESS` or `NULL_POINTER`. The shared control operation can run alongside processing; coordinate a stream boundary if you need a precise reset position.

<span id="aic_processor_context_set_parameter" />

## aic\_processor\_context\_set\_parameter

```c theme={null}
enum AicErrorCode aic_processor_context_set_parameter(const struct AicProcessorContext *context,
                                                      enum AicProcessorParameter parameter,
                                                      float value);
```

Sets `parameter` to `value` through shared control state. Use only the declared [AicProcessorParameter](/reference/sdk/api/c/processing#AicProcessorParameter) values and documented ranges. Returns `SUCCESS`, `NULL_POINTER` or `PARAMETER_OUT_OF_RANGE`; NaN is out of range. Updates may run alongside processing. No ownership transfer.

<span id="aic_processor_context_get_parameter" />

## aic\_processor\_context\_get\_parameter

```c theme={null}
enum AicErrorCode aic_processor_context_get_parameter(const struct AicProcessorContext *context,
                                                      enum AicProcessorParameter parameter,
                                                      float *value);
```

Writes the current `parameter` value to the non-null writable `value` pointer. Use a declared enum value. Returns `SUCCESS` or `NULL_POINTER`. Shared control reads can run alongside processing.

<span id="aic_processor_context_get_audio_delay" />

## aic\_processor\_context\_get\_audio\_delay

```c theme={null}
enum AicErrorCode aic_processor_context_get_audio_delay(const struct AicProcessorContext *context,
                                                        size_t *delay);
```

Writes the current audio delay to `delay`, measured in samples at the initialized host rate. Query after successful initialization and again if you reinitialize. Both `context` and writable `delay` must be non-null. Returns `SUCCESS` or `NULL_POINTER`. This shared metadata read can run alongside processing; it is not elapsed CPU time.

<span id="aic_processor_context_update_bearer_token" />

## aic\_processor\_context\_update\_bearer\_token

```c theme={null}
enum AicErrorCode aic_processor_context_update_bearer_token(const struct AicProcessorContext *context,
                                                            const char *token);
```

Updates credentials through `context` using null-terminated UTF-8 `token`. Both the original credential and replacement must use the supported JWT form. Returns `SUCCESS`, `NULL_POINTER`, `LICENSE_FORMAT_INVALID`, other license errors or `TOKEN_UPDATE_UNSUPPORTED`. Success updates local credential state; it does not prove backend acceptance. This is a control-thread operation, not an audio-callback operation. See [authentication](/models/get-started/authenticate-apps).

## Related

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

## Example: process one initialized stream block

Call this helper repeatedly with an initialized processor and its context. Each successful call modifies the audio buffer. Read the delay after initialization to align output.

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

AicErrorCode process_block(AicProcessor *processor, AicProcessorContext *context,
                           float *audio, size_t count, size_t *delay) {
    AicErrorCode error = aic_processor_context_get_audio_delay(context, delay);
    if (error != AIC_ERROR_CODE_SUCCESS) return error;
    return aic_processor_process(processor, audio, count);
}
```
