.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_SamplePlayer2D: SamplePlayer2D ============== **Inherits:** :ref:`SoundPlayer2D` **<** :ref:`Node2D` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Sample player for positional 2D Sound. Member Functions ---------------- +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_polyphony` **(** **)** const | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_random_pitch_scale` **(** **)** const | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`SampleLibrary` | :ref:`get_sample_library` **(** **)** const | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_voice_active` **(** :ref:`int` voice **)** const | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`play` **(** :ref:`String` sample, :ref:`int` voice=-2 **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_polyphony` **(** :ref:`int` max_voices **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_random_pitch_scale` **(** :ref:`float` val **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_sample_library` **(** :ref:`SampleLibrary` library **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`stop_all` **(** **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`stop_voice` **(** :ref:`int` voice **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`voice_set_pitch_scale` **(** :ref:`int` voice, :ref:`float` ratio **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`voice_set_volume_scale_db` **(** :ref:`int` voice, :ref:`float` db **)** | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ Numeric Constants ----------------- - **INVALID_VOICE** = **-1** --- Value returned if the voice or sample are invalid. - **NEXT_VOICE** = **-2** --- Default voice for the play method. Corresponds to the first voice following the last used voice. Description ----------- Sample player for positional 2D Sound. Plays sound samples positionally, left and right depending on the distance/place on the screen. Member Function Description --------------------------- .. _class_SamplePlayer2D_get_polyphony: - :ref:`int` **get_polyphony** **(** **)** const Return the polyphony of the player. .. _class_SamplePlayer2D_get_random_pitch_scale: - :ref:`float` **get_random_pitch_scale** **(** **)** const Return the amplitude used for random pitch scale variations. .. _class_SamplePlayer2D_get_sample_library: - :ref:`SampleLibrary` **get_sample_library** **(** **)** const Return the sample library used by the player. .. _class_SamplePlayer2D_is_voice_active: - :ref:`bool` **is_voice_active** **(** :ref:`int` voice **)** const Return whether a voice is still active or has stopped playing. .. _class_SamplePlayer2D_play: - :ref:`int` **play** **(** :ref:`String` sample, :ref:`int` voice=-2 **)** Play a sample. An internal polyphony ID can optionally be passed, or defaults to NEXT_VOICE. Return a voice ID which can be used to modify the voice parameters, or INVALID_VOICE if the voice or sample are invalid. .. _class_SamplePlayer2D_set_polyphony: - void **set_polyphony** **(** :ref:`int` max_voices **)** Set the polyphony of the player (maximum amount of simultaneous voices). .. _class_SamplePlayer2D_set_random_pitch_scale: - void **set_random_pitch_scale** **(** :ref:`float` val **)** Set the amplitude for random pitch scale variations. If different from zero, the pitch scale will vary randomly around 1.0 in a range defined by val. The actual pitch scale will be, with "variation" ranging from -val to val: \* variation > 0: 1.0 + variation \* variation < 0: 1.0/(1.0 - variation) .. _class_SamplePlayer2D_set_sample_library: - void **set_sample_library** **(** :ref:`SampleLibrary` library **)** Set the sample library for the player. .. _class_SamplePlayer2D_stop_all: - void **stop_all** **(** **)** Stop all playing voices. .. _class_SamplePlayer2D_stop_voice: - void **stop_voice** **(** :ref:`int` voice **)** Stop a given voice. .. _class_SamplePlayer2D_voice_set_pitch_scale: - void **voice_set_pitch_scale** **(** :ref:`int` voice, :ref:`float` ratio **)** Change the pitch scale of a currently playing voice. .. _class_SamplePlayer2D_voice_set_volume_scale_db: - void **voice_set_volume_scale_db** **(** :ref:`int` voice, :ref:`float` db **)** Change the volume scale (in dB) of a currently playing voice.