• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    Audio

    The Audio class is responsible for controlling music and sound effects.

    Properties

    canModerateRadio

    (arg: Player) -> (boolean)
    ClientOnly
    ReadOnly

    client

    ClientOnly
    ReadOnly

    isPlaying

    boolean
    ClientOnly
    ReadOnly

    True when music is playing, otherwise false.

    musicIntensity

    number
    ClientOnly
    ReadOnly

    An estimation of the perceived loudness of the currently playing audio source.

    musicLength

    number
    ClientOnly
    ReadOnly

    Length of the music track in seconds.

    musicTime

    number
    ClientOnly
    ReadOnly

    Time in seconds since the music started.

    musicVolume

    number
    ClientOnly

    Current music volume.

    onRadioStationChanged

    (obj: RadioStation) -> ()
    ClientOnly
    ReadOnly

    radioEnabled

    boolean
    ClientOnly
    ReadOnly

    radioStation

    ClientOnly
    ReadOnly

    Methods

    DuckMusic

    ClientOnly

    Temporarily lowers the music volume.

    Parameters

    duration
    number

    The duration to lower the music volume.

    duckOutDuration
    number

    Duration for the volume to fade out to the ducked level.

    duckInDuration
    number

    Duration for the volume to return to normal after the specified duration.

    Returns

    void

    Enables radio support in the current room, allowing users to pick a radio station.

    Parameters

    enabled
    boolean
    currentStation
    stationSelected
    (obj: RadioStation) -> ()
    canModerateRadio
    (arg: Player) -> (boolean)

    Returns

    void

    Returns the current music intensity within a specified range.

    Parameters

    low
    number

    The lower bound of the intensity range.

    high
    number

    The upper bound of the intensity range.

    normalizeVolume
    boolean

    Whether to normalize the intensity within the specified range.

    Returns

    number

    The current music intensity, possibly normalized.

    PlayMusic

    ClientOnly

    Plays music using an audio shader. Music played with PlayMusic will be affected by the music volume slider.

    Parameters

    The audio shader containing the music to play

    volume
    number

    Volume of the music in the range of 0-1

    fadeIn
    boolean
    optional

    Whether the music should fade in as it starts playing (Default true)

    loop
    boolean
    optional

    Whether the music will loop instead of just playing once (Default true)

    startTime
    number
    optional

    Returns

    void

    PlayMusicURL

    ClientOnly

    Plays music using a radio station URL. Music played with PlayMusicURL will be affected by the music volume slider.

    Parameters

    url
    string

    The url of the music to play

    volume
    number

    Volume of the music in the range of 0-1

    fadeIn
    boolean
    optional

    Whether the music should fade in as it starts playing (Default true)

    Returns

    void

    PlayShader

    ClientOnly

    Plays an audio effect using an AudioShader.

    Parameters

    The AudioShader to use for playing the sound.

    Returns

    void

    PlaySound

    ClientOnly

    Plays a sound effect attached to a specific game object.

    Parameters

    The AudioShader to play.

    gameObject

    The GameObject to which the sound is attached.

    volume
    number

    The volume at which to play the sound.

    pitch
    number

    The pitch of the sound.

    spatialize
    boolean

    Whether the sound should be spatialized according to the game object's position.

    loop
    boolean

    Returns

    The AudioSource instance representing the played sound.

    PlaySoundGlobal

    ClientOnly

    Plays a sound effect globally, without spatialization.

    Parameters

    The AudioShader to play.

    volume
    number

    The volume at which to play the sound.

    pitch
    number

    The pitch at which to play the sound.

    loop
    boolean

    Whether the sound should loop.

    Returns

    The AudioSource instance representing the played sound.

    Set the position and rotation of the audio listener

    Parameters

    position
    rotation

    Returns

    void

    StopAudioSource

    ClientOnly

    Stops a specific audio source.

    Parameters

    The AudioSource to stop.

    Returns

    void

    StopMusic

    ClientOnly

    Stops currently playing music, with an optional fade-out.

    Parameters

    fadeOut
    boolean

    Whether to fade out the music instead of stopping abruptly.

    Returns

    void

    Updated 12 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.