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

# Unreal Audio

> API reference for FLCKUnrealFeatureInstance, the built-in audio source that captures game audio and microphone input through Unreal Engine's native audio system.

<Info>
  **Module:** LCKUnrealAudio | **Version:** 1.0 | **Platforms:** All
</Info>

## Overview

LCKUnrealAudio captures audio through Unreal Engine's built-in audio system. It is the default audio source and supports both game audio and microphone input without any third-party dependencies.

## Supported Channels

| Channel      | Supported | Description                          |
| ------------ | --------- | ------------------------------------ |
| `Game`       | Yes       | Unreal Engine audio submix output    |
| `Microphone` | Yes       | Platform microphone via Unreal Audio |
| `VoiceChat`  | No        | Use LCKVivox                         |

***

## FLCKUnrealFeatureInstance

Primary audio source class. Implements `ILCKFeatureInstance` with dual-channel support for game audio and microphone capture.

```cpp theme={null}
class FLCKUnrealFeatureInstance : public ILCKFeatureInstance
{
public:
    // ILCKFeatureInstance interface
    virtual bool StartCapture() noexcept override;
    virtual bool StartCapture(TLCKAudioChannelsMask Channels) noexcept override;
    virtual void StopCapture() noexcept override;
    virtual float GetVolume() const noexcept override;
    virtual const FString& GetSourceName() const noexcept override;

protected:
    TLCKAudioChannelsMask SupportedChannels =
        ELCKAudioChannel::Game | ELCKAudioChannel::Microphone;
};
```

### ILCKFeatureInstance Methods

| Method                   | Behavior                                                    |
| ------------------------ | ----------------------------------------------------------- |
| `StartCapture()`         | Begins capture on both game and microphone channels         |
| `StartCapture(Channels)` | Begins capture for the specified channel mask only          |
| `StopCapture()`          | Stops all active capture                                    |
| `GetVolume()`            | Returns current RMS volume across active channels (0.0-1.0) |
| `GetSourceName()`        | Returns `"LCKUnrealAudio"`                                  |

### Usage

```cpp theme={null}
// Get the Unreal audio source
TSharedPtr<FLCKUnrealFeatureInstance> Source = /* from module or modular features */;

// Bind audio data delegate
Source->OnAudioDataDelegate.BindLambda([](
    TArrayView<const float> PCM,
    int32 Channels,
    int32 SampleRate,
    ELCKAudioChannel SourceChannel)
{
    // SourceChannel will be Game or Microphone
    // depending on which channel produced the data
});

// Start capturing both channels
Source->StartCapture();
```

***

## ULCKUnrealAudioBPL

Blueprint function library exposing Unreal audio utilities.

```cpp theme={null}
UCLASS()
class ULCKUnrealAudioBPL : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

public:
    UFUNCTION(BlueprintCallable, BlueprintPure, Category = "LCK")
    static int32 GetUnrealAudioSamplerate() noexcept;
};
```

| Method                       | Returns | Description                                   |
| ---------------------------- | ------- | --------------------------------------------- |
| `GetUnrealAudioSamplerate()` | `int32` | Current Unreal Engine audio sample rate in Hz |

### Blueprint Usage

Call **Get Unreal Audio Samplerate** from any Blueprint to query the engine's current audio sample rate. This is useful for verifying that game audio and voice chat sample rates match.

***

## FLCKUnrealAudioModule

Module that manages the lifecycle of `FLCKUnrealFeatureInstance`.

```cpp theme={null}
class FLCKUnrealAudioModule : public IModuleInterface
{
public:
    virtual void StartupModule() override;
    virtual void ShutdownModule() override;

private:
    TSharedPtr<FLCKUnrealFeatureInstance> FeatureInstance;
};

IMPLEMENT_MODULE(FLCKUnrealAudioModule, LCKUnrealAudio)
```

On startup, the module creates an `FLCKUnrealFeatureInstance` instance and registers it as a modular feature. On shutdown, it unregisters and destroys the source.

***

## Log Category

```cpp theme={null}
DECLARE_LOG_CATEGORY_EXTERN(LogLCKUnrealAudio, Log, All);
```

***

## Related

<CardGroup cols={2}>
  <Card title="Audio Overview" icon="volume-high" href="/api-reference/unreal/audio/overview">
    Audio system API overview
  </Card>

  <Card title="ILCKFeatureInstance" icon="microphone" href="/api-reference/unreal/audio-source-interface">
    Full interface specification
  </Card>
</CardGroup>
