# Bindings: C#

1005 public names in `bindings/csharp/Sona.cs`, `bindings/csharp/Editor.cs`, `bindings/csharp/Track.cs`, `bindings/csharp/Picking.cs`.

## SonaException

`sealed class SonaException : Exception`: The last error on a ctx: code, message and what to do about it. The C type sona_error_info.

| Declaration | What it does |
|---|---|
| `SonaException(SonaResult code, string message, string fix)` | The last error on a ctx: code, message and what to do about it. The C type sona_error_info. |
| `SonaResult Code` | The C field sona_error_info.code (sona_result value). |
| `string Fix` | The C field sona_error_info.fix (text (UTF-8), NULL: none). |

## SonaLibrary

`static unsafe class SonaLibrary`: Where the native library is loaded from: SONA_LIB_DIR, then the system's library path.

| Declaration | What it does |
|---|---|
| `static string Version` | The library's version, "1.1.0".<br>Calls [`sona_version`](../c/the-context.md#sona_version). |
| `static string Platform` | The binary platform id compiled into this library: "windows-x64", "linux-x64", "linux-arm64", "macos-arm64", "macos-x64", "ios-arm64", "android-arm64", "android-x64", "xbox360" or "wasm".<br>Calls [`sona_platform`](../c/the-context.md#sona_platform). |
| `static string ResultName(SonaResult r)` | The name of a code ("licence", "gate",...): the same words as the web SDK's SonaError.code.<br>Calls [`sona_result_name`](../c/results-and-errors.md#sona_result_name). |
| `static void EnsureLayout()` | Throws unless every struct this binding mirrors has the library's size and field offsets. |

## SonaSource

`abstract class SonaSource`: A host-written asset source.

| Declaration | What it does |
|---|---|
| `abstract void Read(SonaReadKind kind, string name, SonaRequest request)` | The C field sona_source.read (a function (NULL: none)). |
| `virtual void Cancel(SonaRequest request)` | Optional. The C field sona_source.cancel (a function (NULL: none)). |
| `virtual void Destroy()` | Optional, called by sona_close. The C field sona_source.destroy (a function (NULL: none)). |

## SonaRequest

`sealed unsafe class SonaRequest`: one read in flight from a source The C type sona_request.

| Declaration | What it does |
|---|---|
| `bool IsCompleted` | True once the request has been answered (Complete, NotFound or Failed). |
| `void Complete(byte[] bytes)`<br>`void Complete(SonaResult status, byte[] bytes, int offset, int count)`<br>`void Complete(SonaResult status, ReadOnlySpan<byte> bytes)` | Finishes one read, exactly once, also after cancel; the request stays valid until then.<br>Calls [`sona_complete`](../c/asset-sources.md#sona_complete). |
| `void NotFound()` | Answers the read: the source has no such file (SONA_E_NOT_FOUND). |
| `void Failed()` | Answers the read: the source failed and a retry may work (SONA_E_IO). |

## SonaHttpRequest

`sealed class SonaHttpRequest`: The C type sona_http_request.

| Declaration | What it does |
|---|---|
| `string Method` | "GET" or "POST". The C field sona_http_request.method (text (UTF-8), NULL: none). |
| `string Url` | The C field sona_http_request.url (text (UTF-8), NULL: none). |
| `string[] Headers` | "Name: value" strings, NULL-terminated; may be NULL. The C field sona_http_request.headers (text (UTF-8), NULL: none). |
| `byte[] Body` | The C field sona_http_request.body (pointer). |
| `uint TimeoutMs` | The C field sona_http_request.timeout_ms (ms). |

## SonaHttpReply

`sealed unsafe class SonaHttpReply`: The C type sona_http_reply.

| Declaration | What it does |
|---|---|
| `void Done(int status, byte[] body)`<br>`void Done(int status, byte[] body, int offset, int count)` | Exactly once per reply, from any thread; status 0 when the request could not be made.<br>Calls [`sona_http_done`](../c/http.md#sona_http_done). |
| `bool IsDone` | True once the reply has been given. |

## SonaHttp

`abstract class SonaHttp`: An HTTP layer the host supplies (UnityWebRequest, HttpClient,...).

| Declaration | What it does |
|---|---|
| `abstract void Send(SonaHttpRequest request, SonaHttpReply reply)` | Start the request; finish it later, from any thread, with sona_http_done(reply,...). The C field sona_http.send (a function (NULL: none)). |

## SonaJob

`readonly struct SonaJob`: One piece of work the core hands to a host job system; Invoke runs it once, on any thread.

| Declaration | What it does |
|---|---|
| `void Invoke()` | Runs the job; call it once. |

## SonaJobs

`abstract class SonaJobs`: A host job system: run each job once, on any thread, and never block the caller on it.

| Declaration | What it does |
|---|---|
| `abstract uint Workers` | How many run at once. The C field sona_jobs.workers (count). |
| `abstract void Run(SonaJob job)` | Run fn(arg) once, on any thread. The C field sona_jobs.run (a function (NULL: none)). |

## SonaSourceSpec

`sealed class SonaSourceSpec`: The C type sona_source_desc.

| Declaration | What it does |
|---|---|
| `SonaSourceKind Kind` | The C field sona_source_desc.kind (sona_source_kind value). |
| `string Location` | The C field sona_source_desc.location (text (UTF-8), NULL: none). |
| `SonaSource Custom` | The C field sona_source_desc.custom (pointer to sona_source). |
| `static SonaSourceSpec Dir(string folder)` | A source that reads a folder of avatar files. |
| `static SonaSourceSpec Console(string contentRoot)` | A source that reads a console's content root. |
| `static SonaSourceSpec Gate(string baseUrl = null)` | A source that reads from 360sona's gate (the given base address, or the default). |
| `static SonaSourceSpec From(SonaSource source)` | A source the host implements (a SonaSource). |

## SonaBudget

`sealed class SonaBudget`: Memory budget in bytes. The C type sona_budget.

| Declaration | What it does |
|---|---|
| `ulong Total` | 0: no overall cap (default). The C field sona_budget.total (bytes). |
| `ulong Assets` | Decoded items no avatar uses: default 256 MiB. The C field sona_budget.assets (bytes). |
| `ulong Clips` | Retained clip blocks no avatar uses: default 32 MiB. The C field sona_budget.clips (bytes). |
| `ulong Faces` | Baked face sheets: default 64 MiB and at most 512 sheets, as the web. The C field sona_budget.faces (bytes). |
| `ulong SourceCache` | Fetched container bytes, in memory only: default 64 MiB. The C field sona_budget.source_cache (bytes). |
| `ulong GpuIdle` | GPU objects no avatar uses any more: default 64 MiB, as the web. The C field sona_budget.gpu_idle (bytes). |

## SonaOptions

`sealed class SonaOptions`: The C type sona_config.

| Declaration | What it does |
|---|---|
| `string AppId` | NULL: the app id stamped into this build. The C field sona_config.app_id (text (UTF-8), NULL: none). |
| `byte[] Licence` | Sona-licence.json from the download, as bytes. The C field sona_config.licence (pointer). |
| `readonly List<SonaSourceSpec> Sources = new List<SonaSourceSpec>()` | Asked in order; the first that has an asset wins. The C field sona_config.sources (a sona_source_desc (see its fields)). |
| `SonaHttp Http` | NULL: sona_http_platform. The C field sona_config.http (pointer to sona_http). |
| `int WorkerThreads = -1` | -1: cores - 1 (default); 0: none, work runs inside sona_update. The C field sona_config.worker_threads (count). |
| `SonaJobs Jobs` | Workers also pose (sona_update) and fold (sona_draw) with the owner thread once 8 or more avatars are in play; poses are the same bits as with 0 when.run is set it replaces worker_threads. The C field sona_config.jobs (a sona_jobs (see its fields)). |
| `uint Seed` | Idle and start-time randomness; 0: from the clock. The C field sona_config.seed (index or id). |
| `uint MaxAvatars = 256` | Default 256, at most 16384. The C field sona_config.max_avatars (count). |
| `float BuildBudgetMs = 6` | owner-thread loading work per sona_update (steps, commits; builds run on the workers); default 6. The C field sona_config.build_budget_ms (ms). |
| `uint FaceSize` | 0: auto (512 up to 4 avatars, 256 up to 32, else 128); or 128, 256, 512. The C field sona_config.face_size (px). |
| `SonaConfigFlags Flags` | SONA_CFG_*. The C field sona_config.flags (bit flags). |
| `SonaBudget Budget` | The C field sona_config.budget (a sona_budget (see its fields)). |
| `Action<SonaLogLevel, string> Log` | The C field sona_config.log (a function (NULL: none)). |
| `string CheckHost` | NULL: https://test.360sona.com, the devs site. The C field sona_config.check_host (text (UTF-8), NULL: none). |

## SonaPlacement

`struct SonaPlacement`: The C type sona_placement.

| Declaration | What it does |
|---|---|
| `float X` | Where the avatar stands, in metres: x. The C field sona_placement.position[0]. |
| `float Y` | Where the avatar stands, in metres: y. The C field sona_placement.position[1]. |
| `float Z` | Where the avatar stands, in metres: z. The C field sona_placement.position[2]. |
| `float TurnDeg` | Degrees about Y; 0 faces -Z. The C field sona_placement.turn_deg (degrees). |
| `float Scale` | Default 1. The C field sona_placement.scale (factor (unitless)). |
| `SonaPlacement(float x, float y, float z, float turnDeg = 0, float scale = 1)` | The C type sona_placement. |
| `static SonaPlacement Default` | At the origin, turned 0 degrees (facing -Z), scale 1. |

## SonaAddOptions

`sealed class SonaAddOptions`: The C type sona_add_options.

| Declaration | What it does |
|---|---|
| `SonaPlacement Placement = SonaPlacement.Default` | The C type sona_placement. |
| `string Clip` | A clip key, a raw clip id, "prop", "idle" or "still"; NULL: "idle". The C field sona_add_options.clip (text (UTF-8), NULL: none). |
| `bool Loop = true` | Default 1. The C field sona_add_options.loop (flag (0 or 1)). |
| `float Speed = 1` | Default 1. The C field sona_add_options.speed (factor (1: as made)). |
| `float StartAt` | Seconds; negative means random, to desynchronise a crowd. The C field sona_add_options.start_at (s). |
| `bool Visible = true` | Default 1. The C field sona_add_options.visible (flag (0 or 1)). |
| `int Priority` | Higher builds sooner; default 0. The C field sona_add_options.priority (order (higher first)). |

## SonaView

`struct SonaView`: A camera: the eye, the target, the vertical field of view in degrees, near and far, and the target size in pixels, kept in doubles. The C type sona_view.

| Declaration | What it does |
|---|---|
| `double EyeX` | The C field sona_view.eye, one part (m (world units)). |
| `double EyeY` | The C field sona_view.eye, one part (m (world units)). |
| `double EyeZ` | The C field sona_view.eye, one part (m (world units)). |
| `double TargetX` | Up is always +Y (lookAtLH), as the web camera. The C field sona_view.target, one part (m (world units)). |
| `double TargetY` | Up is always +Y (lookAtLH), as the web camera. The C field sona_view.target, one part (m (world units)). |
| `double TargetZ` | Up is always +Y (lookAtLH), as the web camera. The C field sona_view.target, one part (m (world units)). |
| `double FovDeg` | Vertical field of view in degrees; default 28.65, as the web. The C field sona_view.fov_deg (degrees). |
| `double NearZ` | Default 0.05. The C field sona_view.near_z (m (world units)). |
| `double FarZ` | Default 200 (the web SDK's; the editor uses 20). The C field sona_view.far_z (m (world units)). |
| `uint Width` | The target size in pixels, for LOD and culling. The C field sona_view.width (px). |
| `uint Height` | The target size in pixels, for LOD and culling. The C field sona_view.height (px). |
| `static unsafe SonaView Defaults()` | The web's full-body framing.<br>Calls [`sona_view_defaults`](../c/the-frame.md#sona_view_defaults). |
| `static unsafe SonaView FromNative(in Native.sona_view v)` | A SonaView from the C struct sona_view. |
| `unsafe Native.sona_view ToNative()` | The C struct sona_view for this view. |

## SonaEvent

`struct SonaEvent`: The C type sona_event.

| Declaration | What it does |
|---|---|
| `SonaEventType Type` | The C field sona_event.type (sona_event_type value). |
| `SonaAvatar Avatar` | READY and FAILED. The C field sona_event.avatar (pointer to sona_avatar). |
| `SonaResult Code` | The C field sona_event.code (sona_result value). |
| `string Message` | Valid until the next sona_poll_event. The C field sona_event.message (text (UTF-8), NULL: none). |
| `string Fix` | The C field sona_event.fix (text (UTF-8), NULL: none). |

## SonaClipInfo

`struct SonaClipInfo`: The C type sona_clip_info.

| Declaration | What it does |
|---|---|
| `string Key` | "GenericWave", "Stand0",... The C field sona_clip_info.key (text (UTF-8), NULL: none). |
| `string Id` | The clip's item id, or NULL for "idle", "still" and "prop". The C field sona_clip_info.id (text (UTF-8), NULL: none). |
| `string Caption` | May be NULL. The C field sona_clip_info.caption (text (UTF-8), NULL: none). |
| `float Seconds` | Negative when not known until decoded. The C field sona_clip_info.seconds (s). |
| `bool IsProp` | True when the clip holds a prop (its item and palette come with the pose). |

## SonaCreditImage

`sealed class SonaCreditImage`: The "Powered by 360sona" badge as pixels: its text, link, size and straight-alpha RGBA, from sona_credit_get.

| Declaration | What it does |
|---|---|
| `string Text` | The badge's words: "Powered by 360sona". |
| `string Url` | Where the badge links: https://360sona.com. |
| `uint Width` | The badge picture's width in px. |
| `uint Height` | The badge picture's height in px. |
| `byte[] Rgba` | The badge's pixels: straight-alpha RGBA8, row 0 at the top. |

## SonaShadingData

`sealed class SonaShadingData`: The fixed shading inputs, for hosts that rebuild our look in their own shaders. The C type sona_shading.

| Declaration | What it does |
|---|---|
| `uint IrradianceSize` | Texels a side of each irradiance face (16). |
| `ushort[] Irradiance` | 16x16 per face, RGBA16F, truncated from the captured floats as the web. The C field sona_shading.irradiance (a sona_texture (see its fields)). |
| `float IrradianceGain` | 1.0. The C field sona_shading.irradiance_gain (radians). |
| `float AoGain` | 0 in the SDK. The C field sona_shading.ao_gain (factor (unitless)). |
| `float BloomGain` | 0.1875. The C field sona_shading.bloom_gain (factor (unitless)). |
| `float[] ShadowRows = new float[12]` | The 3x4 light lookup the web ships. The C field sona_shading.shadow_rows (light lookup rows (unitless, 3x4)). |
| `float[] Rim = new float[4]` | 0.549, 0.502, 0.4039, 1.6. The C field sona_shading.rim (rim colour and power (unitless)). |

## SonaContext

`sealed unsafe class SonaContext : IDisposable`: The C type sona_ctx.

| Declaration | What it does |
|---|---|
| `SonaSource Source` | A host-written source. The C type sona_source. |
| `readonly ConcurrentDictionary<IntPtr, SonaRequest> Pending = new ConcurrentDictionary<IntPtr, SonaRequest>()` | The value of SONA_PENDING. |
| `SonaContext(SonaOptions options)` | Opens a context.<br>Calls [`sona_config_defaults`](../c/the-context.md#sona_config_defaults), [`sona_open`](../c/the-context.md#sona_open). |
| `IntPtr Handle` | The native handle this object owns, for a call the binding does not wrap. |
| `bool IsDisposed` | True once Dispose has run; every other call then throws. |
| `string AppId` | The app id this context runs as.<br>Calls [`sona_app_id`](../c/the-context.md#sona_app_id). |
| `SonaException LastError()` | The last error on a ctx.<br>Calls [`sona_last_error`](../c/results-and-errors.md#sona_last_error). |
| `static Native.sona_prop_part PropPartDefaults()` | size set; colour 0xffffffff.<br>Calls [`sona_prop_part_defaults`](../c/props-held-and-worn-objects.md#sona_prop_part_defaults). |
| `static Native.sona_prop_load_options PropLoadDefaults()` | size set; scale 1.<br>Calls [`sona_prop_load_defaults`](../c/props-held-and-worn-objects.md#sona_prop_load_defaults). |
| `SonaPropMesh CreatePropMesh(Native.sona_prop_part[] parts)` | A prop mesh from triangles; the parts' pointers must stay valid for the call only.<br>Calls [`sona_prop_mesh_create`](../c/props-held-and-worn-objects.md#sona_prop_mesh_create). |
| `SonaPropMesh LoadPropMesh(byte[] bytes, Native.sona_prop_load_options? options = null)` | A glTF 2.0 file (.glb, or.gltf with embedded buffers) as a prop mesh.<br>Calls [`sona_prop_mesh_load`](../c/props-held-and-worn-objects.md#sona_prop_mesh_load). |
| `SonaPropMesh OpenPropMesh(string path, Native.sona_prop_load_options? options = null)` | A glTF file from a path; a.gltf's buffers and images next to it are read too.<br>Calls [`sona_prop_mesh_open`](../c/props-held-and-worn-objects.md#sona_prop_mesh_open). |
| `SonaPropMesh StockPropMesh(string itemId)` | A stock prop item (a carryable); State is Pending until it has loaded.<br>Calls [`sona_prop_mesh_stock`](../c/props-held-and-worn-objects.md#sona_prop_mesh_stock). |
| `static string[] PropPets()` | The catalogue's pets, as the site's pet mode lists them.<br>Calls [`sona_prop_pet_count`](../c/props-held-and-worn-objects.md#sona_prop_pet_count), [`sona_prop_pet`](../c/props-held-and-worn-objects.md#sona_prop_pet), [`sona_guid_format`](../c/manifests.md#sona_guid_format). |
| `static bool PropIsPet(string itemId)` | 1 when the item id is one of the pets.<br>Calls [`sona_prop_is_pet`](../c/props-held-and-worn-objects.md#sona_prop_is_pet). |
| `static Native.sona_interaction_desc InteractionDefaults(uint kind)` | Sets size, kind, the kind's default timings in seconds (high five 0.8, 0.15, 0.7; handshake 0.9, 1.6, 0.8; hug 1.1, 2.5, 1.0; hold hands 0.8, 0, 0.6; sit 1.3, 0, 1.4) and a default seat.<br>Calls [`sona_interaction_defaults`](../c/two-avatar-interactions-and-seats.md#sona_interaction_defaults). |
| `static Native.sona_seat SeatDefaults(uint kind)` | size set and a seat of that kind: height 0.45 (0 for GROUND), depth 0.45 (unlimited for GROUND), width 0.5 for a chair, 1.4 for a bench and unlimited on the ground.<br>Calls [`sona_seat_defaults`](../c/two-avatar-interactions-and-seats.md#sona_seat_defaults). |
| `static bool TryLayoutInteraction(in Native.sona_interaction_desc desc, out Native.sona_interaction_plan plan)` | Where an interaction would stand its avatars and where the contacts meet; false while the avatars (or, for SIT, the stock sit clip) are still loading.<br>Calls [`sona_interaction_layout`](../c/two-avatar-interactions-and-seats.md#sona_interaction_layout). |
| `SonaInteraction StartInteraction(in Native.sona_interaction_desc desc)` | Starts an interaction between desc.a and desc.b (SonaAvatar.Handle; b zero for SIT).<br>Calls [`sona_interaction_start`](../c/two-avatar-interactions-and-seats.md#sona_interaction_start). |
| `int ParamId(string name)` | The id of a parameter name, numbered from 0 in the order first asked for; -1 for a bad name or past 32.<br>Calls [`sona_param_id`](../c/animation-layers.md#sona_param_id). |
| `SonaBlendSpace CreateBlendSpace(string paramX, string paramY, SonaBlendSample[] samples, bool unsynced = false, float smoothSeconds = 0.1f)` | A blend space over paramX (and paramY when 2D); one serves every avatar of this context.<br>Calls [`sona_blend_space_defaults`](../c/animation-layers.md#sona_blend_space_defaults), [`sona_blend_space_create`](../c/animation-layers.md#sona_blend_space_create). |
| `SonaStateMachine CreateStateMachine(SonaState[] states, SonaTransition[] transitions, string initial = null)` | A state machine; one serves every avatar of this context.<br>Calls [`sona_state_machine_defaults`](../c/animation-layers.md#sona_state_machine_defaults), [`sona_state_machine_create`](../c/animation-layers.md#sona_state_machine_create). |
| `SonaAvatar Add(byte[] manifest, SonaAddOptions options = null)` | Adds an avatar from its manifest bytes (sona_avatar_add); it builds in the background and shows once READY. |
| `SonaAvatar AddBase64(string base64, SonaAddOptions options = null)` | Adds an avatar from a base64 manifest, as the web SDK and the lookup routes give them (sona_avatar_add_base64). |
| `SonaAvatar AddState(byte[] blob)` | A new avatar with a saved state's look and state.<br>Calls [`sona_avatar_add_state`](../c/state-sync-and-replays.md#sona_avatar_add_state). |
| `SonaAvatar AddWaiting(SonaAddOptions options = null)` | A player whose manifest is not known: QUEUED, a neutral figure while placeholders are on, until SonaAvatar.SetManifest gives it one. |
| `SonaAvatar AddItemPreview(string itemId, SonaPreviewOptions options = null)` | One item worn alone on a grey stand-in body, framed by its slot.<br>Calls [`sona_preview_defaults`](../c/item-previews.md#sona_preview_defaults), [`sona_item_preview_add`](../c/item-previews.md#sona_item_preview_add). |
| `static Native.sona_pixel_options PixelDefaults()` | size set, height 32, colours 16, flags SONA_PIXEL_OUTLINE, outline 0 (from the palette), alpha_cut 0.5, no palette.<br>Calls [`sona_pixel_defaults`](../c/2d-outputs.md#sona_pixel_defaults). |
| `SonaPicture PixelArt(SonaPicture picture, in Native.sona_pixel_options options, uint[] palette = null)` | Crisp pixel art from a straight RGBA8 picture.<br>Calls [`sona_pixel_art`](../c/2d-outputs.md#sona_pixel_art). |
| `uint[] PixelPalette(IReadOnlyList<SonaPicture> pictures, uint colours = 16)` | One palette (0xFFRRGGBB, darkest first) for several pictures.<br>Calls [`sona_pixel_palette`](../c/2d-outputs.md#sona_pixel_palette). |
| `static Native.sona_lod_options LodDefaults()` | The level-of-detail defaults, with sprites on at 48 px.<br>Calls [`sona_lod_defaults`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_defaults). |
| `void SetLod()`<br>`void SetLod(in Native.sona_lod_options options)` | Turns on the default LOD steps and sprites (a context opens with no sprites, as 1.0 drew).<br>Calls [`sona_lod_set`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_set). |
| `void SetSwayWorld(in Native.sona_sway_world world)` | The gravity and wind every swaying avatar of this context feels.<br>Calls [`sona_sway_world_set`](../c/hair-and-cloth-sway.md#sona_sway_world_set). |
| `static Native.sona_sway_world SwayWorldDefaults()` | Gravity 0 -9.81 0, no wind, gust 0.35 with a period of 1.5 s.<br>Calls [`sona_sway_world_defaults`](../c/hair-and-cloth-sway.md#sona_sway_world_defaults). |
| `Native.sona_lod_options GetLod()` | Copies the current options: before any sona_lod_set, thresholds 120 and 40 and no sprites (sprite_px 0).<br>Calls [`sona_lod_get`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_get). |
| `Native.sona_lod_stats LodStats()` | The level-of-detail statistics: avatars in view at each step, those fading, the baked looks and the bakes of the last draw.<br>Calls [`sona_lod_stats_get`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_stats_get). |
| `static Native.sona_placeholder_options PlaceholderDefaults()` | size set; delay_seconds 0 (never a hole), appear_seconds 0.2, reveal_seconds 0.4, failed_seconds 2, tint 0.16, 0.19, 0.25 (a cool grey), failed_tint 0.25, 0.15, 0.15 (a muted red), glow 0.5.<br>Calls [`sona_placeholder_defaults`](../c/loading-placeholders.md#sona_placeholder_defaults). |
| `void SetPlaceholders()`<br>`void SetPlaceholders(in Native.sona_placeholder_options options)` | Loading avatars show a neutral figure until they are READY (off on a new context).<br>Calls [`sona_placeholder_set`](../c/loading-placeholders.md#sona_placeholder_set). |
| `bool GetPlaceholders(out Native.sona_placeholder_options options)` | The options; false while placeholders are off.<br>Calls [`sona_placeholder_get`](../c/loading-placeholders.md#sona_placeholder_get). |
| `void PlaceholdersOff()` | Figures shown now fade out over appear_seconds.<br>Calls [`sona_placeholder_off`](../c/loading-placeholders.md#sona_placeholder_off). |
| `Native.sona_placeholder_stats PlaceholderStats()` | Figures in view at the last sona_update (by phase, and how many as sprites), how many were posed and the time that took, and the figure draws of the last sona_draw or sona_snapshot.<br>Calls [`sona_placeholder_stats_get`](../c/loading-placeholders.md#sona_placeholder_stats_get). |
| `int AvatarCount` | How many avatars this context holds. |
| `Native.sona_frame_stats Update(double dtSeconds)`<br>`Native.sona_frame_stats Update(double dtSeconds, in SonaView view)` | Advances every avatar by dt_seconds (clamped to 0..0.1 s, as the web), runs build steps inside the build budget, culls against the view and poses what is due (the web's LOD rules).<br>Calls [`sona_update`](../c/the-frame.md#sona_update). |
| `bool PollEvent(out SonaEvent ev)` | True when an event was written to ev, false when there are none; call it until it is false.<br>Calls [`sona_poll_event`](../c/events.md#sona_poll_event). |
| `Native.sona_scene_stats Stats()` | The scene statistics.<br>Calls [`sona_stats`](../c/the-frame.md#sona_stats). |
| `List<SonaClipInfo> Clips()` | How many clips the context knows.<br>Calls [`sona_clip_count`](../c/clips.md#sona_clip_count), [`sona_clip_get`](../c/clips.md#sona_clip_get). |
| `bool TryGetShading(out SonaShadingData shading)` | False until the data files have loaded (sona_shading_get returns PENDING).<br>Calls [`sona_shading_get`](../c/the-data-api.md#sona_shading_get). |
| `SonaCreditImage GetCredit(uint scale = 1)` | The badge: scale 1 on screen; max(1, round(min(w, h) / 400)) for pictures, as the web.<br>Calls [`sona_credit_get`](../c/credit.md#sona_credit_get). |
| `byte[] EncodePng(byte[] rgba, uint width, uint height)` | PNG bytes with the web's three tEXt chunks.<br>Calls [`sona_png_encode`](../c/drawing-with-the-sdks-backends.md#sona_png_encode), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `SonaView FitCrowd(SonaView view)` | Fits every ready avatar in view (the web's preset "crowd").<br>Calls [`sona_camera_fit_crowd`](../c/camera-helpers.md#sona_camera_fit_crowd). |
| `SonaRenderer CreateRenderer(in Native.sona_device_desc device)` | Makes a renderer on the host's device.<br>Calls [`sona_renderer_create`](../c/drawing-with-the-sdks-backends.md#sona_renderer_create). |
| `void Dispose()` | Closes a context.<br>Calls [`sona_close`](../c/the-context.md#sona_close). |

## SonaInteraction

`sealed unsafe class SonaInteraction : IDisposable`: A running interaction (SonaContext.StartInteraction).

| Declaration | What it does |
|---|---|
| `IntPtr Handle` | The native handle this object owns, for a call the binding does not wrap. |
| `void End()` | Begins the end phase: letting go, standing up.<br>Calls [`sona_interaction_end`](../c/two-avatar-interactions-and-seats.md#sona_interaction_end). |
| `void Move(float x, float y, float z, float turnDeg)` | Moves the place (or the seat) while it runs.<br>Calls [`sona_interaction_move`](../c/two-avatar-interactions-and-seats.md#sona_interaction_move). |
| `Native.sona_interaction_status Status()` | Where an interaction is: its kind and phase, the time in the phase and how far through it, whether the contacts are together, the widest gap at a contact, the clearance between the two bodies (negative: into each other),<br>Calls [`sona_interaction_status_get`](../c/two-avatar-interactions-and-seats.md#sona_interaction_status_get). |
| `Native.sona_interaction_event[] Events()` | The events since the last call, oldest first.<br>Calls [`sona_interaction_events`](../c/two-avatar-interactions-and-seats.md#sona_interaction_events). |
| `void Dispose()` | Stops at once and frees it: its IK targets go, the avatars stay where they are and keep their clip.<br>Calls [`sona_interaction_remove`](../c/two-avatar-interactions-and-seats.md#sona_interaction_remove). |

## SonaAvatar

`sealed unsafe class SonaAvatar`: The C type sona_avatar.

| Declaration | What it does |
|---|---|
| `uint Id` | A number unique within the ctx. |
| `IntPtr Handle` | The native handle this object owns, for a call the binding does not wrap. |
| `SonaContext Context` | The C type sona_ctx. |
| `bool IsRemoved` | True once the avatar has been removed; its calls then throw. |
| `SonaAvatarState State` | The avatar's state.<br>Calls [`sona_avatar_state_of`](../c/avatars.md#sona_avatar_state_of). |
| `byte[] SaveState(bool withLook = true)` | The whole state as a blob; null before READY.<br>Calls [`sona_avatar_save_state`](../c/state-sync-and-replays.md#sona_avatar_save_state), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `void LoadState(byte[] blob)` | Puts a saved state on at the next update, once READY and its clips are loaded.<br>Calls [`sona_avatar_load_state`](../c/state-sync-and-replays.md#sona_avatar_load_state). |
| `void Puppet(bool on)` | A puppet's clocks stand still; only states put on it move it.<br>Calls [`sona_avatar_puppet`](../c/state-sync-and-replays.md#sona_avatar_puppet). |
| `bool TryExport(SonaExportOptions options, out byte[] file, out SonaExportReport report)` | The avatar as a.vrm (1.0 or 0.x) or.glb file.<br>Calls [`sona_export_defaults`](../c/skeleton-maps-and-vrm-export.md#sona_export_defaults), [`sona_export_avatar`](../c/skeleton-maps-and-vrm-export.md#sona_export_avatar), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `void Play(string clip, bool loop = true, float speed = 1, float from = 0)` | Before READY it is remembered and applied when the avatar appears.<br>Calls [`sona_avatar_play`](../c/avatars.md#sona_avatar_play). |
| `void Stop()` | Holds the current pose.<br>Calls [`sona_avatar_stop`](../c/avatars.md#sona_avatar_stop). |
| `void Move(SonaPlacement to, float overSeconds = 0)` | Moves the avatar to a new placement over over_seconds.<br>Calls [`sona_avatar_move`](../c/avatars.md#sona_avatar_move). |
| `void SetVisible(bool visible)` | Shows or hides it.<br>Calls [`sona_avatar_set_visible`](../c/avatars.md#sona_avatar_set_visible). |
| `void Bounds(out float cx, out float cy, out float cz, out float radius)` | A bounding sphere, in metres.<br>Calls [`sona_avatar_bounds`](../c/avatars.md#sona_avatar_bounds). |
| `void Remove()` | Removes the avatar and frees what only it used.<br>Calls [`sona_avatar_remove`](../c/avatars.md#sona_avatar_remove). |
| `bool TryGetPose(out SonaPose pose)` | False before READY.<br>Calls [`sona_pose`](../c/the-data-api.md#sona_pose). |
| `void PoseVertices(uint mesh, bool worldSpace, float[] positions, float[] normals, int strideFloats = 3)` | CPU skinning of one mesh: positions (and normals when given), strideFloats apart (at least 3).<br>Calls [`sona_pose_vertices`](../c/the-data-api.md#sona_pose_vertices). |
| `SonaView CameraPreset(SonaPreset preset, SonaView view)` | Sets view->eye and view->target to one of the console's framings on one ready avatar.<br>Calls [`sona_camera_preset`](../c/camera-helpers.md#sona_camera_preset). |
| `bool TryGetJointWorld(int joint, float[] out16)` | A joint's world matrix at the last Update: row-vector, metres, the placement applied.<br>Calls [`sona_joint_world`](../c/game-features.md#sona_joint_world). |
| `void SetOverride(int joint, float x, float y, float z, float w, float weight = 1, SonaOverrideMode mode = SonaOverrideMode.Replace)` | A unit quaternion applied after the clip.<br>Calls [`sona_avatar_override`](../c/game-features.md#sona_avatar_override). |
| `void ClearOverride(int joint)` | A rotation applied after the clip each frame, for look-at and aiming.<br>Calls [`sona_avatar_override`](../c/game-features.md#sona_avatar_override). |
| `void ClearOverrides()` | Clears every override of the avatar.<br>Calls [`sona_avatar_clear_overrides`](../c/game-features.md#sona_avatar_clear_overrides). |
| `void Crossfade(string clip, float seconds, bool loop = true, float speed = 1, float from = 0)` | Play, blending from the current pose over seconds (0: a cut).<br>Calls [`sona_avatar_crossfade`](../c/game-features.md#sona_avatar_crossfade). |
| `void Queue(string clip, float fadeSeconds = 0, bool loop = true, float speed = 1, float from = 0)` | Plays clip when the current one ends.<br>Calls [`sona_avatar_queue`](../c/game-features.md#sona_avatar_queue). |
| `int QueuedCount` | How many clips are waiting in the queue.<br>Calls [`sona_avatar_queued`](../c/game-features.md#sona_avatar_queued). |
| `void PlayStock(uint clipId, float fadeSeconds = 0, bool? loop = null, float speed = 1, float from = 0)`<br>`void PlayStock(string clip, float fadeSeconds = 0, bool? loop = null, float speed = 1, float from = 0)` | A stock clip (SONA_STOCK_* id), the variant for this avatar's body; fadeSeconds > 0 crossfades.<br>Calls [`sona_avatar_play_stock`](../c/stock-clips.md#sona_avatar_play_stock). |
| `void SetIdle(SonaIdleOptions options)` | The procedural idle: blinks, glances, weight shifts and breathing over any clip; null turns it off.<br>Calls [`sona_avatar_idle`](../c/stock-clips.md#sona_avatar_idle). |
| `bool TryGetCapsule(out SonaCapsule capsule)` | A vertical capsule around the posed body, in world space.<br>Calls [`sona_avatar_capsule`](../c/game-features.md#sona_avatar_capsule). |
| `void SetExpression(byte mouth, byte leftEyebrow = SonaMouth.Clip, byte rightEyebrow = SonaMouth.Clip, byte leftEye = SonaMouth.Clip, byte rightEye = SonaMouth.Clip)` | Each a shape index (0 neutral) or SonaMouth.Clip (255) to leave that part as the clip has it.<br>Calls [`sona_avatar_expression`](../c/game-features.md#sona_avatar_expression). |
| `void ClearExpression()` | Hands the whole face back to the clip.<br>Calls [`sona_avatar_expression`](../c/game-features.md#sona_avatar_expression). |
| `static Native.sona_prop_attach PropAttachDefaults()` | size set; position 0, rotation 0 0 0 1, scale 1, hand_weight 1, fade_seconds 0.2, speed 1.<br>Calls [`sona_prop_attach_defaults`](../c/props-held-and-worn-objects.md#sona_prop_attach_defaults). |
| `uint AttachProp(SonaPropMesh mesh, Native.sona_prop_attach? options = null)` | Attaches a prop mesh; returns its id on this avatar.<br>Calls [`sona_avatar_prop_attach`](../c/props-held-and-worn-objects.md#sona_avatar_prop_attach). |
| `void SetProp(uint id, in Native.sona_prop_attach options)` | New placement, flags or hand for an attached prop (each frame for one that moves on the joint).<br>Calls [`sona_avatar_prop_set`](../c/props-held-and-worn-objects.md#sona_avatar_prop_set). |
| `void SwapProp(uint id, SonaPropMesh mesh)` | Another mesh in the same place: a sword for a stick, an item for a placeholder.<br>Calls [`sona_avatar_prop_swap`](../c/props-held-and-worn-objects.md#sona_avatar_prop_swap). |
| `Native.sona_prop_attach GetProp(uint id)` | What the prop was attached with, and its mesh (either may be NULL).<br>Calls [`sona_avatar_prop_get`](../c/props-held-and-worn-objects.md#sona_avatar_prop_get). |
| `void DetachProp(uint id)` | Takes the prop off at once (its hand's IK target eases off).<br>Calls [`sona_avatar_prop_detach`](../c/props-held-and-worn-objects.md#sona_avatar_prop_detach). |
| `void DetachAllProps()` | Takes every prop off the avatar at once.<br>Calls [`sona_avatar_prop_detach_all`](../c/props-held-and-worn-objects.md#sona_avatar_prop_detach_all). |
| `Native.sona_prop_frame PropFrame(uint id)` | One prop as the last update posed it; palette is valid until the next update.<br>Calls [`sona_avatar_prop_frame`](../c/props-held-and-worn-objects.md#sona_avatar_prop_frame). |
| `void PropVertices(uint id, uint mesh, bool world, float[] positions, float[] normals = null)` | CPU skinning of one of the prop's meshes: vertex_count positions (and normals), 3 floats each.<br>Calls [`sona_avatar_prop_vertices`](../c/props-held-and-worn-objects.md#sona_avatar_prop_vertices). |
| `static Native.sona_ik_target IkTargetDefaults()` | size set, no flags, position 0, rotation (0, 0, 0, 1), joint -1, weight 1, and the fade a default of 0.2 s.<br>Calls [`sona_ik_target_defaults`](../c/inverse-kinematics.md#sona_ik_target_defaults). |
| `static Native.sona_ik_feet IkFeetDefaults()` | SONA_IK_GROUND_PLANE with the plane y = 0, weight 1, hips offset at most 0.45 m, tilt at most 35 degrees, and the smoothing a default of 0.1 s.<br>Calls [`sona_ik_feet_defaults`](../c/inverse-kinematics.md#sona_ik_feet_defaults). |
| `static Native.sona_ik_look IkLookDefaults()` | Its defaults are head and eyes, weight 1, yaw 70, up 35, down 45 degrees, smoothing by default 0.15 s, a turn rate of 360 degrees a second, eyes past 10.<br>Calls [`sona_ik_look_defaults`](../c/inverse-kinematics.md#sona_ik_look_defaults). |
| `static Native.sona_ik_limits IkLimitsDefaults()` | Elbows 145, knees 150, wrists 75 swing and 80 twist, ankles 45 and 30 degrees, hips 120 forward, 25 behind, 45 out and 25 in, shoulders 45 behind (held level) and 50 across, reach easing from 0.97, a 0.02 m body margin,<br>Calls [`sona_ik_limits_defaults`](../c/inverse-kinematics.md#sona_ik_limits_defaults). |
| `void SetIkTarget(uint limb, in Native.sona_ik_target target)` | A hand or foot target (Native.SONA_IK_LEFT_HAND..<br>Calls [`sona_avatar_ik_target`](../c/inverse-kinematics.md#sona_avatar_ik_target). |
| `void ClearIkTarget(uint limb)` | A hand puts its palm (with SONA_IK_WRIST its wrist) at position; a foot its ankle.<br>Calls [`sona_avatar_ik_target`](../c/inverse-kinematics.md#sona_avatar_ik_target). |
| `void SetIkFeet(in Native.sona_ik_feet options, Native.IkGroundFn ground = null)` | Foot planting.<br>Calls [`sona_avatar_ik_feet`](../c/inverse-kinematics.md#sona_avatar_ik_feet). |
| `void ClearIkFeet()` | Plants the feet on the ground given by ground: SONA_IK_GROUND_PLANE (plane: n.x, n.y, n.z, d, world), SONA_IK_GROUND_POINTS (sona_avatar_ik_ground per foot) or SONA_IK_GROUND_CALLBACK (query, a downward ray<br>Calls [`sona_avatar_ik_feet`](../c/inverse-kinematics.md#sona_avatar_ik_feet). |
| `void SetIkGround(uint foot, float px, float py, float pz, float nx, float ny, float nz)` | SONA_IK_GROUND_POINTS: the ground under one foot this frame.<br>Calls [`sona_avatar_ik_ground`](../c/inverse-kinematics.md#sona_avatar_ik_ground). |
| `void SetIkLook(in Native.sona_ik_look options)` | Turns the chest, neck and head towards the world point target inside the limits, eased; the eyes take the rest through the face's look shapes when it has them.<br>Calls [`sona_avatar_ik_look`](../c/inverse-kinematics.md#sona_avatar_ik_look). |
| `void ClearIkLook()` | Turns the chest, neck and head towards the world point target inside the limits, eased; the eyes take the rest through the face's look shapes when it has them.<br>Calls [`sona_avatar_ik_look`](../c/inverse-kinematics.md#sona_avatar_ik_look). |
| `static Native.sona_style StyleDefaults()` | The original look, no outline, every parameter at its default.<br>Calls [`sona_style_defaults`](../c/art-styles.md#sona_style_defaults). |
| `void SetStyle(in Native.sona_style style)` | The avatar's own art style, from the next frame.<br>Calls [`sona_avatar_set_style`](../c/art-styles.md#sona_avatar_set_style). |
| `void ClearStyle()` | Back to the renderer's style.<br>Calls [`sona_avatar_set_style`](../c/art-styles.md#sona_avatar_set_style). |
| `void SetIkLimits(in Native.sona_ik_limits limits)` | The joint limits for this avatar's solves.<br>Calls [`sona_avatar_ik_limits`](../c/inverse-kinematics.md#sona_avatar_ik_limits). |
| `void ClearIk()` | Every target, the planting and the look-at off at once.<br>Calls [`sona_avatar_ik_clear`](../c/inverse-kinematics.md#sona_avatar_ik_clear). |
| `void SetPlaceholder(int mode)` | Its loading placeholder: -1 follows the context, 0 never, 1 always.<br>Calls [`sona_avatar_placeholder`](../c/loading-placeholders.md#sona_avatar_placeholder). |
| `Native.sona_placeholder_info PlaceholderInfo()` | The avatar's figure at the last sona_update: its phase, opacity, height, which figure (male, female or neutral), whether it plays the avatar's clip, the seconds since the avatar was added and whether it is drawn as a s<br>Calls [`sona_avatar_placeholder_info`](../c/loading-placeholders.md#sona_avatar_placeholder_info). |
| `void SetManifest(byte[] manifest)` | The manifest of an avatar added with AddWaiting, once.<br>Calls [`sona_avatar_set_manifest`](../c/loading-placeholders.md#sona_avatar_set_manifest). |
| `void SetManifestBase64(string base64)` | sona_avatar_set_manifest with the manifest as base64 text.<br>Calls [`sona_avatar_set_manifest_base64`](../c/loading-placeholders.md#sona_avatar_set_manifest_base64). |
| `bool TryGetIkStatus(out Native.sona_ik_status status)` | What the last pose did; false before the avatar was posed with IK on.<br>Calls [`sona_avatar_ik_status`](../c/inverse-kinematics.md#sona_avatar_ik_status). |
| `static Native.sona_ragdoll_options RagdollDefaults()` | size set; coverage 0.9.<br>Calls [`sona_ragdoll_defaults`](../c/ragdolls.md#sona_ragdoll_defaults). |
| `Native.sona_ragdoll_body[] Ragdoll(in Native.sona_ragdoll_options options)`<br>`Native.sona_ragdoll_body[] Ragdoll()` | The bodies fitted to this avatar now: colliders, masses and the joints to their parents.<br>Calls [`sona_avatar_ragdoll`](../c/ragdolls.md#sona_avatar_ragdoll). |
| `bool TryGetRagdollState(Native.sona_ragdoll_state[] bodies)` | The bodies at the last pose with their velocities; false before Ragdoll.<br>Calls [`sona_avatar_ragdoll_state`](../c/ragdolls.md#sona_avatar_ragdoll_state). |
| `void RagdollDrive(Native.sona_ragdoll_state[] bodies, float weight = 1, uint flags = 0)` | The host's simulated bodies onto the avatar from the next pose; weight 0..1 blends from the clip.<br>Calls [`sona_avatar_ragdoll_drive`](../c/ragdolls.md#sona_avatar_ragdoll_drive). |
| `void RagdollRelease(float blendSeconds)` | Back to the clip, blending from the last ragdoll pose over blendSeconds.<br>Calls [`sona_avatar_ragdoll_release`](../c/ragdolls.md#sona_avatar_ragdoll_release). |
| `bool TryGetRagdollInfo(out Native.sona_ragdoll_info info)` | SONA_E_NOT_READY before the avatar has been posed since sona_avatar_ragdoll.<br>Calls [`sona_avatar_ragdoll_info`](../c/ragdolls.md#sona_avatar_ragdoll_info). |
| `void RagdollClear()` | Off at once: no tracking, no drive, no blend.<br>Calls [`sona_avatar_ragdoll_clear`](../c/ragdolls.md#sona_avatar_ragdoll_clear). |
| `static Native.sona_sway SwayDefaults()` | Parts SONA_SWAY_DEFAULT, medium quality, stiffness and damping 0.5, wind scale 1, 48 minimum pixels.<br>Calls [`sona_sway_defaults`](../c/hair-and-cloth-sway.md#sona_sway_defaults). |
| `void SetSway(in Native.sona_sway options)` | Hair and cloth sway on, with these options; throws ARGUMENT for a value out of range.<br>Calls [`sona_avatar_sway`](../c/hair-and-cloth-sway.md#sona_avatar_sway). |
| `void ClearSway()` | Turns sway on with these options, before or after READY (it applies to every later build too).<br>Calls [`sona_avatar_sway`](../c/hair-and-cloth-sway.md#sona_avatar_sway). |
| `void ResetSway()` | Back to the modelled shape, at rest, at the next pose.<br>Calls [`sona_avatar_sway_reset`](../c/hair-and-cloth-sway.md#sona_avatar_sway_reset). |
| `bool TryGetSwayInfo(out Native.sona_sway_info info)` | What sways and what the last pose did; false before READY.<br>Calls [`sona_avatar_sway_info`](../c/hair-and-cloth-sway.md#sona_avatar_sway_info). |
| `uint SwayMeshParts(uint mesh)` | The SONA_SWAY_* kinds one of sona_pose's meshes sways with; 0 for one that does not, a bad index, or an avatar with sway off or not READY.<br>Calls [`sona_avatar_sway_mesh_parts`](../c/hair-and-cloth-sway.md#sona_avatar_sway_mesh_parts). |
| `void SetMouth(byte shape)` | Only the mouth (a SonaMouth shape, or SonaMouth.Clip to hand it back); the same shape again does nothing.<br>Calls [`sona_avatar_mouth`](../c/lip-sync-and-voice-mouths.md#sona_avatar_mouth). |
| `void Voice(ref Native.sona_voice_mouth state, float level, float dt)` | Voice chat: this speaker's audio level (linear RMS) moves the mouth.<br>Calls [`sona_avatar_voice`](../c/lip-sync-and-voice-mouths.md#sona_avatar_voice). |
| `bool TryGetExpressionCounts(out int mouths, out int eyebrows, out int eyes)` | How many shapes this face has per part; 0 for a part it lacks.<br>Calls [`sona_avatar_expression_counts`](../c/game-features.md#sona_avatar_expression_counts). |
| `int ReadClipEvents(List<SonaClipEvent> into)` | Adds every clip event since the last call, oldest first, to into; returns how many.<br>Calls [`sona_avatar_clip_events`](../c/game-features.md#sona_avatar_clip_events). |
| `void Mark(float seconds, uint id)` | A Mark event with this id each time the current clip passes seconds; marks go when another clip starts.<br>Calls [`sona_avatar_mark`](../c/game-features.md#sona_avatar_mark). |
| `void ClearMarks()` | Removes the avatar's marks.<br>Calls [`sona_avatar_clear_marks`](../c/game-features.md#sona_avatar_clear_marks). |
| `void SetRootMotion(SonaRootMotion mode)` | What happens to the clip's sideways travel of the hips.<br>Calls [`sona_avatar_root_motion`](../c/game-features.md#sona_avatar_root_motion). |
| `void TakeRootMotion(out float dx, out float dy, out float dz)` | The travel collected since the last call, in world metres; clears it.<br>Calls [`sona_avatar_take_root_motion`](../c/game-features.md#sona_avatar_take_root_motion). |
| `void PlayLayer(int layer, string clip, SonaLayerOptions options = null)`<br>`void PlayLayer(int layer, SonaBlendSpace blend, SonaLayerOptions options = null)`<br>`void PlayLayer(int layer, SonaStateMachine machine, SonaLayerOptions options = null)` | Plays a clip key or raw clip id on a layer (0..7), over the avatar's own clip.<br>Calls [`sona_avatar_layer_play`](../c/animation-layers.md#sona_avatar_layer_play), [`sona_avatar_layer_blend`](../c/animation-layers.md#sona_avatar_layer_blend), [`sona_avatar_layer_machine`](../c/animation-layers.md#sona_avatar_layer_machine). |
| `void SetLayerWeight(int layer, float weight, float overSeconds = 0)` | Moves the layer's weight linearly to weight (0..1) over over_seconds; 0 or less sets it at once.<br>Calls [`sona_avatar_layer_weight`](../c/animation-layers.md#sona_avatar_layer_weight). |
| `void SetLayerMask(int layer, float[] mask)` | 72 weights 0..1, or null for every joint.<br>Calls [`sona_avatar_layer_mask`](../c/animation-layers.md#sona_avatar_layer_mask). |
| `void StopLayer(int layer, float fadeSeconds = 0.2f)` | Fades the layer out over fade_seconds and then empties it (a STOPPED event); 0 empties it now.<br>Calls [`sona_avatar_layer_stop`](../c/animation-layers.md#sona_avatar_layer_stop). |
| `void GotoState(int layer, int state, float fadeSeconds = 0.2f)` | Sends a machine layer to a state now, crossfading over fadeSeconds.<br>Calls [`sona_avatar_layer_goto`](../c/animation-layers.md#sona_avatar_layer_goto). |
| `SonaLayerInfo LayerInfo(int layer)` | The layer now: kind, mode, state (machines, else -1), clip (the sona_clip_get index, -1 for a raw id), weight with fades, time and normalized through the clip or cycle, ready (its clips have loaded) and<br>Calls [`sona_avatar_layer_info`](../c/animation-layers.md#sona_avatar_layer_info). |
| `int ReadLayerEvents(List<SonaLayerEvent> into)` | Adds every layer event since the last call, oldest first, to into; returns how many.<br>Calls [`sona_avatar_layer_events`](../c/animation-layers.md#sona_avatar_layer_events). |
| `void SetParam(int param, float value)` | Sets one parameter on the avatar; read at the next sona_update.<br>Calls [`sona_avatar_set_param`](../c/animation-layers.md#sona_avatar_set_param). |
| `void SetParams(int first, float[] values)` | Parameters first..<br>Calls [`sona_avatar_set_params`](../c/animation-layers.md#sona_avatar_set_params). |
| `float Param(int param)` | A parameter's value; 0 when unset or unknown.<br>Calls [`sona_avatar_param`](../c/animation-layers.md#sona_avatar_param). |
| `SonaLodStep Lod(out float fade)` | The LOD step at the last Update, and how far from mesh (0) to sprite (1).<br>Calls [`sona_avatar_lod`](../c/crowds-level-of-detail-and-sprites.md#sona_avatar_lod). |
| `SonaLodStep LodStep` | The level of detail it was drawn at last (sona_avatar_lod). |
| `bool TryGetPreviewBounds(float[] lo, float[] hi)` | The previewed item's world box.<br>Calls [`sona_item_preview_bounds`](../c/item-previews.md#sona_item_preview_bounds). |
| `bool TryGetPreviewView(uint width, uint height, out SonaView view)` | The framed camera for a width x height picture of this preview.<br>Calls [`sona_item_preview_view`](../c/item-previews.md#sona_item_preview_view). |

## SonaCapsule

`struct SonaCapsule`: A vertical capsule around the posed body, in world space, for collisions: the segment a..b and its radius. The C type sona_capsule.

| Declaration | What it does |
|---|---|
| `float AX` | The C field sona_capsule.a, one part (m (world units)). |
| `float AY` | The C field sona_capsule.a, one part (m (world units)). |
| `float AZ` | The C field sona_capsule.a, one part (m (world units)). |
| `float BX` | The C field sona_capsule.b, one part (m (world units)). |
| `float BY` | The C field sona_capsule.b, one part (m (world units)). |
| `float BZ` | The C field sona_capsule.b, one part (m (world units)). |
| `float Radius` | The C field sona_capsule.radius (m (world units)). |

## SonaClipEvent

`struct SonaClipEvent`: The C type sona_clip_event.

| Declaration | What it does |
|---|---|
| `SonaClipEventKind Kind` | The C field sona_clip_event.kind (one of the values named in the header). |
| `uint Mark` | The C field sona_clip_event.mark (index or id). |
| `int Clip` | The C field sona_clip_event.clip (index or id (-1: none)). |
| `float Time` | The C field sona_clip_event.time (s). |

## SonaJoints

`static unsafe class SonaJoints`: The value of SONA_JOINTS: palette slots; the avatar rig animates 71

| Declaration | What it does |
|---|---|
| `const int Count = Native.SONA_JOINT_COUNT - 1` | The joints the rig animates. |
| `static int Find(string name)` | "Hips", "Head", "PropRight", "shape_04" or "joint_33"; -1 when unknown.<br>Calls [`sona_joint_find`](../c/game-features.md#sona_joint_find). |
| `static string Name(int joint)` | null past the last joint.<br>Calls [`sona_joint_name`](../c/game-features.md#sona_joint_name). |

## SonaSkeletons

`static unsafe class SonaSkeletons`: The rig's joints under Unity Humanoid, VRM and Unreal mannequin bone names.

| Declaration | What it does |
|---|---|
| `static string Bone(SonaSkeleton skeleton, int joint)` | The bone a joint is in that skeleton; null for a joint it has none for.<br>Calls [`sona_skeleton_bone`](../c/skeleton-maps-and-vrm-export.md#sona_skeleton_bone). |
| `static int Joint(SonaSkeleton skeleton, string bone)` | The joint a bone of that skeleton is; -1 when none.<br>Calls [`sona_skeleton_joint`](../c/skeleton-maps-and-vrm-export.md#sona_skeleton_joint). |

## SonaExportOptions

`sealed class SonaExportOptions`: What sona_export_avatar writes.

| Declaration | What it does |
|---|---|
| `SonaExportFormat Format = SonaExportFormat.Vrm` | SONA_EXPORT_*; default SONA_EXPORT_VRM. The C field sona_export_options.format (one of the SONA_ values named). |
| `SonaExportFlags Flags` | SONA_EXPORT_* flags. The C field sona_export_options.flags (bit flags). |
| `SonaSkeleton BoneNames = SonaSkeleton.Unity` | The bones' node names, a sona_skeleton_kind (default UNITY); UE4 and UE5 add "root". The C field sona_export_options.bone_names (sona_skeleton_kind value). |
| `string Name` | The model's name; NULL: "Avatar". The C field sona_export_options.name (text (UTF-8), NULL: none). |
| `string Version` | NULL: none. The C field sona_export_options.version (text (UTF-8), NULL: none). |
| `string Authors` | One per line; NULL: "360sona". The C field sona_export_options.authors (text (UTF-8), NULL: none). |
| `string Copyright` | The C field sona_export_options.copyright (text (UTF-8), NULL: none). |
| `string Contact` | The C field sona_export_options.contact (text (UTF-8), NULL: none). |
| `string References` | One per line. The C field sona_export_options.references (text (UTF-8), NULL: none). |
| `string ThirdPartyLicences` | The C field sona_export_options.third_party_licences (text (UTF-8), NULL: none). |
| `string LicenceUrl` | NULL: the VRM Public License 1.0, https://vrm.dev/licenses/1.0/. The C field sona_export_options.licence_url (text (UTF-8), NULL: none). |
| `string OtherLicenceUrl` | The C field sona_export_options.other_licence_url (text (UTF-8), NULL: none). |
| `SonaVrmPermission AvatarPermission` | SONA_VRM_ONLY_AUTHOR (default), SEPARATELY_LICENSED, EVERYONE. The C field sona_export_options.avatar_permission (one of the SONA_ values named). |
| `SonaVrmCommercial CommercialUsage` | SONA_VRM_PERSONAL_NON_PROFIT (default), PERSONAL_PROFIT, CORPORATION. The C field sona_export_options.commercial_usage (one of the SONA_ values named). |
| `SonaVrmModification Modification` | SONA_VRM_MODIFY_PROHIBITED (default), ALLOWED, REDISTRIBUTION. The C field sona_export_options.modification (one of the SONA_ values named). |
| `SonaVrmAllow Allow` | SONA_VRM_ALLOW_* bits; 0: nothing allowed, credit required. The C field sona_export_options.allow (one of the SONA_ values named). |
| `byte[] ThumbnailPng` | A square PNG for the meta (sona_snapshot + sona_png_encode); NULL: none. The C field sona_export_options.thumbnail_png (pointer). |

## SonaExportReport

`struct SonaExportReport`: The C type sona_export_report.

| Declaration | What it does |
|---|---|
| `uint Meshes` | Degenerate triangles left out. The C field sona_export_report.meshes (count). |
| `uint Primitives` | Degenerate triangles left out. The C field sona_export_report.primitives (count). |
| `uint Vertices` | Degenerate triangles left out. The C field sona_export_report.vertices (count). |
| `uint Triangles` | Degenerate triangles left out. The C field sona_export_report.triangles (count). |
| `uint Degenerate` | Degenerate triangles left out. The C field sona_export_report.degenerate (count). |
| `uint Textures` | The C field sona_export_report.textures (count). |
| `uint Expressions` | The C field sona_export_report.expressions (count). |
| `uint AtlasCells` | The C field sona_export_report.atlas_cells (count). |
| `uint Baked` | Materials whose albedo chain was flattened into a new picture. The C field sona_export_report.baked (count). |
| `float BakeError` | The worst of those, in 0..255 levels (glb.js bakeError). The C field sona_export_report.bake_error (colour levels, 0 to 255). |
| `float Ms` | The C field sona_export_report.ms (ms). |

## SonaPreviewOptions

`sealed class SonaPreviewOptions`: The C type sona_preview_options.

| Declaration | What it does |
|---|---|
| `uint Gender` | 1 male, 2 female; 0: the body the item was made for (male when either). The C field sona_preview_options.gender (one of the values named in the header). |
| `uint Slot` | The category mask to frame by (0x40 hat, 0x38 costume,...); 0: from the item. The C field sona_preview_options.slot (index or id). |
| `SonaPreviewFlags Flags` | SONA_PREVIEW_*. The C field sona_preview_options.flags (bit flags). |
| `uint Skin` | 0xAARRGGBB; 0: the stand-in grey 0xff9a9a9a. The C field sona_preview_options.skin (colour, 0xAARRGGBB). |
| `uint[] Colours = new uint[3]` | 0xAARRGGBB primary, secondary, tertiary, with SONA_PREVIEW_COLOURS. The C field sona_preview_options.colours (colour, 0xAARRGGBB). |
| `int Priority` | Build order, as sona_add_options.priority. The C field sona_preview_options.priority (order (higher first)). |
| `float Time = -1` | Props: seconds into the clip to hold (or start at); negative: its fullest frame. The C field sona_preview_options.time (s). |
| `float Margin = 1.36f` | Room around the item: 1 touches the edges; 0: 1.36, as the web's item renders. The C field sona_preview_options.margin (factor (unitless)). |

## SonaPose

`readonly unsafe struct SonaPose`: The avatar's pose data, valid until the next sona_update.

| Declaration | What it does |
|---|---|
| `bool IsValid` | True until the next Update; a pose read after that throws. |
| `IntPtr Raw` | The native pointer this value wraps, for a call through Native that the friendly layer does not cover. |
| `uint BuildVersion` | Bumps when meshes, materials or textures change. The C field sona_pose_data.build_version (version number). |
| `float World(int i)` | W = scale * rotateY(turn) * translate(position), row-vector. The C field sona_pose_data.world (4x4 matrix, row-vector). |
| `void CopyWorld(float[] out16)` | Copies the avatar's 4x4 world matrix (sona_pose_data.world) into a float[16]. |
| `ReadOnlySpan<float> Palette` | 864 floats: per joint 3 float4, columns 0..2 of the row-vector skin matrix, in avatar space. |
| `IntPtr PalettePtr` | 864 floats: per joint 3 float4 = columns 0..2 of the row-vector skin matrix, in avatar space (view = identity). The C field sona_pose_data.palette (pointer). |
| `ReadOnlySpan<float> ViewJoints` | 72 * 3 floats: each joint's translation before W. The C field sona_pose_data.view_joints (pointer). |
| `int MeshCount` | The C field sona_pose_data.mesh_count (count). |
| `int MaterialCount` | The C field sona_pose_data.material_count (count). |
| `int TextureCount` | The C field sona_pose_data.texture_count (count). |
| `int PropCount` | Held props (up to 4), then one per swaying mesh with sway on (3.34):. The C field sona_pose_data.prop_count (count). |
| `byte Expression(int i)` | Mouth, left eyebrow, right eyebrow, left eye, right eye. The C field sona_pose_data.expression (expression index per face part). |
| `SonaMeshData Mesh(int i)` | The runtime vertex, 76 bytes, in host byte order: +0 float3 position (bind pose, avatar space) +12 uint8 x4 joint index * 3 (the palette's float4 row) +16 uint8 x4 weight (sum 255) +20 uint8 x4 normal, (n * 0.5 + 0.5) *  The C type sona_mesh. |
| `SonaMaterialData Material(int i)` | Address modes: bit 0 set = U wraps, bit 1 set = V wraps; clear = clamp. The C type sona_material. |
| `SonaTextureData Texture(int i)` | The C type sona_texture. |
| `SonaPropData Prop(int i)` | The i-th prop the avatar holds this frame (sona_pose_data.props). |

## SonaMeshData

`readonly unsafe struct SonaMeshData`: The runtime vertex, 76 bytes, in host byte order: +0 float3 position (bind pose, avatar space) +12 uint8 x4 joint index * 3 (the palette's float4 row) +16 uint8 x4 weight (sum 255) +20 uint8 x4 normal, (n * 0.5 + 0.5) *  The C type sona_mesh.

| Declaration | What it does |
|---|---|
| `string Item` | The item it came from. The C field sona_mesh.item (text (UTF-8)). |
| `uint Mask` | The item's AssetMask. The C field sona_mesh.mask (bit flags). |
| `uint Batch` | The C field sona_mesh.batch (count). |
| `int Material` | Index into sona_pose_data.materials. The C field sona_mesh.material (index or id). |
| `SonaPass Pass` | The C field sona_mesh.pass (sona_pass value). |
| `int Palette` | -1: the body palette; else an index into props. The C field sona_mesh.palette (index or id). |
| `int VertexCount` | The C field sona_mesh.vertex_count (count). |
| `int IndexCount` | The C field sona_mesh.index_count (count). |
| `uint Key` | Stable while the geometry lives; shared by avatars wearing the same item. The C field sona_mesh.key (index or id). |
| `IntPtr VerticesPtr` | Vertex_count * 76 bytes. The C field sona_mesh.vertices (pointer). |
| `IntPtr IndicesPtr` | Triangle list. The C field sona_mesh.indices (pointer). |
| `ReadOnlySpan<byte> Vertices` | VertexCount * 76 bytes, the runtime vertex of sona.h. |
| `ReadOnlySpan<ushort> Indices` | Triangle list. The C field sona_mesh.indices (pointer). |

## SonaMaterialData

`readonly unsafe struct SonaMaterialData`: Address modes: bit 0 set = U wraps, bit 1 set = V wraps; clear = clamp. The C type sona_material.

| Declaration | What it does |
|---|---|
| `uint ShaderId` | The app's material family, 0..4. The C field sona_material.shader_id (index or id). |
| `SonaMaterialFlags Flags` | SONA_MAT_*. The C field sona_material.flags (bit flags). |
| `float Param(int i)` | One of the material's 40 shader constants (sona_material.params). |
| `float Transparency` | The C field sona_material.transparency (factor (unitless)). |
| `int ColorTex` | Index into sona_pose_data.textures; -1: neutral white. The C field sona_material.color_tex (index or id (-1: neutral white)). |
| `int IntensityTex` | -1: neutral (0,0,0,255). The C field sona_material.intensity_tex (factor (unitless)). |
| `int DecalTex` | -1: neutral (0,0,0,255); the matcap for reflective materials. The C field sona_material.decal_tex (index or id (-1: none)). |
| `int ColorAddr` | The C field sona_material.color_addr (address mode bits (bit 0: U wraps, bit 1: V wraps)). |
| `int IntensityAddr` | The C field sona_material.intensity_addr (address mode bits (bit 0: U wraps, bit 1: V wraps)). |
| `int DecalAddr` | The C field sona_material.decal_addr (address mode bits (bit 0: U wraps, bit 1: V wraps)). |

## SonaTextureData

`readonly unsafe struct SonaTextureData`: The C type sona_texture.

| Declaration | What it does |
|---|---|
| `uint Key` | Stable while the texture lives; use it to cache uploads. The C field sona_texture.key (index or id). |
| `uint Version` | Bumps when the pixels change (the face sheet). The C field sona_texture.version (version number). |
| `SonaTexFormat Format` | The C field sona_texture.format (sona_tex_format value). |
| `int Width` | The C field sona_texture.width (px). |
| `int Height` | The C field sona_texture.height (px). |
| `IntPtr DataPtr` | Width * height * 4 bytes for RGBA8. The C field sona_texture.data (pointer). |
| `int Bytes` | The C field sona_texture.bytes (bytes). |
| `ReadOnlySpan<byte> Data` | Width * height * 4 bytes for RGBA8. The C field sona_texture.data (pointer). |

## SonaPropData

`readonly unsafe struct SonaPropData`: The meshes in the data API's own form (3.11), for hosts that draw props themselves: 76-byte vertices whose joint bytes index sona_prop_frame.palette (a host mesh uses joint 0 only), materials and textures. The C type sona_prop_data.

| Declaration | What it does |
|---|---|
| `string Item` | The id of the item the prop shows (sona_prop_palette.item). |
| `bool Playing` | True while the prop is drawn; false hides its meshes (sona_prop_palette.playing). |
| `IntPtr PalettePtr` | The C type sona_prop_palette. |
| `ReadOnlySpan<float> Palette` | The C type sona_prop_palette. |

## SonaRenderer

`sealed unsafe class SonaRenderer : IDisposable`: The C type sona_renderer.

| Declaration | What it does |
|---|---|
| `ulong FrameIndex` | The index of the last frame recorded (0 before the first).<br>Calls [`sona_renderer_frame_index`](../c/drawing-with-the-sdks-backends.md#sona_renderer_frame_index). |
| `void FrameDone(ulong completedFrame)` | Vulkan, D3D12 and Metal: every frame up to and including completed_frame has finished on the GPU.<br>Calls [`sona_renderer_frame_done`](../c/drawing-with-the-sdks-backends.md#sona_renderer_frame_done). |
| `void Lost()` | After a device loss: forget every GPU object.<br>Calls [`sona_renderer_lost`](../c/drawing-with-the-sdks-backends.md#sona_renderer_lost). |
| `SonaResult Reset(in Native.sona_device_desc device)` | Starts the renderer again on a new device of the same backend, after sona_renderer_lost.<br>Calls [`sona_renderer_reset`](../c/drawing-with-the-sdks-backends.md#sona_renderer_reset). |
| `SonaResult Draw(in SonaView view, in Native.sona_target target, SonaDrawFlags flags = SonaDrawFlags.None, SonaCorner creditCorner = SonaCorner.BottomRight)` | Returns PENDING (no throw) when frames_in_flight frames are outstanding.<br>Calls [`sona_draw`](../c/drawing-with-the-sdks-backends.md#sona_draw). |
| `byte[] Snapshot(in SonaView view, uint width, uint height, SonaDrawFlags flags = SonaDrawFlags.None)` | Straight RGBA8, row 0 at the top.<br>Calls [`sona_snapshot`](../c/drawing-with-the-sdks-backends.md#sona_snapshot). |
| `static Native.sona_quality QualityDefaults()` | The web SDK's defaults: msaa = SONA_MSAA_AUTO, flags = SONA_QUALITY_MIPS \| SONA_QUALITY_CUTOUT_MIPS.<br>Calls [`sona_quality_defaults`](../c/rendering-quality.md#sona_quality_defaults). |
| `bool TryGetStyle(out Native.sona_style style)` | False when this renderer's backend draws no art styles (then style is the defaults).<br>Calls [`sona_renderer_style`](../c/art-styles.md#sona_renderer_style). |
| `void SetStyle(in Native.sona_style style)` | The art style of every avatar without its own (with SONA_STYLE_OVERRIDE, of every avatar), from the next draw.<br>Calls [`sona_renderer_set_style`](../c/art-styles.md#sona_renderer_set_style). |
| `void ClearStyle()` | The style of every avatar this renderer draws that has none of its own (with SONA_STYLE_OVERRIDE, of every avatar), from the next sona_draw or sona_snapshot.<br>Calls [`sona_renderer_set_style`](../c/art-styles.md#sona_renderer_set_style). |
| `void SetQuality()`<br>`void SetQuality(in Native.sona_quality quality)` | The web SDK's: SONA_MSAA_AUTO, Mips \| CutoutMips.<br>Calls [`sona_renderer_set_quality`](../c/rendering-quality.md#sona_renderer_set_quality). |
| `static Native.sona_lighting LightingDefaults()` | sona_lighting_defaults: a key and fill switched off, the built-in environment, a fitted shadow map.<br>Calls [`sona_lighting_defaults`](../c/lighting-and-shadows.md#sona_lighting_defaults). |
| `void SetLighting(in Native.sona_lighting lighting)` | The host's lights from the next draw.<br>Calls [`sona_renderer_set_lighting`](../c/lighting-and-shadows.md#sona_renderer_set_lighting). |
| `void ClearLighting()` | No lighting: the original look again, byte for byte.<br>Calls [`sona_renderer_set_lighting`](../c/lighting-and-shadows.md#sona_renderer_set_lighting). |
| `void SetEnvironmentSh(float[] sh9, float skinRed = 1.2f)` | The lit avatars' environment as 9 RGB spherical harmonics of radiance; null: the built-in cube.<br>Calls [`sona_renderer_set_environment`](../c/lighting-and-shadows.md#sona_renderer_set_environment), [`sona_environment_defaults`](../c/lighting-and-shadows.md#sona_environment_defaults). |
| `void SetHostShadow(in Native.sona_host_shadow shadow)` | The host's own shadow map on the lit avatars from the next draw: its depth texture (u.vk, u.gl, u.d3d11 or u.d3d12) and the matrix from a world point to (u, v, depth, w).<br>Calls [`sona_renderer_set_host_shadow`](../c/lighting-and-shadows.md#sona_renderer_set_host_shadow). |
| `void ClearHostShadow()` | No host map: the lit avatars take only their own.<br>Calls [`sona_renderer_set_host_shadow`](../c/lighting-and-shadows.md#sona_renderer_set_host_shadow). |
| `SonaResult DrawPreview(SonaAvatar preview, in Native.sona_target target, SonaDrawFlags flags = SonaDrawFlags.None, SonaCorner creditCorner = SonaCorner.BottomRight)`<br>`SonaResult DrawPreview(SonaAvatar preview, in SonaView view, in Native.sona_target target, SonaDrawFlags flags = SonaDrawFlags.None, SonaCorner creditCorner = SonaCorner.BottomRight)` | Draws only this preview, framed for the target's size.<br>Calls [`sona_item_preview_draw`](../c/item-previews.md#sona_item_preview_draw). |
| `byte[] SnapshotPreview(SonaAvatar preview, uint width, uint height, SonaDrawFlags flags = SonaDrawFlags.None)` | Straight RGBA8 of only this preview, framed by its slot, row 0 at the top.<br>Calls [`sona_item_preview_snapshot`](../c/item-previews.md#sona_item_preview_snapshot). |
| `static Native.sona_sticker_options StickerDefaults()` | size set, pixels 512, time -1, framing SONA_PRESET_FULL, outline_px 10, outline 0xffffffff, shadow 0x59000000 (off while shadow_px is 0), padding 8.<br>Calls [`sona_sticker_defaults`](../c/2d-outputs.md#sona_sticker_defaults). |
| `static Native.sona_sheet_options SheetDefaults()` | size set, 8 frames, 8 directions, px_per_metre 64, padding 2, max_page 4096, draw_flags SONA_DRAW_NO_BLOOM; every other field 0 (the whole clip, facing the camera first, side on, orthographic, packed and trim<br>Calls [`sona_sheet_defaults`](../c/2d-outputs.md#sona_sheet_defaults). |
| `SonaPicture Sticker(SonaAvatar avatar, in Native.sona_sticker_options options, string clip = null)` | A transparent, outlined cut-out.<br>Calls [`sona_sticker`](../c/2d-outputs.md#sona_sticker). |
| `SonaSheet RenderSheet(SonaAvatar avatar, in Native.sona_sheet_options options, string clip = null, string name = null, Native.sona_pixel_options? pixel = null)` | A sprite sheet of the clip at frames x directions.<br>Calls [`sona_sheet_render`](../c/2d-outputs.md#sona_sheet_render). |
| `void Dispose()` | Frees the renderer and its GPU objects.<br>Calls [`sona_renderer_destroy`](../c/drawing-with-the-sdks-backends.md#sona_renderer_destroy). |

## SonaPicture

`sealed class SonaPicture`: A straight RGBA8 picture, row 0 at the top.

| Declaration | What it does |
|---|---|
| `byte[] Rgba` | Straight RGBA8, row 0 at the top; free with sona_free unless a call says otherwise. The C field sona_picture.rgba (pointer). |
| `uint Width` | The C field sona_picture.width (px). |
| `uint Height` | The C field sona_picture.height (px). |

## SonaSheet

`sealed unsafe class SonaSheet : IDisposable`: A rendered sprite sheet: pages, frames and their atlases.

| Declaration | What it does |
|---|---|
| `uint PageCount` | The number of pages; 0 for NULL.<br>Calls [`sona_sheet_page_count`](../c/2d-outputs.md#sona_sheet_page_count). |
| `uint FrameCount` | frames * directions; 0 for NULL.<br>Calls [`sona_sheet_frame_count`](../c/2d-outputs.md#sona_sheet_frame_count). |
| `SonaPicture Page(uint page)` | A copy of one page's pixels.<br>Calls [`sona_sheet_page`](../c/2d-outputs.md#sona_sheet_page). |
| `Native.sona_sheet_frame Frame(uint index)` | One frame (index = direction * frames + frame): its page and rectangle, where the rectangle sits in the full cell (trim_x, trim_y), the cell's size, the pivot (the avatar's feet) in the cell, its direction, facing, t<br>Calls [`sona_sheet_frame_get`](../c/2d-outputs.md#sona_sheet_frame_get). |
| `string Atlas(uint format, uint page, string image)` | The atlas JSON: Native.SONA_ATLAS_ASEPRITE or _TEXTUREPACKER, one page (or SONA_ATLAS_ALL_PAGES with TexturePacker); image names the page file ("{n}" becomes the page number).<br>Calls [`sona_sheet_atlas`](../c/2d-outputs.md#sona_sheet_atlas), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `void Dispose()` | Frees the sheet, its pages and frames.<br>Calls [`sona_sheet_free`](../c/2d-outputs.md#sona_sheet_free). |

## SonaItem

`sealed class SonaItem`: One catalogue item: its id, name, slot and flags (sona_item_info).

| Declaration | What it does |
|---|---|
| `Native.sona_guid Guid` | The C field sona_item_info.guid (a sona_guid (see its fields)). |
| `string Id` | Lowercase text form. The C field sona_item_info.id (text (UTF-8)). |
| `SonaItemKind Kind` | SONA_ITEM_KIND_*. The C field sona_item_info.kind (one of the SONA_ values named). |
| `int Gender` | 1 male, 2 female, 3 both, 0 not stated. The C field sona_item_info.gender (one of the values named in the header). |
| `SonaSection Section` | Sona_section. The C field sona_item_info.section (sona_section value). |
| `uint Mask` | AssetMask: the slot bits. The C field sona_item_info.mask (bit flags). |
| `SonaItemFlags Flags` | SONA_ITEM_*. The C field sona_item_info.flags (bit flags). |
| `SonaRoute Route` | Where sona_manifest_wear puts it, as sona_slot_of. The C field sona_item_info.route (sona_route value). |
| `uint ColourSet` | The palette it tints from; 0 when not SONA_ITEM_COLOURABLE. The C field sona_item_info.colour_set (one of the SONA_ values named). |
| `string Name` | The C field sona_item_info.name (text (UTF-8), NULL: none). |
| `string Game` | The game or source it comes from. The C field sona_item_info.game (text (UTF-8), NULL: none). |
| `string Type` | "Shirt/Hoodie". The C field sona_item_info.type (text (UTF-8), NULL: none). |
| `string Family` | "Shirt". The C field sona_item_info.family (text (UTF-8), NULL: none). |
| `string Description` | How an award is earned. The C field sona_item_info.description (text (UTF-8), NULL: none). |
| `int Subcategory` | The type as a number; 0 when none. The C field sona_item_info.subcategory (one of the values named in the header). |
| `int ColourChoices` | Colourways in its own colour table; 0 when not stated. The C field sona_item_info.colour_choices (count). |
| `int TextureType` | 255 when not stated. The C field sona_item_info.texture_type (one of the values named in the header). |
| `int ShapeType` | 255 when not stated. The C field sona_item_info.shape_type (one of the values named in the header). |

## SonaCatalogueQuery

`sealed class SonaCatalogueQuery`: The C type sona_catalogue_query.

| Declaration | What it does |
|---|---|
| `string Text` | words that must all be in the name, game or type (ASCII case folded); "in quotes" matches the whole name. The C field sona_catalogue_query.text (text (UTF-8), NULL: none). |
| `string Game` | That game only (ASCII case folded); NULL: any. The C field sona_catalogue_query.game (text (UTF-8), NULL: none). |
| `uint Slots` | AssetMask bits: items with any of them; 0: any. The C field sona_catalogue_query.slots (bit flags). |
| `SonaSection Section` | Sona_section; 0: any. The C field sona_catalogue_query.section (one of the values named in the header). |
| `uint Gender` | 1 or 2: what the editor offers that body; 0: any. The C field sona_catalogue_query.gender (one of the values named in the header). |
| `SonaItemFlags Require` | SONA_ITEM_* that must all be set. The C field sona_catalogue_query.require (one of the SONA_ values named). |
| `SonaItemFlags Exclude` | SONA_ITEM_* that must all be clear. The C field sona_catalogue_query.exclude (one of the SONA_ values named). |
| `uint Offset` | Skip this many matches, for paging. The C field sona_catalogue_query.offset (m (world units)). |

## SonaCatalogue

`sealed unsafe class SonaCatalogue : IDisposable`: sona-catalogue.bin: every item id with its name, slots, game and source.

| Declaration | What it does |
|---|---|
| `static SonaCatalogue Load(string path, SonaContext ctx = null)` | ctx may be null: then malloc is used and an error carries only its code.<br>Calls [`sona_catalogue_load`](../c/the-offline-catalogue.md#sona_catalogue_load). |
| `static SonaCatalogue LoadMemory(byte[] bytes, SonaContext ctx = null)` | The same from bytes in memory.<br>Calls [`sona_catalogue_load_memory`](../c/the-offline-catalogue.md#sona_catalogue_load_memory). |
| `IntPtr Handle` | The native handle this object owns, for a call the binding does not wrap. |
| `bool IsDisposed` | True once Dispose has run; every other call then throws. |
| `int Count` | Items, sorted by id.<br>Calls [`sona_catalogue_count`](../c/the-offline-catalogue.md#sona_catalogue_count). |
| `string Generated` | When its data was made, ISO 8601.<br>Calls [`sona_catalogue_generated`](../c/the-offline-catalogue.md#sona_catalogue_generated). |
| `SonaItem Get(int index)` | One item.<br>Calls [`sona_catalogue_get`](../c/the-offline-catalogue.md#sona_catalogue_get). |
| `int Find(string id)`<br>`int Find(in Native.sona_guid id)` | 32 hex digits, with or without dashes, braces or spaces, any case.<br>Calls [`sona_catalogue_find`](../c/the-offline-catalogue.md#sona_catalogue_find), [`sona_catalogue_find_guid`](../c/the-offline-catalogue.md#sona_catalogue_find_guid). |
| `int[] Search(SonaCatalogueQuery query, int max, out int total)`<br>`int[] Search(SonaCatalogueQuery query, int max = int.MaxValue)` | Matching indexes in id order, up to max, after query.Offset; total is every match.<br>Calls [`sona_catalogue_search`](../c/the-offline-catalogue.md#sona_catalogue_search). |
| `int GameCount` | The games items come from, sorted by name.<br>Calls [`sona_catalogue_game_count`](../c/the-offline-catalogue.md#sona_catalogue_game_count). |
| `string Game(int index, out int items)` | One game, sorted by name, and its item count.<br>Calls [`sona_catalogue_game`](../c/the-offline-catalogue.md#sona_catalogue_game). |
| `static string SectionName(SonaSection section)` | "shirt", "facialHair",...; null past the last section.<br>Calls [`sona_catalogue_section_name`](../c/the-offline-catalogue.md#sona_catalogue_section_name). |
| `void Dispose()` | Frees it and every string it handed out.<br>Calls [`sona_catalogue_free`](../c/the-offline-catalogue.md#sona_catalogue_free). |

## SonaFilterChange

`sealed class SonaFilterChange`: The C type sona_filter_change.

| Declaration | What it does |
|---|---|
| `Native.sona_guid From` | The denied item. The C field sona_filter_change.from (a sona_guid (see its fields)). |
| `Native.sona_guid To` | What took its place (zero when HIDDEN, or for the head's own shape). The C field sona_filter_change.to (a sona_guid (see its fields)). |
| `bool Replaced` | True when the item was swapped for another; false when it was hidden. |
| `uint Reason` | SONA_CONTENT_BY_*. The C field sona_filter_change.reason (one of the SONA_ values named). |
| `string Tag` | As sona_filter_verdict.tag. The C field sona_filter_change.tag (index or id (-1: none)). |
| `SonaSection Section` | The denied item's. The C field sona_filter_change.section (one of the values named in the header). |

## SonaFilter

`sealed unsafe class SonaFilter : IDisposable`: Which items a game allows: by section, slot, game, tag, source or id.

| Declaration | What it does |
|---|---|
| `static SonaFilter Create(SonaCatalogue cat, SonaContext ctx = null)` | cat may be null: then only id, slot, section and source rules can match.<br>Calls [`sona_filter_create`](../c/content-filters.md#sona_filter_create). |
| `IntPtr Handle` | The native handle this object owns, for a call the binding does not wrap. |
| `int AllowedCount` | Catalogue items allowed.<br>Calls [`sona_filter_allowed_count`](../c/content-filters.md#sona_filter_allowed_count). |
| `void Reset()` | Every rule goes; tags stay.<br>Calls [`sona_filter_reset`](../c/content-filters.md#sona_filter_reset). |
| `void Preset(SonaContentPreset preset)` | Adds a preset's rules (SONA_FILTER_PRESET_*).<br>Calls [`sona_filter_preset`](../c/content-filters.md#sona_filter_preset). |
| `void Sections(bool allow, uint sectionBits)` | Adds a rule on sections: bits (1u << sona_section).<br>Calls [`sona_filter_sections`](../c/content-filters.md#sona_filter_sections). |
| `void Slots(bool allow, uint slots)` | Adds a rule on slots (AssetMask bits): an item matches when it covers any of them.<br>Calls [`sona_filter_slots`](../c/content-filters.md#sona_filter_slots). |
| `void Sources(bool allow, uint sources)` | Adds a rule on where items come from (SONA_CONTENT_STOCK and the other source bits).<br>Calls [`sona_filter_sources`](../c/content-filters.md#sona_filter_sources). |
| `void Game(bool allow, string game)` | A game as sona_catalogue_game names it (ASCII case folded).<br>Calls [`sona_filter_game`](../c/content-filters.md#sona_filter_game). |
| `void Tag(bool allow, string tag)` | A tag by name ("weapon", "logo", or one the host defined).<br>Calls [`sona_filter_tag`](../c/content-filters.md#sona_filter_tag). |
| `void Item(bool allow, Native.sona_guid id)` | Adds a rule on one item by id.<br>Calls [`sona_filter_item`](../c/content-filters.md#sona_filter_item). |
| `void Load(string json)` | Rules from JSON ([Content filters](../../guides/filters.md)); all or nothing.<br>Calls [`sona_filter_load`](../c/content-filters.md#sona_filter_load). |
| `int TagCount` | How many tags the filter knows, built-in and host-defined.<br>Calls [`sona_filter_tag_count`](../c/content-filters.md#sona_filter_tag_count). |
| `string TagName(int tag)` | NULL past the last.<br>Calls [`sona_filter_tag_name`](../c/content-filters.md#sona_filter_tag_name). |
| `int TagItems(int tag)` | How many catalogue items carry a tag.<br>Calls [`sona_filter_tag_items`](../c/content-filters.md#sona_filter_tag_items). |
| `int TagFind(string name)` | -1 when unknown.<br>Calls [`sona_filter_tag_find`](../c/content-filters.md#sona_filter_tag_find). |
| `int TagDefine(string name)` | A new tag (a name of 1 to 31 bytes of a-z, 0-9 and '-'), or the index of the one of that name.<br>Calls [`sona_filter_tag_define`](../c/content-filters.md#sona_filter_tag_define). |
| `void TagSet(Native.sona_guid id, int tag, bool on)` | Puts a tag on an item (on 1) or takes it off (0), for ids in the catalogue or not.<br>Calls [`sona_filter_tag_set`](../c/content-filters.md#sona_filter_tag_set). |
| `ulong ItemTags(Native.sona_guid id)` | The bits of an item's tags (bit n is tag n).<br>Calls [`sona_filter_item_tags`](../c/content-filters.md#sona_filter_item_tags). |
| `bool Allows(Native.sona_guid id)` | 1 when the item is allowed; a NULL filter allows everything.<br>Calls [`sona_filter_allows`](../c/content-filters.md#sona_filter_allows). |
| `Native.sona_filter_verdict Check(Native.sona_guid id)` | Whether the item is allowed, and if not, which rule denied it (SONA_CONTENT_BY_*) and the item's tags.<br>Calls [`sona_filter_check`](../c/content-filters.md#sona_filter_check). |
| `int[] Search(SonaCatalogue cat, SonaSection section, int max, out int total)` | sona_catalogue_search, allowed items only.<br>Calls [`sona_filter_search`](../c/content-filters.md#sona_filter_search). |
| `List<SonaFilterChange> FilterManifest(byte[] manifest)` | The 1000 manifest bytes through the filter, in place; the changes it made.<br>Calls [`sona_filter_manifest_bytes`](../c/content-filters.md#sona_filter_manifest_bytes). |
| `static void SetOn(SonaContext ctx, SonaFilter f)` | Gives ctx a copy: every avatar it reads from then on goes through it.<br>Calls [`sona_ctx_set_filter`](../c/content-filters.md#sona_ctx_set_filter). |
| `static List<SonaFilterChange> ReportOf(SonaAvatar a)` | What the ctx's filter changed on an avatar; null before its manifest is read or with no filter then.<br>Calls [`sona_avatar_filter_report`](../c/content-filters.md#sona_avatar_filter_report). |
| `void Dispose()` | Frees the filter.<br>Calls [`sona_filter_free`](../c/content-filters.md#sona_filter_free). |

## SonaCamera

`static unsafe class SonaCamera`: Camera helpers: the preset views of an avatar (full, upper, bust, face), an orbit and a crowd fit (sona_camera_preset, sona_camera_orbit, sona_camera_fit_crowd).

| Declaration | What it does |
|---|---|
| `static SonaView Orbit(SonaView view, double tx, double ty, double tz, double yawDeg, double pitchDeg, double distance)` | Places the eye on an orbit around target.<br>Calls [`sona_camera_orbit`](../c/camera-helpers.md#sona_camera_orbit). |
| `static void ViewMatrices(in SonaView view, float[] viewM, float[] projM)` | Row-vector view and projection (D3D depth 0..1), 16 floats each.<br>Calls [`sona_view_matrices`](../c/camera-helpers.md#sona_view_matrices). |
| `static byte[] ShaderSource(SonaShaderLang lang, SonaProgram program, int stage)` | Text, or SPIR-V bytes; null when that language is not in this build.<br>Calls [`sona_shader_source`](../c/the-data-api.md#sona_shader_source). |

## SonaStockClip

`sealed class SonaStockClip`: The C type sona_stock_clip.

| Declaration | What it does |
|---|---|
| `uint Id` | SONA_STOCK_*. The C field sona_stock_clip.id (one of the SONA_ values named). |
| `string Name` | "wave", "laugh_female": unique, lower case. The C field sona_stock_clip.name (text (UTF-8), NULL: none). |
| `string Family` | "laugh": one action across its body variants and copies. The C field sona_stock_clip.family (text (UTF-8), NULL: none). |
| `string AssetId` | "00400000-0007-0003-c1c8-f109a19cb2e0", for sona_avatar_play. The C field sona_stock_clip.asset_id (text (UTF-8), NULL: none). |
| `string Caption` | A short description. The C field sona_stock_clip.caption (text (UTF-8), NULL: none). |
| `SonaClipTags Tags` | SONA_CLIP_TAG_*. The C field sona_stock_clip.tags (one of the SONA_ values named). |
| `int Body` | 1 male, 2 female, 3 both. The C field sona_stock_clip.body (one of the values named in the header). |
| `uint Frames` | The C field sona_stock_clip.frames (count). |
| `float Fps` | The C field sona_stock_clip.fps (frames per second). |
| `float Seconds` | Frames / fps. The C field sona_stock_clip.seconds (s). |
| `uint SameAs` | The clip this one copies (SONA_CLIP_TAG_COPY), else 0. The C field sona_stock_clip.same_as (one of the SONA_ values named). |
| `override string ToString()` | A readable line for logs. |

## SonaIdleOptions

`sealed class SonaIdleOptions`: The C type sona_idle_options.

| Declaration | What it does |
|---|---|
| `SonaIdleParts Parts = SonaIdleParts.All` | SONA_IDLE_*; default SONA_IDLE_ALL. The C field sona_idle_options.parts (one of the SONA_ values named). |
| `uint Seed` | 0: from the ctx seed and the avatar id. The C field sona_idle_options.seed (index or id). |
| `float Amount = 1` | Scales every motion, 0 to 2; default 1. The C field sona_idle_options.amount (factor (unitless)). |
| `float FacePx = 240` | Default 240. The C field sona_idle_options.face_px (px). |

## SonaIdleState

`struct SonaIdleState`: The C type sona_idle_state.

| Declaration | What it does |
|---|---|
| `float Blink` | 0 open to 1 shut. The C field sona_idle_state.blink (factor (unitless)). |
| `float GazeLeft` | Where the idle's glance looks, in degrees to the avatar's left (sona_idle_state.gaze[0]). |
| `float GazeUp` | Where the idle's glance looks, in degrees up (sona_idle_state.gaze[1]). |
| `float Shift` | -1 the weight on the left foot to 1 on the right. The C field sona_idle_state.shift (factor (unitless)). |
| `float Breath` | 0 breathed out to 1 in. The C field sona_idle_state.breath (factor (unitless)). |

## SonaClips

`static unsafe class SonaClips`: The stock clips: lists and looks them up (sona_stock_clip_count, sona_stock_clip_at, sona_stock_clip_find, sona_stock_clips_tagged).

| Declaration | What it does |
|---|---|
| `static int Count` | The clips in the library: 100 (SONA_STOCK_CLIP_COUNT).<br>Calls [`sona_stock_clip_count`](../c/stock-clips.md#sona_stock_clip_count). |
| `static SonaStockClip At(int index)` | The clip at index, in id order.<br>Calls [`sona_stock_clip_at`](../c/stock-clips.md#sona_stock_clip_at). |
| `static SonaStockClip Get(uint id)` | The clip with this id (SONA_STOCK_*: bytes 4 to 7 of its asset id).<br>Calls [`sona_stock_clip_get`](../c/stock-clips.md#sona_stock_clip_get). |
| `static uint Find(string name)` | By name ("wave"), asset id or a legacy key ("GenericWave"); 0 when none.<br>Calls [`sona_stock_clip_find`](../c/stock-clips.md#sona_stock_clip_find). |
| `static uint ForBody(uint id, int body)` | The clip of id's family made for body (1 male, 2 female): its own variant, else one for both, else id itself.<br>Calls [`sona_stock_clip_for_body`](../c/stock-clips.md#sona_stock_clip_for_body). |
| `static List<SonaStockClip> Tagged(SonaClipTags all = SonaClipTags.None, SonaClipTags without = SonaClipTags.None, int body = 0)` | Every clip with all of the tags and none of without that suits body (0 any, 1 male, 2 female), by id.<br>Calls [`sona_stock_clips_tagged`](../c/stock-clips.md#sona_stock_clips_tagged). |
| `static string TagName(SonaClipTags tag)` | The name of one tag bit ("idle", "travel",...); NULL for 0, several bits or an unknown bit.<br>Calls [`sona_clip_tag_name`](../c/stock-clips.md#sona_clip_tag_name). |
| `static SonaClipTags TagFind(string name)` | The bit for a tag name; 0 when none.<br>Calls [`sona_clip_tag_find`](../c/stock-clips.md#sona_clip_tag_find). |
| `static SonaIdleOptions IdleDefaults()` | size set, parts SONA_IDLE_ALL, seed 0, amount 1, face_px 240.<br>Calls [`sona_idle_defaults`](../c/stock-clips.md#sona_idle_defaults). |
| `static SonaIdleState IdleSample(double seconds, uint seed, SonaIdleParts parts = SonaIdleParts.All)` | The idle's channels at seconds for a seed and parts, before amount.<br>Calls [`sona_idle_sample`](../c/stock-clips.md#sona_idle_sample). |

## SonaManifests

`static unsafe class SonaManifests`: Manifest helpers: parse and write, wear and take off, colours, gender and shape (sona_manifest_parse, sona_manifest_write, sona_manifest_wear and the rest).

| Declaration | What it does |
|---|---|
| `static Native.sona_manifest Parse(byte[] bytes)` | Reads 1000 bytes into a sona_manifest.<br>Calls [`sona_manifest_parse`](../c/manifests.md#sona_manifest_parse). |
| `static byte[] Write(in Native.sona_manifest m)` | Byte-exact: Write(Parse(x)) equals x.<br>Calls [`sona_manifest_write`](../c/manifests.md#sona_manifest_write). |
| `static byte[] Base64Decode(string text)` | The bytes the base64 text holds.<br>Calls [`sona_base64_decode`](../c/manifests.md#sona_base64_decode). |
| `static Native.sona_guid ParseGuid(string text)` | Parses the 36-character text form.<br>Calls [`sona_guid_parse`](../c/manifests.md#sona_guid_parse). |
| `static string FormatGuid(in Native.sona_guid id)` | The id in its lowercase 36-character form.<br>Calls [`sona_guid_format`](../c/manifests.md#sona_guid_format). |
| `static SonaRoute SlotOf(in Native.sona_guid id, out uint mask)` | Where an item id goes, and its slot mask in mask.<br>Calls [`sona_slot_of`](../c/manifests.md#sona_slot_of). |
| `static SonaResult Wear(ref Native.sona_manifest m, in Native.sona_guid item, uint primary, uint secondary, uint tertiary, SonaEditFlags flags = SonaEditFlags.None)` | Edit verbs: each changes m in place, or returns ARGUMENT with m unchanged where the JS fails.<br>Calls [`sona_manifest_wear`](../c/manifests.md#sona_manifest_wear). |
| `static SonaResult Unwear(ref Native.sona_manifest m, uint slotMask, SonaEditFlags flags = SonaEditFlags.None)` | Takes off what is in the slots of slot_mask.<br>Calls [`sona_manifest_unwear`](../c/manifests.md#sona_manifest_unwear). |
| `static SonaResult UndressAll(ref Native.sona_manifest m)` | Takes everything off.<br>Calls [`sona_manifest_undress_all`](../c/manifests.md#sona_manifest_undress_all). |
| `static SonaResult SetColour(ref Native.sona_manifest m, uint colourSlot, uint argb)` | Sets one of the nine body colours, by its index in colours.<br>Calls [`sona_manifest_set_colour`](../c/manifests.md#sona_manifest_set_colour). |
| `static SonaResult SetGender(ref Native.sona_manifest m, uint gender, SonaEditFlags flags = SonaEditFlags.None)` | Sets the gender: 1 male, 2 female.<br>Calls [`sona_manifest_set_gender`](../c/manifests.md#sona_manifest_set_gender). |
| `static SonaResult SetShape(ref Native.sona_manifest m, float weight, float height)` | Sets the weight and height.<br>Calls [`sona_manifest_set_shape`](../c/manifests.md#sona_manifest_set_shape). |
| `static bool ReadyForXbox(in Native.sona_manifest m)` | 1 when the body (and so the gender) is known and the editor's Xbox clean-up would change nothing: the manifest can be saved to Xbox as it is.<br>Calls [`sona_manifest_ready_for_xbox`](../c/manifests.md#sona_manifest_ready_for_xbox). |

## SonaLayerOptions

`sealed class SonaLayerOptions`: The C type sona_layer_options.

| Declaration | What it does |
|---|---|
| `SonaLayerMode Mode = SonaLayerMode.Override` | SONA_LAYER_OVERRIDE (default) or SONA_LAYER_ADDITIVE. The C field sona_layer_options.mode (one of the SONA_ values named). |
| `bool OneShot` | A clip that does not loop fades the layer out by its end, then stops it. |
| `bool Loop = true` | Default 1; for a machine, its states say. The C field sona_layer_options.loop (flag (0 or 1)). |
| `float Weight = 1` | 0..1; default 1. The C field sona_layer_options.weight (factor (unitless)). |
| `float FadeSeconds = 0.2f` | From what the layer showed before (or from nothing); default 0.2; 0: a cut. The C field sona_layer_options.fade_seconds (s). |
| `float Speed = 1` | Default 1. The C field sona_layer_options.speed (factor (1: as made)). |
| `float From` | Seconds into a clip, or 0..1 through a blend space's cycle; default 0. The C field sona_layer_options.from (s). |
| `float AdditiveRef` | ADDITIVE: seconds into each clip of the frame it is measured from; default 0. The C field sona_layer_options.additive_ref (s). |
| `float[] Mask` | SONA_JOINT_COUNT weights 0..1, copied; NULL keeps the layer's mask (every joint at first). The C field sona_layer_options.mask (pointer). |

## SonaLayerInfo

`struct SonaLayerInfo`: The C type sona_layer_info.

| Declaration | What it does |
|---|---|
| `SonaLayerKind Kind` | SONA_LAYER_EMPTY, _CLIP, _BLEND, _MACHINE. The C field sona_layer_info.kind (one of the SONA_ values named). |
| `SonaLayerMode Mode` | The C field sona_layer_info.mode (count). |
| `int State` | MACHINE: the current state; else -1. The C field sona_layer_info.state (one of the values named in the header). |
| `int Clip` | CLIP: the sona_clip_get index, -1 for a raw id. The C field sona_layer_info.clip (count). |
| `float Weight` | The layer's weight now, fades included. The C field sona_layer_info.weight (factor (unitless)). |
| `float Time` | Seconds into the clip; BLEND and MACHINE: into the current motion's leading clip. The C field sona_layer_info.time (s). |
| `float Normalized` | 0..1 through the clip or cycle. The C field sona_layer_info.normalized (factor (unitless)). |
| `bool Ready` | 1 once every clip it plays has loaded; until then it shows nothing. The C field sona_layer_info.ready (flag (0 or 1)). |
| `bool Fading` | 1 while it crossfades (a new clip, a transition). The C field sona_layer_info.fading (flag (0 or 1)). |

## SonaLayerEvent

`struct SonaLayerEvent`: The C type sona_layer_event.

| Declaration | What it does |
|---|---|
| `SonaLayerEventKind Kind` | The C field sona_layer_event.kind (one of the values named in the header). |
| `int Layer` | The C field sona_layer_event.layer (index or id). |
| `int State` | The C field sona_layer_event.state (one of the values named in the header). |
| `int FromState` | The C field sona_layer_event.from_state (one of the values named in the header). |
| `float Time` | The C field sona_layer_event.time (s). |

## SonaBlendSample

`struct SonaBlendSample`: The C type sona_blend_sample.

| Declaration | What it does |
|---|---|
| `string Clip` | A clip key or raw clip id. The C field sona_blend_sample.clip (text (UTF-8), NULL: none). |
| `float X` | Where it sits (y: 2D only). The C field sona_blend_sample.x (the blend space's own axis units (the parameter the host drives)). |
| `float Y` | Where it sits (y: 2D only). The C field sona_blend_sample.y (the blend space's own axis units (the parameter the host drives)). |
| `float Speed` | Its playback rate; 0: 1. The C field sona_blend_sample.speed (factor (1: as made)). |
| `SonaBlendSample(string clip, float x, float y = 0, float speed = 1)` | The C type sona_blend_sample. |

## SonaState

`sealed class SonaState`: The C type sona_state_desc.

| Declaration | What it does |
|---|---|
| `string Name` | Unique in the machine, at most 31 bytes. The C field sona_state_desc.name (text (UTF-8), NULL: none). |
| `string Clip` | A clip key or raw clip id; or NULL with blend. The C field sona_state_desc.clip (text (UTF-8), NULL: none). |
| `SonaBlendSpace Blend` | The C field sona_state_desc.blend (pointer to sona_blend_space). |
| `bool Loop = true` | 1 loops; 0 holds the last frame. The C field sona_state_desc.loop (flag (0 or 1)). |
| `float Speed = 1` | 0: 1. The C field sona_state_desc.speed (factor (1: as made)). |

## SonaConditionSpec

`struct SonaConditionSpec`: The C type sona_condition.

| Declaration | What it does |
|---|---|
| `string Param` | The C field sona_condition.param (text (UTF-8), NULL: none). |
| `SonaCondition Op` | The C field sona_condition.op (one of the values named in the header). |
| `float Value` | The C field sona_condition.value (the parameter's own units). |
| `SonaConditionSpec(string param, SonaCondition op, float value = 0)` | The C type sona_condition. |

## SonaTransition

`sealed class SonaTransition`: The C type sona_transition_desc.

| Declaration | What it does |
|---|---|
| `string From` | A state name, or NULL for any state but to. The C field sona_transition_desc.from (text (UTF-8), NULL: none). |
| `string To` | The C field sona_transition_desc.to (text (UTF-8), NULL: none). |
| `float FadeSeconds = 0.2f` | The C field sona_transition_desc.fade_seconds (s). |
| `float ExitTime = -1` | Negative: whenever; else not before the state is this far (0..1) through its cycle. The C field sona_transition_desc.exit_time (s). |
| `SonaConditionSpec[] Conditions` | The C field sona_transition_desc.conditions (a sona_condition (see its fields)). |

## SonaPropMesh

`sealed unsafe class SonaPropMesh : IDisposable`: A prop mesh of one context.

| Declaration | What it does |
|---|---|
| `SonaResult State` | Ok, Pending, or why it failed.<br>Calls [`sona_prop_mesh_state`](../c/props-held-and-worn-objects.md#sona_prop_mesh_state). |
| `Native.sona_prop_mesh_info Info()` | SONA_PENDING (only kind and item set) until the mesh is ready.<br>Calls [`sona_prop_mesh_info_get`](../c/props-held-and-worn-objects.md#sona_prop_mesh_info_get). |
| `Native.sona_prop_data Data()` | The meshes in the data API's form, valid while the mesh lives.<br>Calls [`sona_prop_mesh_data`](../c/props-held-and-worn-objects.md#sona_prop_mesh_data). |
| `void Dispose()` | The host's reference goes; avatars it is attached to keep it until they detach it.<br>Calls [`sona_prop_mesh_release`](../c/props-held-and-worn-objects.md#sona_prop_mesh_release). |

## SonaBlendSpace

`sealed unsafe class SonaBlendSpace : IDisposable`: A blend space of one context.

| Declaration | What it does |
|---|---|
| `float[] Weights(float x, float y = 0)` | Each sample's weight at (x, y).<br>Calls [`sona_blend_space_weights`](../c/animation-layers.md#sona_blend_space_weights). |
| `void Dispose()` | Lets go of the host's handle.<br>Calls [`sona_blend_space_destroy`](../c/animation-layers.md#sona_blend_space_destroy). |

## SonaStateMachine

`sealed unsafe class SonaStateMachine : IDisposable`: A state machine of one context.

| Declaration | What it does |
|---|---|
| `int Find(string state)` | A state's index by name; -1 if unknown.<br>Calls [`sona_state_machine_find`](../c/animation-layers.md#sona_state_machine_find). |
| `string StateName(int state)` | A state's name, NULL past the last.<br>Calls [`sona_state_machine_state_name`](../c/animation-layers.md#sona_state_machine_state_name). |
| `void Dispose()` | As sona_blend_space_destroy.<br>Calls [`sona_state_machine_destroy`](../c/animation-layers.md#sona_state_machine_destroy). |

## SonaMasks

`static unsafe class SonaMasks`: The joint masks layers play on: the presets (upper body, arms, head and the rest) and a branch from a joint (sona_mask_preset, sona_mask_branch).

| Declaration | What it does |
|---|---|
| `static float[] Preset(SonaMask preset)` | Fills a mask: SONA_MASK_NONE, _FULL, _UPPER_BODY (Spine and below it), _LOWER_BODY (the hips and legs), _HEAD (from the Neck), _LEFT_ARM, _RIGHT_ARM, _ARMS (from the shoulders).<br>Calls [`sona_mask_preset`](../c/animation-layers.md#sona_mask_preset). |
| `static void Branch(float[] mask, int joint, float weight)` | Sets joint and every joint below it to weight.<br>Calls [`sona_mask_branch`](../c/animation-layers.md#sona_mask_branch). |

## SonaLipSync

`sealed unsafe class SonaLipSync : IDisposable`: Audio in, mouths out: PCM in any chunks, a frame every 10 ms.

| Declaration | What it does |
|---|---|
| `SonaLipSync(int sampleRate, int channels = 1)` | NULL options: the defaults.<br>Calls [`sona_lipsync_defaults`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_defaults), [`sona_lipsync_create`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_create). |
| `void Feed(float[] pcm, int frames = -1)` | Interleaved floats, -1..1; length is a whole number of frames.<br>Calls [`sona_lipsync_feed`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_feed). |
| `byte Mouth(out float open)` | The newest mouth and how open it is.<br>Calls [`sona_lipsync_current`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_current). |
| `Native.sona_lipsync_frame[] Read()` | The frames made since the last call, oldest first (the newest SONA_LIPSYNC_QUEUE are kept).<br>Calls [`sona_lipsync_read`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_read). |
| `double Latency` | Seconds from a sample being fed to the first frame that hears it.<br>Calls [`sona_lipsync_latency`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_latency). |
| `void Reset()` | Back to time 0: hints and frames waiting to be read are dropped.<br>Calls [`sona_lipsync_reset`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_reset). |
| `void Hint(string symbol, float start, float end)` | Phonemes the host's TTS reported, on the fed audio's clock.<br>Calls [`sona_lipsync_hint`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_hint). |
| `static byte PhonemeMouth(string symbol)` | The mouth for a phoneme symbol (ARPAbet, IPA, viseme names or ids); 255 when unknown.<br>Calls [`sona_phoneme_mouth`](../c/lip-sync-and-voice-mouths.md#sona_phoneme_mouth). |
| `static SonaMouthKey[] FromText(string text, float[] pcm = null, int sampleRate = 48000)` | Text to mouth keys; with audio (mono floats at sampleRate) aligned to it, else at an even pace.<br>Calls [`sona_lipsync_defaults`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_defaults), [`sona_lipsync_text`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_text). |
| `static byte Sample(SonaMouthKey[] keys, double t, out float open)` | The mouth at time t of a key list.<br>Calls [`sona_mouth_keys_sample`](../c/lip-sync-and-voice-mouths.md#sona_mouth_keys_sample). |
| `static Native.sona_voice_mouth VoiceState(uint seed)` | A fresh voice-chat state for one speaker (sona_voice_mouth_init).<br>Calls [`sona_voice_mouth_init`](../c/lip-sync-and-voice-mouths.md#sona_voice_mouth_init). |
| `void Dispose()` | Frees the analyser.<br>Calls [`sona_lipsync_destroy`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_destroy). |

## SonaRenderOptions

`sealed class SonaRenderOptions`: What one headless picture looks like.

| Declaration | What it does |
|---|---|
| `uint Width = Width` | Pixels, 1 to 8192; default 256 x 256. The C field sona_render_options.width (px). |
| `SonaPreset Preset = SonaPreset.Full` | The framing; default SONA_PRESET_FULL. The C field sona_render_options.preset (sona_preset value). |
| `float YawDeg` | The camera moved around the preset's target; default 0, 0. The C field sona_render_options.yaw_deg (degrees). |
| `float PitchDeg` | The camera moved around the preset's target; default 0, 0. The C field sona_render_options.pitch_deg (degrees). |
| `float Zoom` | The preset's distance divided by this; default 1. The C field sona_render_options.zoom (factor (unitless)). |
| `float[] Clear` | The background, premultiplied RGBA from 0 to 1 (sona_render_options.clear). |
| `SonaDrawFlags Flags` | 0. The C field sona_render_options.flags (bit flags). |
| `string Clip` | A clip key or id; NULL: an avatar the headless call adds stands still (Stand0), one of yours keeps its own clip and time. The C field sona_render_options.clip (text (UTF-8), NULL: none). |

## SonaHeadlessDevice

`sealed class SonaHeadlessDevice`: The C type sona_headless_info.

| Declaration | What it does |
|---|---|
| `SonaBackend Backend` | The C field sona_headless_info.backend (sona_backend value). |
| `bool Software` | 1: a CPU rasteriser. The C field sona_headless_info.software (flag (0 or 1)). |
| `uint Type` | Vulkan: VkPhysicalDeviceType (1 integrated, 2 discrete, 3 virtual, 4 CPU); GL: 0. The C field sona_headless_info.type (count). |
| `uint VendorId` | The C field sona_headless_info.vendor_id (index or id). |
| `uint DeviceId` | The C field sona_headless_info.device_id (index or id). |
| `string Name` | "Intel(R) Arc(tm) Graphics (MTL)", "llvmpipe (LLVM 19.1.7, 256 bits)". The C field sona_headless_info.name (text (UTF-8)). |
| `string Driver` | The API and driver versions. The C field sona_headless_info.driver (text (UTF-8)). |

## SonaHeadless

`sealed unsafe class SonaHeadless : IDisposable`: A renderer on the library's own device (the best GPU, or lavapipe or llvmpipe): no window, no display.

| Declaration | What it does |
|---|---|
| `SonaHeadless(SonaContext ctx, SonaDeviceKind device = SonaDeviceKind.Auto, SonaBackend backend = 0, int adapter = -1, uint batchInFlight = 8, float waitSeconds = 60)` | Makes the device and a renderer on it, waiting up to wait_seconds for the ctx's shading data.<br>Calls [`sona_headless_open`](../c/headless-rendering-and-video-out.md#sona_headless_open). |
| `static List<SonaHeadlessDevice> Devices(SonaBackend backend = 0)` | Every device a headless renderer can open: Vulkan devices, then EGL devices.<br>Calls [`sona_headless_devices`](../c/headless-rendering-and-video-out.md#sona_headless_devices). |
| `SonaRenderer Renderer` | The device's renderer, for its lighting, environment, shadow maps, style and quality.<br>Calls [`sona_headless_renderer`](../c/headless-rendering-and-video-out.md#sona_headless_renderer). |
| `void Dispose()` | Frees the renderer and the device.<br>Calls [`sona_headless_close`](../c/headless-rendering-and-video-out.md#sona_headless_close). |
| `byte[] Render(SonaAvatar avatar, SonaRenderOptions options = null)` | One picture of an avatar of the ctx, alone, after waiting for it to be READY.<br>Calls [`sona_headless_render`](../c/headless-rendering-and-video-out.md#sona_headless_render). |
| `byte[] RenderManifest(byte[] manifest, SonaRenderOptions options = null)` | Adds the avatar (hidden, standing still or playing clip from time), draws it and removes it.<br>Calls [`sona_headless_render_manifest`](../c/headless-rendering-and-video-out.md#sona_headless_render_manifest). |
| `List<KeyValuePair<SonaResult, byte[]>> Batch(IList<byte[]> manifests, SonaRenderOptions options = null)` | One (result, pixels or null) per manifest, in order; a bad manifest gives its code.<br>Calls [`sona_headless_batch`](../c/headless-rendering-and-video-out.md#sona_headless_batch). |
| `List<byte[]> Sequence(SonaAvatar avatar, SonaRenderOptions options = null, uint frames = 0, float fps = 30, float turnDeg = 0, bool orbit = false)` | Frames at a fixed frame rate: frame i at the clip's start + i / fps, turned turnDeg * i / frames.<br>Calls [`sona_headless_sequence`](../c/headless-rendering-and-video-out.md#sona_headless_sequence). |
| `void Record(SonaAvatar avatar, SonaVideo video, SonaRenderOptions options = null, uint frames = 0, float fps = 30, float turnDeg = 0, bool orbit = false)` | sona_headless_sequence into a video.<br>Calls [`sona_headless_record`](../c/headless-rendering-and-video-out.md#sona_headless_record). |

## SonaVideo

`sealed unsafe class SonaVideo : IDisposable`: A PNG sequence, GIF, MP4 or WebM.

| Declaration | What it does |
|---|---|
| `uint Width` | Every frame's size. The C field sona_video_options.width (px). |
| `uint Height` | Every frame's size. The C field sona_video_options.height (px). |
| `SonaVideo(SonaContext ctx, string path, uint width, uint height, SonaVideoFormat format = SonaVideoFormat.Auto, float fps = 30, uint loops = 0, uint quality = 0, uint background = 0xff000000u, SonaVideoFlags flags = SonaVideoFlags.None, uint colours = 0, string ffmpeg = null)` | Starts a PNG sequence (the path holds one %d, %u or %0Nd), a GIF, or an MP4 or WebM through ffmpeg (started here).<br>Calls [`sona_video_defaults`](../c/headless-rendering-and-video-out.md#sona_video_defaults), [`sona_video_open`](../c/headless-rendering-and-video-out.md#sona_video_open). |
| `static List<SonaVideoFormat> Formats(string ffmpeg = null)` | The formats this machine can write.<br>Calls [`sona_video_formats`](../c/headless-rendering-and-video-out.md#sona_video_formats). |
| `void Frame(byte[] rgba)` | One frame of width * height straight RGBA8, row 0 at the top.<br>Calls [`sona_video_frame`](../c/headless-rendering-and-video-out.md#sona_video_frame). |
| `byte[] Finish()` | Ends the file; the bytes of an in-memory video, else null.<br>Calls [`sona_video_finish`](../c/headless-rendering-and-video-out.md#sona_video_finish), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `void Dispose()` | Ends the file and frees v, also on error.<br>Calls [`sona_video_finish`](../c/headless-rendering-and-video-out.md#sona_video_finish). |

## SonaPlayerLook

`sealed class SonaPlayerLook`: The C type sona_player_look.

| Declaration | What it does |
|---|---|
| `SonaPlayerState State` | The C field sona_player_look.state (sona_player_state value). |
| `SonaResult Error` | Why the last check failed: SONA_E_IO offline, SONA_E_LIMIT, SONA_E_GATE (the server failed), SONA_E_APP (client unknown to the lookup), SONA_E_CORRUPT; or OK. The C field sona_player_look.error (sona_result value). |
| `bool Placeholder` | 1: manifest is the placeholder. The C field sona_player_look.placeholder (flag (0 or 1)). |
| `byte[] Manifest` | The C field sona_player_look.manifest (bytes). |
| `string Version` | The look's version: 32 hex digits of its SHA-256; "" for the placeholder. The C field sona_player_look.version (text (UTF-8)). |
| `string Name` | The gamertag as Xbox spells it, or the slot's name; "" when there is none. The C field sona_player_look.name (text (UTF-8)). |
| `double FetchedAt` | Clock seconds this look arrived; 0: never. The C field sona_player_look.fetched_at (s). |
| `double CheckedAt` | Clock seconds the server last answered for it; 0: never. The C field sona_player_look.checked_at (s). |
| `double NextCheck` | Clock seconds of the next request; 0: none planned (not watched, or final). The C field sona_player_look.next_check (s). |

## SonaPlayerEvent

`struct SonaPlayerEvent`: The C type sona_player_event.

| Declaration | What it does |
|---|---|
| `SonaPlayerEventType Type` | The C field sona_player_event.type (sona_player_event_type value). |
| `SonaResult Code` | The C field sona_player_event.code (sona_result value). |
| `string Id` | The id as it was last watched. The C field sona_player_event.id (text (UTF-8)). |

## SonaPlayersOptions

`sealed class SonaPlayersOptions`: The C type sona_players_config.

| Declaration | What it does |
|---|---|
| `string Host` | NULL: "https://360sona.com". The C field sona_players_config.host (text (UTF-8), NULL: none). |
| `string Client` | The app id the gamertag lookup knows; NULL: the app id stamped into this build. The C field sona_players_config.client (text (UTF-8), NULL: none). |
| `string CacheDir` | NULL: memory only; else a folder this app owns, made when missing. The C field sona_players_config.cache_dir (text (UTF-8), NULL: none). |
| `byte[] Placeholder` | SONA_MANIFEST_BYTES shown while nothing is known; NULL: sona_players_placeholder. The C field sona_players_config.placeholder (pointer). |
| `uint MaxPlayers` | looks kept, in memory and on disk; 0: 2048. The C field sona_players_config.max_players (count). |
| `uint RefreshSeconds` | How often a watched player's look is checked again, in seconds (sona_players_config.refresh_seconds). |
| `uint PerHour` | Requests in any hour; 0: 60, the lookup's limit per address. The C field sona_players_config.per_hour (count (requests an hour)). |
| `uint InFlight` | Requests at once; 0: 4, at most 16. The C field sona_players_config.in_flight (count). |
| `uint TimeoutMs` | 0: 15000. The C field sona_players_config.timeout_ms (ms). |

## SonaPlayers

`sealed unsafe class SonaPlayers : IDisposable`: Friends, lobby members and leaderboard rows by id: a gamertag, "a:<account>/<slot>" or "w:<case key>".

| Declaration | What it does |
|---|---|
| `SonaPlayers(SonaPlayersOptions o = null)` | Reads the cache file when cache_dir is set (a file that does not decode is ignored).<br>Calls [`sona_players_defaults`](../c/other-players-avatars-by-id.md#sona_players_defaults), [`sona_players_open`](../c/other-players-avatars-by-id.md#sona_players_open). |
| `SonaResult Watch(string[] ids, int priority = 0)` | Ok, or the first problem (Argument for a string that is not an id, Limit); the rest are watched.<br>Calls [`sona_players_watch`](../c/other-players-avatars-by-id.md#sona_players_watch). |
| `void Unwatch(string[] ids = null)` | null: every id.<br>Calls [`sona_players_unwatch`](../c/other-players-avatars-by-id.md#sona_players_unwatch). |
| `SonaResult Refresh(string[] ids = null)` | null: every watched id.<br>Calls [`sona_players_refresh`](../c/other-players-avatars-by-id.md#sona_players_refresh). |
| `uint Update()` | Each frame: takes answers, sends due requests, writes the cache file (at most every 2 s).<br>Calls [`sona_players_update`](../c/other-players-avatars-by-id.md#sona_players_update). |
| `List<SonaPlayerEvent> Poll()` | Every event waiting, oldest first; an empty list when there are none.<br>Calls [`sona_players_poll`](../c/other-players-avatars-by-id.md#sona_players_poll). |
| `SonaPlayerLook Look(string id)` | Always a look to draw (the placeholder when nothing is known).<br>Calls [`sona_players_look`](../c/other-players-avatars-by-id.md#sona_players_look). |
| `bool Forget(string id)` | Drops the id's look from memory and, at the next write, from the cache file, and stops watching it.<br>Calls [`sona_players_forget`](../c/other-players-avatars-by-id.md#sona_players_forget). |
| `Native.sona_players_stats Stats()` | Looks kept, ids watched, requests in flight and due, and counts since open: requests, changed, the same, 304s, gone, failed, read from disk, disk writes, waits for per_hour; paused_until.<br>Calls [`sona_players_stats_get`](../c/other-players-avatars-by-id.md#sona_players_stats_get). |
| `static byte[] PlaceholderLook()` | The built-in placeholder: the site's faceless grey mannequin, nothing worn.<br>Calls [`sona_players_placeholder`](../c/other-players-avatars-by-id.md#sona_players_placeholder). |
| `void Dispose()` | Writes the cache file when it changed; answers still in flight are dropped.<br>Calls [`sona_players_close`](../c/other-players-avatars-by-id.md#sona_players_close). |

## SonaRandomOptions

`sealed class SonaRandomOptions`: The C type sona_random_options.

| Declaration | What it does |
|---|---|
| `uint Body` | 0: the seed picks (or the base's body); 1 male; 2 female. The C field sona_random_options.body (one of the values named in the header). |
| `uint Style` | SONA_STYLE_*. The C field sona_random_options.style (one of the SONA_ values named). |
| `uint Palette` | SONA_PALETTE_*. The C field sona_random_options.palette (one of the SONA_ values named). |
| `uint Flags` | SONA_RANDOM_*. The C field sona_random_options.flags (bit flags). |
| `SonaItemFlags Require` | SONA_ITEM_* every picked item has / lacks, on top of OFFERED and not HIDDEN. The C field sona_random_options.require (one of the SONA_ values named). |
| `SonaItemFlags Exclude` | SONA_ITEM_* every picked item has / lacks, on top of OFFERED and not HIDDEN. The C field sona_random_options.exclude (one of the SONA_ values named). |
| `uint SkipSections` | Bit (1u << sona_section) per section left as the base has it. The C field sona_random_options.skip_sections (bit flags). |
| `string Game` | Clothes from this game only (a franchise; ASCII case folded); NULL: any. The C field sona_random_options.game (text (UTF-8), NULL: none). |
| `string Tag` | A tag the random clothes must have; null: any (sona_random_options.tag). |
| `byte[] Base` | SONA_MANIFEST_BYTES to start from; NULL: a new avatar. The C field sona_random_options.base (pointer). |
| `uint[] Skin` | ARGB colours of the host's in place of the palette's; NULL: the palette's. The C field sona_random_options.skin (pointer). |
| `uint[] Hair` | ARGB colours of the host's in place of the palette's; NULL: the palette's. The C field sona_random_options.hair (pointer). |
| `uint[] Eyes` | ARGB colours of the host's in place of the palette's; NULL: the palette's. The C field sona_random_options.eyes (pointer). |
| `Func<string, bool> Available` | 0: the host cannot draw it, never pick it; NULL: all. The C field sona_random_options.available (a function (NULL: none)). |

## SonaRandomResult

`sealed class SonaRandomResult`: What sona_make_random picked: the set worn, the item per section and the candidates (sona_random_report).

| Declaration | What it does |
|---|---|
| `byte[] Manifest` | The C type sona_manifest. |
| `uint Body` | 0: the seed picks (or the base's body); 1 male; 2 female. The C field sona_random_options.body (one of the values named in the header). |
| `int Set` | The matched set worn, or -1. The C field sona_random_report.set (index or id (-1: none)). |
| `int[] Picked = new int[Native.SONA_SECTION_COUNT]` | Per sona_section: the catalogue index worn, or -1. The C field sona_random_report.picked (count). |
| `uint[] Candidates = new uint[Native.SONA_SECTION_COUNT]` | Per sona_section: the items that passed every filter. The C field sona_random_report.candidates (count). |

## SonaLikeItem

`sealed class SonaLikeItem`: The C type sona_like_item.

| Declaration | What it does |
|---|---|
| `string From` | The C field sona_like_item.from (a sona_guid (see its fields)). |
| `string To` | The C field sona_like_item.to (a sona_guid (see its fields)). |
| `string Outcome` | The C field sona_like_item.outcome (one of the values named in the header). |
| `uint Section` | The C field sona_like_item.section (one of the values named in the header). |

## SonaLikeResult

`sealed class SonaLikeResult`: What sona_make_dress_like kept, varied, swapped and dropped (sona_like_report).

| Declaration | What it does |
|---|---|
| `byte[] Manifest` | The C type sona_manifest. |
| `List<SonaLikeItem> Items = new List<SonaLikeItem>()` | Each item copied: from, what this body wears for it, SONA_RESOLVED_*. The C field sona_like_report.items (a sona_like_item (see its fields)). |
| `uint Kept` | The C field sona_like_report.kept (count). |
| `uint Variants` | The C field sona_like_report.variants (count). |
| `uint Similar` | The C field sona_like_report.similar (count). |
| `uint Substitutes` | The C field sona_like_report.substitutes (count). |
| `uint Dropped` | The C field sona_like_report.dropped (count). |
| `uint Covered` | The C field sona_like_report.covered (count). |

## SonaOutfitSet

`sealed class SonaOutfitSet`: The C type sona_outfit_set.

| Declaration | What it does |
|---|---|
| `int Index` | The set's index in the catalogue's list of matched sets. |
| `string Name` | The words its items' names share, or the game; lives as long as the maker. The C field sona_outfit_set.name (text (UTF-8), NULL: none). |
| `string Game` | The game it comes from; "" when none. The C field sona_outfit_set.game (text (UTF-8), NULL: none). |
| `uint Title` | The id tail its items share (the last four bytes, big-endian). The C field sona_outfit_set.title (bytes). |
| `uint Count` | Items. The C field sona_outfit_set.count (count). |
| `uint Bodies` | Who wears two or more of its sections: 1 a male body, 2 a female one, 3 both. The C field sona_outfit_set.bodies (one of the values named in the header). |
| `uint Sections` | Bit (1u << sona_section) per section it has items in. The C field sona_outfit_set.sections (bit flags). |
| `uint Slots` | Every slot its items cover. The C field sona_outfit_set.slots (bit flags). |

## SonaOutfitIssue

`sealed class SonaOutfitIssue`: The C type sona_outfit_issue.

| Declaration | What it does |
|---|---|
| `string Kind` | SONA_ISSUE_*. The C field sona_outfit_issue.kind (one of the SONA_ values named). |
| `string Severity` | SONA_SEVERITY_*. The C field sona_outfit_issue.severity (one of the SONA_ values named). |
| `uint Slots` | The slots concerned. The C field sona_outfit_issue.slots (bit flags). |
| `uint Field` | SONA_FIELD_* of item. The C field sona_outfit_issue.field (one of the SONA_ values named). |
| `string Item` | The items concerned; zero when none. The C field sona_outfit_issue.item (a sona_guid (see its fields)). |
| `string Other` | The items concerned; zero when none. The C field sona_outfit_issue.other (a sona_guid (see its fields)). |

## SonaOutfitReport

`sealed class SonaOutfitReport`: The C type sona_outfit_report.

| Declaration | What it does |
|---|---|
| `bool Valid` | 1: no errors (the manifest is valid and nothing clashes). The C field sona_outfit_report.valid (flag (0 or 1)). |
| `uint Issues` | Issues found (more than cap may be), and of them errors and warnings. The C field sona_outfit_report.issues (count). |
| `uint Errors` | Issues found (more than cap may be), and of them errors and warnings. The C field sona_outfit_report.errors (count). |
| `uint Warnings` | Issues found (more than cap may be), and of them errors and warnings. The C field sona_outfit_report.warnings (count). |
| `uint Body` | 1, 2, or 0 when not known. The C field sona_outfit_report.body (one of the values named in the header). |
| `uint Slots` | Every slot the worn items cover. The C field sona_outfit_report.slots (count). |
| `uint SetItems` | Worn items of the matched set (sona_outfit_report.set_items). |
| `int Set` | The matched set most worn items come from (two or more), or -1. The C field sona_outfit_report.set (index or id (-1: none)). |
| `List<SonaOutfitIssue> List = new List<SonaOutfitIssue>()` | The issues found, each with its slots and words (sona_outfit_issue). |

## SonaMaker

`sealed unsafe class SonaMaker : IDisposable`: A catalogue's outfit rules, indexed once: seeded random avatars, dress like, clashes, matched sets and the outfit check.

| Declaration | What it does |
|---|---|
| `SonaMaker(SonaCatalogue catalogue, SonaContext ctx = null)` | Indexes a catalogue's outfit rules once: candidate items per body and section, gender variants and matched sets.<br>Calls [`sona_maker_create`](../c/making-avatars-in-code.md#sona_maker_create). |
| `SonaRandomResult Random(uint seed, SonaRandomOptions options = null)` | size set and everything else zero: the seed picks the body, any game, a new avatar, the palette's colours and every item available.<br>Calls [`sona_random_defaults`](../c/making-avatars-in-code.md#sona_random_defaults), [`sona_make_random`](../c/making-avatars-in-code.md#sona_make_random). |
| `SonaLikeResult DressLike(byte[] body, byte[] like, uint parts = 0, uint match = Native.SONA_MATCH_SIMILAR, bool layer = false, Func<string, bool> available = null)` | body wearing like's parts (Native.SONA_LIKE_*; 0: clothes and props), each item resolved for body's gender.<br>Calls [`sona_like_defaults`](../c/making-avatars-in-code.md#sona_like_defaults), [`sona_make_dress_like`](../c/making-avatars-in-code.md#sona_make_dress_like). |
| `string Variant(string item, uint body, uint match, out string variant)` | What body (1 or 2) wears for item: the outcome name and the id (null when dropped).<br>Calls [`sona_make_variant`](../c/making-avatars-in-code.md#sona_make_variant). |
| `uint Clash(string a, string b, out uint slots)`<br>`static uint Clash(SonaMaker maker, string a, string b, out uint slots)` | Native.SONA_CLASH_* bits for two item ids; maker may be null (the ids alone).<br>Calls [`sona_outfit_clash`](../c/making-avatars-in-code.md#sona_outfit_clash). |
| `List<string> Conflicts(byte[] manifest, string item)` | The ids wearing item would take off manifest.<br>Calls [`sona_outfit_conflicts`](../c/making-avatars-in-code.md#sona_outfit_conflicts). |
| `int SetCount` | How many matched sets (outfits sold as one) the maker knows.<br>Calls [`sona_outfit_set_count`](../c/making-avatars-in-code.md#sona_outfit_set_count). |
| `SonaOutfitSet Set(int index)` | Set set: its item count, which bodies wear it, the sections it has items in and the slots it covers.<br>Calls [`sona_outfit_set_get`](../c/making-avatars-in-code.md#sona_outfit_set_get). |
| `int SetOf(string item)` | The matched set an item belongs to, or -1 when it is in none.<br>Calls [`sona_outfit_set_of`](../c/making-avatars-in-code.md#sona_outfit_set_of). |
| `uint[] SetItems(int set, uint body = 0)` | Catalogue indexes of a set's items a body wears (0: every item).<br>Calls [`sona_outfit_set_items`](../c/making-avatars-in-code.md#sona_outfit_set_items). |
| `SonaOutfitReport Check(byte[] manifest)`<br>`static SonaOutfitReport Check(SonaMaker maker, byte[] manifest)` | Every issue of a manifest, errors first; maker may be null (the catalogue's checks are left out).<br>Calls [`sona_outfit_check`](../c/making-avatars-in-code.md#sona_outfit_check), [`sona_outfit_issue_name`](../c/making-avatars-in-code.md#sona_outfit_issue_name). |
| `SonaOutfitReport Fix(byte[] manifest)`<br>`static SonaOutfitReport Fix(SonaMaker maker, byte[] manifest)` | Mends every error but no body in place; the report is the check after.<br>Calls [`sona_outfit_fix`](../c/making-avatars-in-code.md#sona_outfit_fix). |
| `void Dispose()` | Frees the maker.<br>Calls [`sona_maker_free`](../c/making-avatars-in-code.md#sona_maker_free). |

## EditorNative

`static unsafe class EditorNative`: The P/Invoke declarations of sona_editor.h, one to one.

| Declaration | What it does |
|---|---|
| `const string Lib = "__Internal"`<br>`const string Lib = "sona_editor"` | The library name the P/Invoke calls load ("__Internal" where the library is linked in, as on iOS). |
| `static List<string> CheckLayout(out int checkedRows)` | Every mirrored struct size, and every offset the library lists, that differs from the library's.<br>Calls [`sona_editor_struct_size`](../c/player-editor.md#sona_editor_struct_size), [`sona_editor_struct_offset`](../c/player-editor.md#sona_editor_struct_offset). |

## sona_editor_options

`struct sona_editor_options`: The C type sona_editor_options, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_editor_options), set by sona_editor_defaults. The C field sona_editor_options.size (bytes (sizeof the struct)). |
| `uint mode` | SONA_EDITOR_MODE_*. The C field sona_editor_options.mode (one of the SONA_ values named). |
| `uint width` | The target in pixels; default 1280 x 720 (sona_editor_resize changes it). The C field sona_editor_options.width (px). |
| `uint height` | The target in pixels; default 1280 x 720 (sona_editor_resize changes it). The C field sona_editor_options.height (px). |
| `uint flags` | SONA_EDITOR_*. The C field sona_editor_options.flags (bit flags). |
| `IntPtr start` | SONA_MANIFEST_BYTES to edit; NULL: a blank figure (MODE_WARDROBE needs one). The C field sona_editor_options.start (pointer). |
| `IntPtr catalogue` | Required: names, sections and what can be worn; must outlive the editor. The C field sona_editor_options.catalogue (pointer to sona_catalogue). |
| `ulong seed` | The generated looks; 0: 1. The C field sona_editor_options.seed (index or id). |
| `IntPtr title` | The heading; NULL: "Create your avatar" (or "Choose an outfit"). The C field sona_editor_options.title (text (UTF-8), NULL: none). |
| `IntPtr filter` | The C field sona_editor_options.filter (a function (NULL: none)). |
| `IntPtr filter_user` | The C field sona_editor_options.filter_user (pointer). |
| `IntPtr look` | The C field sona_editor_options.look (a function (NULL: none)). |
| `IntPtr look_user` | The C field sona_editor_options.look_user (pointer). |
| `IntPtr sound` | The C field sona_editor_options.sound (a function (NULL: none)). |
| `IntPtr sound_user` | The C field sona_editor_options.sound_user (pointer). |

## sona_editor_theme

`struct sona_editor_theme`: Colours are 0xAARRGGBB, straight alpha. The C type sona_editor_theme, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_editor_theme), set by sona_editor_theme_defaults. The C field sona_editor_theme.size (bytes (sizeof the struct)). |
| `uint background` | Behind the avatar (the avatar layer's clear). The C field sona_editor_theme.background (colour, 0xAARRGGBB). |
| `uint panel` | The panels. The C field sona_editor_theme.panel (colour, 0xAARRGGBB). |
| `uint raised` | Cells, buttons and rows on a panel. The C field sona_editor_theme.raised (colour, 0xAARRGGBB). |
| `uint text` | The C field sona_editor_theme.text (colour, 0xAARRGGBB). |
| `uint text_dim` | The C field sona_editor_theme.text_dim (colour, 0xAARRGGBB). |
| `uint accent` | The current tab, the selected cell, slider fill. The C field sona_editor_theme.accent (colour, 0xAARRGGBB). |
| `uint accent_text` | Text on accent. The C field sona_editor_theme.accent_text (colour, 0xAARRGGBB). |
| `uint focus` | The focus ring. The C field sona_editor_theme.focus (colour, 0xAARRGGBB). |
| `uint shade` | The dialog's screen dim. The C field sona_editor_theme.shade (colour, 0xAARRGGBB). |
| `float corner_radius` | Default 8. The C field sona_editor_theme.corner_radius (layout units (a 1280 x 720 screen)). |
| `float scale` | Every size; 0: the shorter side / 720, at least 0.5. The C field sona_editor_theme.scale (factor (unitless)). |
| `float font_px` | Body text; default 14 (titles are 1.5 times). The C field sona_editor_theme.font_px (px). |
| `IntPtr font` | TrueType or OpenType bytes, copied; NULL: the built-in font (Droid Sans). The C field sona_editor_theme.font (pointer). |
| `UIntPtr font_len` | The C field sona_editor_theme.font_len (bytes). |

## sona_editor_input

`struct sona_editor_input`: The C type sona_editor_input, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_editor_input). The C field sona_editor_input.size (bytes (sizeof the struct)). |
| `uint kind` | SONA_EDITOR_IN_*. The C field sona_editor_input.kind (one of the SONA_ values named). |
| `uint code` | The C field sona_editor_input.code (one of the values named in the header). |
| `int down` | The C field sona_editor_input.down (flag (0 or 1)). |
| `uint mods` | The C field sona_editor_input.mods (bit flags). |
| `uint pointer` | The C field sona_editor_input.pointer (index or id). |
| `float x` | The C field sona_editor_input.x (px). |
| `float y` | The C field sona_editor_input.y (px). |
| `float value` | The C field sona_editor_input.value (the control's own units (an axis: -1 to 1)). |

## sona_editor_control

`struct sona_editor_control`: The C type sona_editor_control, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_editor_control). The C field sona_editor_control.size (bytes (sizeof the struct)). |
| `uint id` | Stable while the control exists. The C field sona_editor_control.id (index or id). |
| `uint role` | SONA_EDITOR_ROLE_*. The C field sona_editor_control.role (one of the SONA_ values named). |
| `uint flags` | SONA_EDITOR_CTRL_*. The C field sona_editor_control.flags (bit flags). |
| `float value` | Sliders and spins. The C field sona_editor_control.value (the control's own units (between min and max)). |
| `float min` | Sliders and spins. The C field sona_editor_control.min (the control's own units). |
| `float max` | Sliders and spins. The C field sona_editor_control.max (the control's own units). |
| `uint index` | "index + 1 of count" in its group (0, 0 when none). The C field sona_editor_control.index (index or id). |
| `uint count` | "index + 1 of count" in its group (0, 0 when none). The C field sona_editor_control.count (count). |

## sona_editor_draw_data

`struct sona_editor_draw_data`: The C type sona_editor_draw_data, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_editor_draw_data). The C field sona_editor_draw_data.size (bytes (sizeof the struct)). |
| `uint width` | The C field sona_editor_draw_data.width (px). |
| `uint height` | The C field sona_editor_draw_data.height (px). |
| `uint revision` | Changes whenever the lists do. The C field sona_editor_draw_data.revision (revision number). |
| `uint vertex_count` | The C field sona_editor_draw_data.vertex_count (count). |
| `uint index_count` | Triangles. The C field sona_editor_draw_data.index_count (count). |
| `uint command_count` | The C field sona_editor_draw_data.command_count (count). |

## sona_editor_texture

`struct sona_editor_texture`: The C type sona_editor_texture, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_editor_texture). The C field sona_editor_texture.size (bytes (sizeof the struct)). |
| `uint id` | The C field sona_editor_texture.id (index or id). |
| `uint width` | The C field sona_editor_texture.width (px). |
| `uint height` | The C field sona_editor_texture.height (px). |
| `uint revision` | Upload again when it changes. The C field sona_editor_texture.revision (revision number). |
| `uint dirty_since` | A copy of dirty_since or later needs only dirty; an older one needs all of it. The C field sona_editor_texture.dirty_since (revision number). |

## SonaEditorControl

`struct SonaEditorControl`: One control on screen, for a screen reader.

| Declaration | What it does |
|---|---|
| `uint Id` | Stable while the control exists. The C field sona_editor_control.id (index or id). |
| `SonaEditorRole Role` | SONA_EDITOR_ROLE_*. The C field sona_editor_control.role (one of the SONA_ values named). |
| `bool Focused` | True for the control that has the focus. |
| `bool Selected` | True for the control that is selected (a tab, a list item). |
| `float X` | The control's left edge in px (sona_editor_control.rect[0]). |
| `float Y` | The control's top edge in px (sona_editor_control.rect[1]). |
| `float Width` | The control's width in px (sona_editor_control.rect[2]). |
| `float Height` | The control's height in px (sona_editor_control.rect[3]). |
| `float Value` | Sliders and spins. The C field sona_editor_control.value (the control's own units (between min and max)). |
| `uint Index` | "index + 1 of count" in its group (0, 0 when none). The C field sona_editor_control.index (index or id). |
| `uint Count` | "index + 1 of count" in its group (0, 0 when none). The C field sona_editor_control.count (count). |
| `string Label` | The control's label, as shown: "Blue Hoodie". The C field sona_editor_control.label. |
| `string ValueText` | "worn", "0.40", "Female". The C field sona_editor_control.value_text (text (UTF-8)). |
| `string Hint` | What pressing it does: "Wear it". The C field sona_editor_control.hint (text (UTF-8)). |

## SonaEditor

`sealed unsafe class SonaEditor : IDisposable`: The player-facing editor on a context of its own and a catalogue.

| Declaration | What it does |
|---|---|
| `SonaEditor(SonaContext ctx, SonaCatalogue catalogue, SonaEditorMode mode = SonaEditorMode.Full, byte[] start = null, bool light = false, uint width = 1280, uint height = 720, ulong seed = 1, SonaEditorFlags flags = SonaEditorFlags.None, Action<uint> sound = null)` | theme NULL: the light (site) theme.<br>Calls [`sona_editor_defaults`](../c/player-editor.md#sona_editor_defaults), [`sona_editor_theme_defaults`](../c/player-editor.md#sona_editor_theme_defaults), [`sona_editor_open`](../c/player-editor.md#sona_editor_open). |
| `void Dispose()` | Removes its avatars from the ctx.<br>Calls [`sona_editor_close`](../c/player-editor.md#sona_editor_close). |
| `void Button(SonaEditorPad b, bool down)` | A gamepad button pressed or let go (sona_editor_input). |
| `void Press(SonaEditorPad b, double dt = 1.0 / 60)` | A button pressed and let go, with an update between. |
| `void Axis(SonaEditorAxis a, float v)` | A gamepad axis moved, -1 to 1 (sona_editor_input). |
| `void Key(SonaEditorKey k, bool shift = false, bool ctrl = false)` | A key pressed, with shift and ctrl (sona_editor_input). |
| `void Text(string s)` | Typed text, for the search box (sona_editor_input). |
| `void Pointer(float x, float y, bool? down, uint pointer = 0)` | down: true pressed, false released, null moved. |
| `void Wheel(float lines, float x, float y)` | A mouse wheel turned at a point, in lines (sona_editor_input). |
| `SonaEditorStatus Update(double dt)` | Advances dt seconds: stick repeat, animations, avatar builds and (unless HOST_UPDATES) sona_update on the ctx.<br>Calls [`sona_editor_update`](../c/player-editor.md#sona_editor_update). |
| `SonaEditorStatus Status` | SONA_EDITOR_RUNNING, _DONE or _CANCELLED, as the last sona_editor_update returned.<br>Calls [`sona_editor_status`](../c/player-editor.md#sona_editor_status). |
| `bool Busy` | 1 while an avatar is still building (the shown one or a change on its way); thumbnails do not count.<br>Calls [`sona_editor_busy`](../c/player-editor.md#sona_editor_busy). |
| `uint BuildFailures` | How many avatar builds failed since open (the screen reader is told each time).<br>Calls [`sona_editor_build_failures`](../c/player-editor.md#sona_editor_build_failures). |
| `bool Undo(bool redo = false)` | Undoes the last change (redo 0) or redoes the last undone one (redo 1), for a host that draws the stage's own undo and redo buttons.<br>Calls [`sona_editor_undo`](../c/player-editor.md#sona_editor_undo). |
| `bool CanUndo(bool redo = false)` | 1 when sona_editor_undo with the same redo would step: use it to grey out the buttons.<br>Calls [`sona_editor_can_undo`](../c/player-editor.md#sona_editor_can_undo). |
| `double Zoom` | The stage's zoom: 1 is the editor's own framing, from 0.6 to 3.<br>Calls [`sona_editor_zoom`](../c/player-editor.md#sona_editor_zoom). |
| `void Turn(double degrees)` | Turns the avatar on the stage by degrees, as a drag across the stage does.<br>Calls [`sona_editor_turn`](../c/player-editor.md#sona_editor_turn). |
| `SonaEditorScreen[] Screens()` | The mode's screens in tab order.<br>Calls [`sona_editor_screens`](../c/player-editor.md#sona_editor_screens). |
| `byte[] Result()` | The avatar as it stands (at any time): SONA_MANIFEST_BYTES.<br>Calls [`sona_editor_result`](../c/player-editor.md#sona_editor_result). |
| `void SetSearch(string text)` | The search box of the wardrobe and the item screens, for hosts with an on-screen keyboard (UTF-8; NULL clears).<br>Calls [`sona_editor_set_search`](../c/player-editor.md#sona_editor_set_search). |
| `void Resize(uint width, uint height)` | The editor's size in pixels, the size of the target it is drawn into.<br>Calls [`sona_editor_resize`](../c/player-editor.md#sona_editor_resize). |
| `List<SonaEditorControl> Controls()` | Every control on screen, in reading order, and the focused one.<br>Calls [`sona_editor_control_count`](../c/player-editor.md#sona_editor_control_count), [`sona_editor_control_get`](../c/player-editor.md#sona_editor_control_get). |
| `SonaEditorControl? Focus()` | SONA_E_NOT_FOUND when nothing has focus (pointer-only use).<br>Calls [`sona_editor_focus_get`](../c/player-editor.md#sona_editor_focus_get). |
| `string Announcement()` | What a screen reader should say since the last call, or null.<br>Calls [`sona_editor_announcement`](../c/player-editor.md#sona_editor_announcement). |
| `byte[] RenderUi(uint width, uint height, byte[] under = null)` | The UI layer as straight RGBA (width x height of the editor).<br>Calls [`sona_editor_render_ui`](../c/player-editor.md#sona_editor_render_ui). |
| `EditorNative.sona_editor_draw_data DrawData()` | The triangle list for the host's own 2D pass; valid until the next Update.<br>Calls [`sona_editor_draw_data_get`](../c/player-editor.md#sona_editor_draw_data_get). |

## TrackNative

`static unsafe class TrackNative`: The P/Invoke declarations of sona_track.h, one to one.

| Declaration | What it does |
|---|---|
| `const string Lib = "__Internal"`<br>`const string Lib = "sona_track"` | The library name the P/Invoke calls load ("__Internal" where the library is linked in, as on iOS). |
| `const int SONA_TRACK_BLENDSHAPES = 52` | The value of SONA_TRACK_BLENDSHAPES. |
| `const uint SONA_TRACK_FOUND = SONA_TRACK_FOUND` | The value of SONA_TRACK_FOUND. |
| `static List<string> CheckLayout(out int checkedRows)` | Every mirrored struct's size and field offset that differs from the library's.<br>Calls [`sona_track_struct_offset`](../c/face-tracking.md#sona_track_struct_offset), [`sona_track_struct_size`](../c/face-tracking.md#sona_track_struct_size). |

## sona_track_options

`struct sona_track_options`: The C type sona_track_options, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_track_options). The C field sona_track_options.size (bytes (sizeof the struct)). |
| `uint flags` | SONA_TRACK_*. The C field sona_track_options.flags (bit flags). |
| `float face_min_cutoff` | The weights' One Euro filter: cutoff at rest in Hz; default 3. The C field sona_track_options.face_min_cutoff (Hz). |
| `float face_beta` | How fast the cutoff rises with speed; default 2. The C field sona_track_options.face_beta (factor (unitless)). |
| `float head_min_cutoff` | The head rotation's filter; default 1.2. The C field sona_track_options.head_min_cutoff (Hz). |
| `float head_beta` | Default 0.6 (per radian a second). The C field sona_track_options.head_beta (radians). |
| `float head_gain` | The head's rotation is scaled by this; default 1. The C field sona_track_options.head_gain (factor (unitless)). |
| `float neck_share` | Of the head's rotation, the part the Neck joint takes; default 0.35. The C field sona_track_options.neck_share (factor (unitless)). |
| `float sensitivity` | Above 1 a weaker expression reaches a shape; 0 (default): by layout, 1 for ARKit and 1.4 for MediaPipe, whose scores run lower. The C field sona_track_options.sensitivity (factor (unitless)). |
| `float lost_seconds` | The last face holds this long once the tracker loses it; default 0.5. The C field sona_track_options.lost_seconds (s). |
| `float return_seconds` | Then the head and face ease back to the clip over this; default 0.4. The C field sona_track_options.return_seconds (s). |
| `float sleep_seconds` | Eyes shut this long show the sleeping eyes instead of the blink; default 1.5, 0 never. The C field sona_track_options.sleep_seconds (s). |

## sona_track_face_input

`struct sona_track_face_input`: One frame of a face tracker. The C type sona_track_face_input, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_track_face_input). The C field sona_track_face_input.size (bytes (sizeof the struct)). |
| `uint flags` | SONA_TRACK_FOUND, SONA_TRACK_HAS_HEAD. The C field sona_track_face_input.flags (bit flags). |
| `double time` | Seconds, rising: the filters and holds run on it, not on calls. The C field sona_track_face_input.time (s). |
| `uint layout` | SONA_TRACK_LAYOUT_*. The C field sona_track_face_input.layout (one of the SONA_ values named). |
| `uint count` | Weights given: 52. The C field sona_track_face_input.count (count). |

## sona_track_face_state

`struct sona_track_face_state`: What the tracker makes of the frames so far. The C type sona_track_face_state, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_track_face_state). The C field sona_track_face_state.size (bytes (sizeof the struct)). |
| `uint tracking` | 1 while a face is followed or held after a loss; 0 once handed back. The C field sona_track_face_state.tracking (flag (0 or 1)). |
| `double time` | Of the last frame fed. The C field sona_track_face_state.time (s). |
| `float weight` | 0..1: how far the tracker drives the head (eases out after a loss, back in on a new face). The C field sona_track_face_state.weight (factor (unitless)). |
| `byte mood` | Sona_track_mood. The C field sona_track_face_state.mood (sona_track_mood value). |

## sona_track_calibration

`struct sona_track_calibration`: Neutral face. The C type sona_track_calibration, field for field.

| Declaration | What it does |
|---|---|
| `uint size` | Sizeof(sona_track_calibration). The C field sona_track_calibration.size (bytes (sizeof the struct)). |
| `uint frames` | Frames collected; 0: no calibration. The C field sona_track_calibration.frames (count). |

## SonaTrackState

`struct SonaTrackState`: What the tracker makes of the frames so far.

| Declaration | What it does |
|---|---|
| `bool Tracking` | 1 while a face is followed or held after a loss; 0 once handed back. The C field sona_track_face_state.tracking (flag (0 or 1)). |
| `double Time` | Of the last frame fed. The C field sona_track_face_state.time (s). |
| `float Weight` | 0..1: how far the tracker drives the head (eases out after a loss, back in on a new face). The C field sona_track_face_state.weight (factor (unitless)). |
| `byte[] Expression` | Mouth, left eyebrow, right eyebrow, left eye, right eye (255: left to the clip). |
| `SonaTrackMood Mood` | Sona_track_mood. The C field sona_track_face_state.mood (sona_track_mood value). |
| `float[] Head` | x, y, z, w in the avatar's body space. |
| `float[] Weights` | The filtered, calibrated weights in ARKit order. |

## SonaTracker

`sealed unsafe class SonaTracker : IDisposable`: Webcam face tracking onto one avatar.

| Declaration | What it does |
|---|---|
| `SonaTracker(SonaTrackFlags flags = SonaTrackFlags.None, float sensitivity = 0)` | NULL options: the defaults.<br>Calls [`sona_track_defaults`](../c/face-tracking.md#sona_track_defaults), [`sona_track_create`](../c/face-tracking.md#sona_track_create). |
| `static string BlendshapeName(int i)` | The name of blendshape index ("eyeBlinkLeft",...) as both trackers spell them; NULL past the last.<br>Calls [`sona_track_blendshape_name`](../c/face-tracking.md#sona_track_blendshape_name). |
| `void Feed(double time, float[] scores, float[] head = null, SonaTrackLayout layout = SonaTrackLayout.MediaPipe)` | One frame: scores in the layout's order (null: no face this frame), the head (x, y, z, w) or null.<br>Calls [`sona_track_face_input_defaults`](../c/face-tracking.md#sona_track_face_input_defaults), [`sona_track_face_feed`](../c/face-tracking.md#sona_track_face_feed). |
| `SonaTrackState State()` | What the tracker makes of the frames so far: the filtered, calibrated weights in ARKit order (sides swapped under SONA_TRACK_MIRROR, so Left is the avatar's left) and the head.<br>Calls [`sona_track_face_get`](../c/face-tracking.md#sona_track_face_get). |
| `void CalibrateBegin()` | Starts collecting a neutral face: every frame with a face from now on counts.<br>Calls [`sona_track_calibrate_begin`](../c/face-tracking.md#sona_track_calibrate_begin). |
| `byte[] CalibrateEnd()` | Ends the calibration; the bytes go back to CalibrationSet in a later session.<br>Calls [`sona_track_calibrate_end`](../c/face-tracking.md#sona_track_calibrate_end). |
| `void CalibrationSet(byte[] saved)` | A saved calibration, for the next session; NULL clears it.<br>Calls [`sona_track_calibration_set`](../c/face-tracking.md#sona_track_calibration_set). |
| `void Reset()` | Forgets the filters, the shapes held and the tracking state; keeps the options and the calibration.<br>Calls [`sona_track_reset`](../c/face-tracking.md#sona_track_reset). |
| `bool Apply(SonaAvatar avatar)` | The state on the avatar; false until it is ready and posed.<br>Calls [`sona_track_apply`](../c/face-tracking.md#sona_track_apply). |
| `void Release(SonaAvatar avatar)` | Hands the face and the tracker's joints back to the clip; nothing when a is not the avatar it drives.<br>Calls [`sona_track_release`](../c/face-tracking.md#sona_track_release). |
| `void Dispose()` | Frees the tracker.<br>Calls [`sona_track_destroy`](../c/face-tracking.md#sona_track_destroy). |

## SonaPickOptions

`sealed class SonaPickOptions`: The C type sona_pick_options.

| Declaration | What it does |
|---|---|
| `uint Flags` | SONA_PICK_*. The C field sona_pick_options.flags (bit flags). |
| `float MaxDistance` | Metres along the ray; 0: no limit. The C field sona_pick_options.max_distance (m (world units)). |
| `SonaAvatar[] Ignore` | Avatars the ray passes through (the player's own, say). The C field sona_pick_options.ignore (pointer). |

## SonaPickHit

`struct SonaPickHit`: The C type sona_pick_hit.

| Declaration | What it does |
|---|---|
| `uint Source` | SONA_PICK_SOURCE_*: a triangle, the sprite's picture, or the sphere. The C field sona_pick_hit.source (one of the SONA_ values named). |
| `uint Flags` | SONA_PICK_HIT_*. The C field sona_pick_hit.flags (bit flags). |
| `uint AvatarId` | Sona_avatar_id. The C field sona_pick_hit.avatar_id (index or id). |
| `SonaAvatar Avatar` | The C field sona_pick_hit.avatar (pointer to sona_avatar). |
| `uint Part` | SONA_PICK_BODY, _ITEM or _PROP; 0 for a sphere hit. The C field sona_pick_hit.part (one of the SONA_ values named). |
| `uint Section` | Sona_section from the item's mask (the catalogue has the exact one). The C field sona_pick_hit.section (one of the values named in the header). |
| `uint Mask` | The item's AssetMask. The C field sona_pick_hit.mask (bit flags). |
| `string Item` | The item hit; "" for a sphere hit. The C field sona_pick_hit.item (text (UTF-8)). |
| `int Mesh` | Index into sona_pose_data.meshes; -1 for a sphere hit. The C field sona_pick_hit.mesh (index or id). |
| `int Prop` | Index into sona_pose_data.props for a held prop, else -1. The C field sona_pick_hit.prop (index or id). |
| `int Joint` | The named joint (sona_joint_name) that moves the point most; -1 for a prop. The C field sona_pick_hit.joint (index or id). |
| `uint Triangle` | the mesh's indices3 * triangle.. The C field sona_pick_hit.triangle (index or id). |
| `uint Region` | Sona_body_region of that joint. The C field sona_pick_hit.region (sona_body_region value). |
| `uint Lod` | SONA_LOD_* at the last sona_update. The C field sona_pick_hit.lod (one of the SONA_ values named). |
| `float Distance` | Metres from the ray's origin, along its unit direction. The C field sona_pick_hit.distance (m (world units)). |
| `float PointX` | World. The C field sona_pick_hit.point, one part (m (world units)). |
| `float PointY` | World. The C field sona_pick_hit.point, one part (m (world units)). |
| `float PointZ` | World. The C field sona_pick_hit.point, one part (m (world units)). |
| `float NormalX` | World, unit, toward the ray: the triangle's, or the sprite's for a picture. The C field sona_pick_hit.normal, one part (direction (unit vector)). |
| `float NormalY` | World, unit, toward the ray: the triangle's, or the sprite's for a picture. The C field sona_pick_hit.normal, one part (direction (unit vector)). |
| `float NormalZ` | World, unit, toward the ray: the triangle's, or the sprite's for a picture. The C field sona_pick_hit.normal, one part (direction (unit vector)). |
| `float BaryU` | Where on the triangle the ray met it: barycentric u (sona_pick_hit.bary[0]). |
| `float BaryV` | Where on the triangle the ray met it: barycentric v (sona_pick_hit.bary[1]). |
| `float U` | The texture coordinate there: u (sona_pick_hit.uv[0]). |
| `float V` | The texture coordinate there: v (sona_pick_hit.uv[1]). |
| `string RegionName` | "none", "head", "neck", "torso", "hips", "leftArm", "rightArm", "leftHand", "rightHand", "leftLeg", "rightLeg", "leftFoot", "rightFoot"; NULL past the last. |

## SonaPicking

`static unsafe class SonaPicking`: Picking: which avatar, mesh and triangle a ray or a pixel meets (sona_pick_ray, sona_pick_screen, sona_pick_gpu).

| Declaration | What it does |
|---|---|
| `static string RegionName(uint region)` | "none", "head", "neck", "torso", "hips", "leftArm", "rightArm", "leftHand", "rightHand", "leftLeg", "rightLeg", "leftFoot", "rightFoot"; NULL past the last.<br>Calls [`sona_region_name`](../c/picking.md#sona_region_name). |
| `static void ViewRay(in SonaView view, double x, double y, float[] origin, float[] dir)` | The ray through (x, y) of the view's picture, pixels from its top left; dir has length 1.<br>Calls [`sona_view_ray`](../c/picking.md#sona_view_ray). |
| `static bool PickRay(this SonaContext ctx, float[] origin, float[] dir, out SonaPickHit hit, SonaPickOptions options = null)` | The nearest hit along the ray; false when nothing is hit.<br>Calls [`sona_pick_ray`](../c/picking.md#sona_pick_ray). |
| `static bool PickScreen(this SonaContext ctx, in SonaView view, double x, double y, out SonaPickHit hit, SonaPickOptions options = null)` | The nearest hit under (x, y) of the view's picture, sprites facing that view.<br>Calls [`sona_pick_screen`](../c/picking.md#sona_pick_screen). |
| `static SonaPickHit[] PickRayAll(this SonaContext ctx, float[] origin, float[] dir, int max = 64, SonaPickOptions options = null)` | Every avatar the ray hits, its nearest hit each, nearest first (at most max).<br>Calls [`sona_pick_ray_all`](../c/picking.md#sona_pick_ray_all). |
| `static bool Pick(this SonaAvatar a, float[] origin, float[] dir, out SonaPickHit hit, SonaPickOptions options = null)` | The ray against this avatar alone; false when it misses.<br>Calls [`sona_avatar_pick`](../c/picking.md#sona_avatar_pick). |
| `static bool PickGpu(this SonaRenderer renderer, in SonaView view, double x, double y, out SonaPickHit hit, SonaPickOptions options = null)` | The pick through the GPU id buffer (Vulkan, GL, GLES); throws UNSUPPORTED on other backends.<br>Calls [`sona_pick_gpu`](../c/picking.md#sona_pick_gpu). |
| `static void PickGpuIds(this SonaRenderer renderer, in SonaView view, uint x, uint y, uint w, uint h, uint[] avatarIds, ushort[] meshes = null, SonaPickOptions options = null)` | The id buffer of a region of the view's picture: per pixel the avatar id (0: none), row 0 at the top; meshes, when given, gets the mesh index + 1.<br>Calls [`sona_pick_gpu_ids`](../c/picking.md#sona_pick_gpu_ids). |

## Types

| Declaration | What it does |
|---|---|
| `enum SonaContentPreset : uint` | The content filter presets: family, no logos, no licensed items (SONA_CONTENT_FAMILY, SONA_CONTENT_NO_LOGOS, SONA_CONTENT_NO_LICENSED). |
| `enum SonaClipTags : uint` | The tags of a stock clip (SONA_CLIP_TAG_*): idle, emote, walk and the rest. |
| `enum SonaIdleParts : uint` | Which parts of the idle play: blink, glance, shift, breathe (SONA_IDLE_*). |
| `struct SonaMouthKey` | A mouth from time on (sona_mouth_key). |
| `enum SonaPlayerState` | The C type sona_player_state. |
| `enum SonaPlayerEventType` | The C type sona_player_event_type. |
| `enum SonaEditorMode : uint` | The editor's modes: full, quick creator, wardrobe (SONA_EDITOR_MODE_*). |
| `enum SonaEditorStatus : uint` | SONA_EDITOR_RUNNING, _DONE or _CANCELLED, as the last sona_editor_update returned. |
| `enum SonaEditorScreen : uint` | The editor's screens (SONA_EDITOR_SCREEN_*): body, appearance and wardrobe in the full editor, looks and quick in the quick creator; face, hair and colours are deprecated. |
| `enum SonaEditorPad : uint` | Gamepad buttons the editor takes (SONA_EDITOR_PAD_*). |
| `enum SonaEditorAxis : uint` | Gamepad axes the editor takes (SONA_EDITOR_AXIS_*). |
| `enum SonaEditorKey : uint` | Keyboard keys the editor takes (SONA_EDITOR_KEY_*). |
| `enum SonaEditorRole : uint` | What a control is: button, tab, list item, option, slider, spin, search (SONA_EDITOR_ROLE_*). |
| `enum SonaEditorFlags : uint` | The editor's options: no thumbnails, no cancel, host updates, all items, garment colours (the sona_editor_options flags). |
| `struct sona_editor_vertex` | The C type sona_editor_vertex, field for field. |
| `struct sona_editor_command` | Blend with SRC_ALPHA, ONE_MINUS_SRC_ALPHA (straight alpha), no depth, the scissor at clip. The C type sona_editor_command, field for field. |
| `enum SonaTrackLayout : uint` | The blendshape layout of the face input: ARKit or MediaPipe (SONA_TRACK_LAYOUT_*). |
| `enum SonaTrackFlags : uint` | Face tracking options: mirror, no head, no face, no gaze (the sona_track_options flags). |
| `enum SonaTrackMood : byte` | The face's moods, the first seven shapes of every part of the avatar's face. The C type sona_track_mood. |
