# getSoundWaveData (Client)

> Returns the waveform of what the sound just played, for drawing oscilloscopes.

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

## Syntax

```lua
table|false getSoundWaveData(sound sound, int samples)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `sound` | `sound` | The `sound` element, or a `dui` element for the browser's sound. |
| `samples` | `int` | How many values to return: a power of 2 from 128 to 16384. |

## Returns

A table of `samples` values from -1 to 1, alternating left and right channel, or `false` if `samples` is not valid or the sound is paused, finished or streamed out.

## Example

```lua
addEventHandler("onClientRender", root, function()
    local wave = getSoundWaveData(music, 512)
    if not wave then return end
    for i = 0, 510, 2 do
        dxDrawLine(i, 300 + wave[i] * 100, i + 2, 300 + wave[i + 2] * 100, tocolor(255, 255, 255))
    end
end)
```

### Note

The table starts at index 0.

## See also

- [getSoundFFTData (Client)](https://wiki.mymp.gg/en/getSoundFFTData.md): Returns the frequency spectrum of what the sound is playing right now, for building visualisers.
- [getSoundLevelData (Client)](https://wiki.mymp.gg/en/getSoundLevelData.md): Returns the peak level of each channel over the sound's last 20 ms.
