# 💻 3. Core API

To play sounds from a Burst-compiled job, you need to pass the `FmodRuntimeAudio.ParallelWriter` to your job.

#### Playing One-Shots

One-shots are "fire-and-forget" sounds (e.g., footsteps, gunshots, impacts). If the sound is spawned outside its audible range (defined in FMOD Studio), it is instantly culled to save CPU.

```csharp
[BurstCompile]
public partial struct WeaponFireJob : IJobEntity
{
    public SncRuntimeAudio.ParallelWriter AudioWriter;

    private void Execute(in LocalTransform transform, in FireEvent fireEvent)
    {
        // Plays a sound at the given position with 80% volume
        SncAudioID.WeaponsGunshot.Shot(transform.Position)
            .Volume(0.8f)
            .Pitch(1.1f)
            .Apply(AudioWriter);
    }
}
```

#### Looping Sounds & Lifecycle

When you call `.Loop(entity)`, the system creates a lightweight **Shadow Entity**. This entity automatically tracks your target's position, rotation, and velocity (for the Doppler effect).

> 💡 **Info:** You **do not** need to stop loops manually! If you destroy the target entity (e.g., the enemy dies), the Shadow Entity detects it, tells FMOD to smoothly fade out the sound, and destroys itself. Zero memory leaks.

```csharp
// Start a looping engine sound attached to a vehicle entity
SncAudioID.VehiclesEngine.Loop(entity)
    .Volume(1.0f)
    .Apply(AudioWriter);
```

#### Dynamic Parameters & Properties

You can change FMOD Local Parameters or built-in properties (like Min/Max 3D Distance) on the fly for any active loop.

```csharp
// Update the RPM parameter of an already playing engine loop
SncAudioID.VehiclesEngine.Change(entity)
    .Param(SncAudioParamID.VehiclesEngine.RPM, 3500f)
    .Apply(AudioWriter);
```

#### Global Commands

Control buses and global parameters without string allocations. IDs are automatically generated from your `.strings.bank`.

```csharp
// Pause the SFX bus (e.g., when the game is paused)
AudioWriter.SetBusPaused(SncBusID.GameSfx, true);

// Change Music Volume
AudioWriter.SetBusVolume(SncBusID.Music, 0.5f);

// Update a Global Parameter
AudioWriter.SetGlobalParameter(SncGlobalParamID.TimeOfDay, 14.5f);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sniveler-code.gitbook.io/dots/audio-dispatcher-fmod/3.-core-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
