Skip to main content

Audio

This item only works when running on the client. Client

The sea's sounds on the Audio API: AudioPlayers, AudioEmitters in the world and one AudioListener on the camera, all wired through a single low-pass filter that goes dull while the camera is under the surface. No legacy Sound is made anywhere in the Ocean or its addons.

Ocean.Audio.Play("rbxassetid://123", nil, { Volume = 0.8 })                -- heard everywhere
Ocean.Audio.Play("rbxassetid://123", point, { Volume = 1, Distance = 800 }) -- from a spot in the world

Functions​

SetMuffle​

Audio.SetMuffle(amount: number) → ()

How dull everything the Ocean plays is, 0 (open) to 1 (as if under water). Eased by whoever calls it.

NewPlayer​

Audio.NewPlayer(name: string) → AudioPlayer?

A new AudioPlayer wired into the shared chain (heard everywhere, through the muffle). For loops that manage their own volume; Audio.Play is the one for one-shots.

Measure​

Audio.Measure(id: string) → ()

Plays id silently once, into an AudioAnalyzer only, to learn how loud it gets (the loudest moment of the whole clip), so a later Audio.Play with Normalize can bring it to a known level whatever asset it is. Takes as long as the clip; one voice, nothing audible. Does nothing for one already measured.

Play​

Audio.Play(
id: string,
position: Vector3?,
options: Options?
) → AudioPlayer?

Plays id once and cleans everything up afterwards. With a position the sound comes from that spot in the world (an AudioEmitter, heard by the listener on the camera, louder the closer); without one it is heard everywhere. Returns the player, or nil where audio is not available (a server) or id is blank.

Show raw api
{
    "functions": [
        {
            "name": "SetMuffle",
            "desc": "How dull everything the Ocean plays is, 0 (open) to 1 (as if under water). Eased by whoever calls it.",
            "params": [
                {
                    "name": "amount",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 92,
                "path": "src/Ocean/Audio.luau"
            }
        },
        {
            "name": "NewPlayer",
            "desc": "A new AudioPlayer wired into the shared chain (heard everywhere, through the muffle). For loops that\nmanage their own volume; `Audio.Play` is the one for one-shots.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "AudioPlayer?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 112,
                "path": "src/Ocean/Audio.luau"
            }
        },
        {
            "name": "Measure",
            "desc": "Plays `id` silently once, into an AudioAnalyzer only, to learn how loud it gets (the loudest moment of the\nwhole clip), so a later `Audio.Play` with `Normalize` can bring it to a known level whatever asset it is.\nTakes as long as the clip; one voice, nothing audible. Does nothing for one already measured.",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 130,
                "path": "src/Ocean/Audio.luau"
            }
        },
        {
            "name": "Play",
            "desc": "Plays `id` once and cleans everything up afterwards. With a `position` the sound comes from that spot in\nthe world (an AudioEmitter, heard by the listener on the camera, louder the closer); without one it is\nheard everywhere. Returns the player, or nil where audio is not available (a server) or `id` is blank.",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3?"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "Options?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "AudioPlayer?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 179,
                "path": "src/Ocean/Audio.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Audio",
    "desc": "The sea's sounds on the Audio API: AudioPlayers, AudioEmitters in the world and one AudioListener on the camera, all\nwired through a single low-pass filter that goes dull while the camera is under the surface. No legacy `Sound` is\nmade anywhere in the Ocean or its addons.\n\n```lua\nOcean.Audio.Play(\"rbxassetid://123\", nil, { Volume = 0.8 })                -- heard everywhere\nOcean.Audio.Play(\"rbxassetid://123\", point, { Volume = 1, Distance = 800 }) -- from a spot in the world\n```",
    "realm": [
        "Client"
    ],
    "source": {
        "line": 14,
        "path": "src/Ocean/Audio.luau"
    }
}