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

# State Enum & Callbacks

> ProcessorState, ProcessorStateChange, and the state/transcript callback signatures

## `ProcessorState`

Tracks the lifecycle of an `IAudioProcessor`: `kUnknown` → `kInitializing` → `kReady`, or `kFailed` / `kDisconnected` on error.

| Value           | Meaning                                                                |
| --------------- | ---------------------------------------------------------------------- |
| `kUnknown`      | Initial state before connection begins.                                |
| `kInitializing` | Connecting to the server — do not send audio yet.                      |
| `kReady`        | Connected and ready — safe to call `ProcessSamples`.                   |
| `kFailed`       | Connection or processing error. Destroy and recreate the processor.    |
| `kDisconnected` | Was connected; the connection dropped. Destroy and recreate if needed. |

## `ProcessorStateChange`

Returned by `GetNextStateChange` and `WaitForStateChange` when polling.

| Field    | Type             | Description                               |
| -------- | ---------------- | ----------------------------------------- |
| `state`  | `ProcessorState` | The new processor state.                  |
| `reason` | string           | Human-readable reason for the transition. |

## Callbacks

Both callbacks run on background threads managed by the SDK. Keep them fast, non-blocking, and thread-safe.

### `ProcessorStateCallback`

Invoked whenever the processor's state changes.

```cpp theme={null}
auto onState = [](ProcessorState s, std::string reason) {
    // handle state transition
};
```

### `TranscriptCallback`

Invoked each time a transcript JSON event is received from the server. See [Transcripts](/API-Reference/Cpp-SDK/Guides/Transcripts) for the payload schema.

```cpp theme={null}
auto onTranscript = [](const std::string& json) {
    // parse and handle the JSON event
};
```

Both are passed to `CreateAudioProcessor`:

```cpp theme={null}
auto p = sdk->CreateAudioProcessor(params, rc, onState, onTranscript);
```
