# getSoundFFTData (Client)

> Returns the frequency spectrum of what the sound is playing right now, for building visualisers.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Sound
- **URL**: https://wiki.mymp.gg/en/getSoundFFTData

## Syntax

```lua
table|false getSoundFFTData(sound sound, int samples [, int bands = 0])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `sound` | `sound` | The `sound` element, or a `dui` element for the browser's sound. |
| `samples` | `int` | How many samples to analyse: a power of 2 from 256 to 16384. |
| `bands` | `int` | Group the spectrum into this many bands (up to half of `samples`). 0 returns the whole spectrum. *(default: `0`)* |

## Returns

A table of magnitudes from 0 to 1, or `false` if the arguments are not valid or the sound is paused, finished or streamed out.

## Example

```lua
local music = playSound("sounds/track.mp3", true)

addEventHandler("onClientRender", root, function()
    local bands = getSoundFFTData(music, 2048, 32)
    if not bands then return end
    for i = 0, 31 do
        local h = math.min(bands[i] * 400, 200)
        dxDrawRectangle(20 + i * 12, 400 - h, 10, h, tocolor(80, 200, 255))
    end
end)
```

### Note

The table starts at index 0. Without `bands` it holds `samples / 2 + 1` values; with `bands` it holds that many values, in logarithmically growing bands.

## See also

- [getSoundWaveData (Client)](https://wiki.mymp.gg/en/getSoundWaveData.md): Returns the waveform of what the sound just played, for drawing oscilloscopes.
- [getSoundLevelData (Client)](https://wiki.mymp.gg/en/getSoundLevelData.md): Returns the peak level of each channel over the sound's last 20 ms.
- [getSoundBPM (Client)](https://wiki.mymp.gg/en/getSoundBPM.md): Detects the sound's tempo in beats per minute, rounded down.
