> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/dolphin-emu/dolphin/llms.txt
> Use this file to discover all available pages before exploring further.

# Audio system

> DSP emulation and audio processing with HLE and LLE backends

Dolphin emulates the GameCube/Wii Digital Signal Processor (DSP) which handles all audio processing.

## DSP Hardware

The DSP is a dedicated audio coprocessor:

| Feature      | Value                      |
| ------------ | -------------------------- |
| Clock Speed  | 81 MHz                     |
| Architecture | Custom 16-bit DSP          |
| IRAM         | 8192 x 16-bit instructions |
| DRAM         | 4096 x 16-bit data words   |
| DMA          | Bidirectional to main RAM  |

**Location**: `Source/Core/Core/DSP/`

## Emulation Modes

Dolphin supports two DSP emulation approaches:

<Tabs>
  <Tab title="HLE (High-Level)">
    **Location**: `Core/DSP/DSPHLE/`

    **Default and recommended**. Emulates DSP behavior without running actual DSP code:

    ### Advantages

    * Very fast (low CPU usage)
    * No DSP ROM required
    * Compatible with 95%+ of games
    * Deterministic

    ### How It Works

    * Intercepts DSP UCode (microcode) uploads
    * Identifies known UCode types (AX, Zelda, etc.)
    * Reimplements UCode functionality in C++
    * Outputs audio samples directly

    ### Supported UCodes

    * **AX**: Most common (Luigi's Mansion, Mario Kart, etc.)
    * **Zelda**: Zelda-specific (Wind Waker, Twilight Princess)
    * **Card**: Memory card operations
    * **InitAudioSystem**: Boot-time initialization
    * **ROM**: IPL/BIOS DSP code

    ```ini theme={null}
    [DSP]
    EnableJIT = True  # Irrelevant for HLE
    Backend = HLE     # Default
    ```
  </Tab>

  <Tab title="LLE (Low-Level)">
    **Location**: `Core/DSP/DSPLLE/`

    Accurately emulates the DSP hardware by running actual DSP code:

    ### Advantages

    * Near-perfect accuracy
    * Supports custom DSP code
    * Required for some games (\< 5%)

    ### Disadvantages

    * Higher CPU usage (10-30% more)
    * Requires DSP ROM files
    * Potential audio glitches if too slow

    ### DSP ROM Files

    Required files in `User/GC/USA/` (or region equivalent):

    * `dsp_rom.bin` (8 KB DSP instruction ROM)
    * `dsp_coef.bin` (4 KB coefficient ROM)

    ### Execution Backends

    <Accordion title="LLE Interpreter">
      Interprets each DSP instruction:

      * Slowest LLE option
      * Simplest and most accurate
      * Used for DSP debugging

      ```ini theme={null}
      [DSP]
      EnableJIT = False
      Backend = LLE
      ```
    </Accordion>

    <Accordion title="LLE JIT Recompiler">
      Compiles DSP code to native x86-64:

      * 3-5x faster than interpreter
      * Still accurate
      * Recommended LLE mode

      ```ini theme={null}
      [DSP]  
      EnableJIT = True
      Backend = LLE
      ```
    </Accordion>
  </Tab>
</Tabs>

## Audio Pipeline

Audio flows through these stages:

<Steps>
  <Step title="Game Sends Audio Commands">
    PowerPC CPU sends commands to DSP via mail interface

    **Location**: `Core/DSP/DSP.cpp`

    * Write to DSP mailbox registers
    * Upload UCode to IRAM
    * Send DMA commands for audio buffers
  </Step>

  <Step title="DSP Processes Audio">
    DSP runs UCode to process samples

    **HLE**: C++ implementation mimics UCode
    **LLE**: Execute actual DSP instructions

    * Decode audio (ADPCM, PCM)
    * Apply effects (reverb, delay, filters)
    * Mix multiple channels
    * Output to DMA buffer
  </Step>

  <Step title="Audio Interface Streams">
    Audio Interface (AI) streams from DMA buffer

    **Location**: `Core/HW/AudioInterface.cpp`

    * 32 KHz sample rate (AI default)
    * Stereo output (left/right channels)
    * Trigger AI interrupts on buffer completion
  </Step>

  <Step title="Audio Backend Outputs">
    Backend plays samples through OS audio API

    **Location**: `AudioCommon/`

    * Resample if needed
    * Send to audio device
    * Handle buffer underruns
  </Step>
</Steps>

## Audio Backends

**Location**: `Source/Core/AudioCommon/`

Dolphin supports multiple audio output backends:

| Backend        | Platforms | Description                       |
| -------------- | --------- | --------------------------------- |
| **Cubeb**      | All       | Cross-platform (recommended)      |
| **WASAPI**     | Windows   | Windows Audio Session API         |
| **PulseAudio** | Linux     | Linux standard                    |
| **ALSA**       | Linux     | Advanced Linux Sound Architecture |
| **OpenAL**     | All       | OpenAL Soft                       |
| **OpenSLES**   | Android   | Android native audio              |
| **Null**       | All       | No output (testing)               |

### Configuration

```ini theme={null}
[DSP]
Backend = Cubeb       # Audio backend to use
Volume = 100          # Volume (0-100)
AudioLatency = 20     # Latency in ms (lower = less delay, more CPU)
EnableJIT = True      # DSP JIT (LLE only)
```

### Cubeb (Recommended)

Mozilla's cross-platform audio library:

```ini theme={null}
[DSP]  
Backend = Cubeb
AudioLatency = 20  # 20ms recommended
```

Advantages:

* Low latency
* Reliable on all platforms
* Automatic device switching
* Minimal CPU overhead

## Audio Settings

Key audio configuration options:

<Accordion title="DSP Emulation Engine">
  Choose between HLE and LLE:

  ```ini theme={null}
  [Core]
  DSPHLE = True   # True for HLE, False for LLE

  [DSP]
  EnableJIT = True  # LLE JIT compilation
  ```

  **Default**: HLE (fast, compatible)
  **Use LLE when**: Game has audio issues with HLE
</Accordion>

<Accordion title="Audio Latency">
  Buffer size in milliseconds:

  ```ini theme={null}
  [DSP]
  AudioLatency = 20  # 10-100ms
  ```

  * **Lower** (10-20ms): Less delay, more CPU, potential underruns
  * **Higher** (50-100ms): More delay, less CPU, smoother audio

  **Default**: 20ms (good balance)
</Accordion>

<Accordion title="Stretching">
  Time-stretch audio to match emulation speed:

  ```ini theme={null}
  [DSP]
  AudioStretch = False
  StretchFactor = 1.0
  ```

  Useful when emulation runs slower than 100% speed.
</Accordion>

<Accordion title="DPL II Decoding">
  Dolby Pro Logic II decoder:

  ```ini theme={null}
  [DSP]
  EnableDPL2 = False  # 5.1 surround from stereo
  DPL2Quality = 2     # 0=low, 1=normal, 2=high
  ```

  Upmixes stereo to 5.1 surround.
</Accordion>

## DSP UCode Types

Common UCode implementations in HLE:

### AX UCode

**Location**: `Core/DSP/DSPHLE/UCodes/AX.cpp`

Most common UCode for game audio:

* Multiple voice channels (up to 64)
* ADPCM and PCM decoding
* Volume, pitch, and pan control
* Effects: reverb, chorus, delay
* Surround positioning

Games using AX:

* Luigi's Mansion
* Mario Kart: Double Dash
* Super Smash Bros. Melee
* Most GameCube/Wii games

### Zelda UCode

**Location**: `Core/DSP/DSPHLE/UCodes/Zelda.cpp`

Zelda-specific audio:

* Sequenced music playback
* Sound effect triggering
* Custom mixing

Games using Zelda UCode:

* The Legend of Zelda: Wind Waker
* The Legend of Zelda: Twilight Princess
* The Legend of Zelda: Four Swords Adventures

### Card UCode

Memory card audio operations (beeps).

## Audio Debugging

Enable audio logging:

```ini theme={null}
[Logging]
EnableLogs = True
LOGSP1 = True    # Audio Interface
LOGDSP = True    # DSP
LOGAudio = True  # Audio backend
```

DSP debugging tools:

```bash theme={null}
# Dump DSP UCode to file
[DSP]
DumpUCode = True

# Dump audio to WAV files  
[DSP]
DumpAudio = True
```

Files written to `User/Dump/Audio/` and `User/Dump/DSP/`.

## Performance Tuning

<Tabs>
  <Tab title="Fast Performance">
    ```ini theme={null}
    [Core]
    DSPHLE = True         # Use HLE

    [DSP]
    Backend = Cubeb       # Efficient backend
    AudioLatency = 50     # Higher latency
    EnableDPL2 = False    # Disable surround
    ```
  </Tab>

  <Tab title="Low Latency">
    ```ini theme={null}
    [Core]  
    DSPHLE = True

    [DSP]
    Backend = Cubeb
    AudioLatency = 10     # Minimal latency
    EnableJIT = True      # If using LLE
    ```
  </Tab>

  <Tab title="Accuracy">
    ```ini theme={null}
    [Core]
    DSPHLE = False        # Use LLE

    [DSP]
    EnableJIT = True      # LLE with JIT
    AudioLatency = 20
    Backend = Cubeb
    ```
  </Tab>
</Tabs>

## See Also

* [Audio Settings Guide](/user-guide/audio-settings)
* [Core Emulation](/architecture/core-emulation)
* [Configuration](/user-guide/configuration)
