GLSL Hacker
FEATURES DOWNLOAD GALLERY BLOG LEARN



» Back to Reference Guide Index

gh_audio Library

Description

gh_audio is the module that manages sounds: creation, destruction, playing. The audio module follows FMOD principles.

Number of functions: 14



gh_audio.update

Description

Updates the sound system. Must be called once per frame.

Languages

Lua - Python

Parameters

This function has no input parameter(s).

Return Values

This function has no return value(s).

Code sample


gh_audio.update()



gh_audio.sound_create

Description

Creates a sound.

Languages

Lua - Python

Parameters

  • filename [STRING]: audio filename.
  • is_absolute_path [INTEGER]: audio filename path type: absolute (1) or relative (0) to the script file.
  • stream [INTEGER]: streaming mode (1) or not (0).

    Return Values

  • sound [INTEGER]: sound identifier

    Code sample


    sound = gh_audio.sound_create(filename, 0, 1)



    gh_audio.sound_kill

    Description

    Destroys a sound.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier

    Return Values

    This function has no return value(s).

    Code sample


    gh_audio.sound_kill(sound)



    gh_audio.sound_play

    Description

    Plays a sound.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier

    Return Values

  • channel [INTEGER]: sound instance

    Code sample


    channel = gh_audio.sound_play(sound)



    gh_audio.sound_is_playing

    Description

    Checks if a sound is currently playing.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance

    Return Values

  • is_playing [INTEGER]: playing state: 1 ot 0

    Code sample


    is_playing = gh_audio.sound_is_playing(sound, channel)



    gh_audio.sound_set_loop_state

    Description

    Sets the loop state.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • state [INTEGER]: enabled (1) or disabled (0)

    Return Values

    This function has no return value(s).

    Code sample


    gh_audio.sound_set_loop_state(sound, 1)



    gh_audio.sound_set_volume

    Description

    Sets the volume level of a particular sound instance.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance
  • volume [FLOAT]: volume from 0.0 to 1.0

    Return Values

    This function has no return value(s).

    Code sample


    gh_audio.sound_set_volume(sound, channel, 0.5)



    gh_audio.sound_get_volume

    Description

    Gets the volume level of a particular sound instance.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance

    Return Values

  • volume [FLOAT]: volume from 0.0 to 1.0

    Code sample


    volume = gh_audio.sound_get_volume(sound, channel)



    gh_audio.sound_get_duration_ms

    Description

    Gets the duration of a sound in milli-seconds.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier

    Return Values

  • duration [INTEGER]: duration in milli-seconds

    Code sample


    duration = gh_audio.sound_get_duration_ms(sound)



    gh_audio.sound_get_position_ms

    Description

    Gets the current position in a sound instance in milli-seconds.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance

    Return Values

  • position [INTEGER]: current position in milli-seconds

    Code sample


    position = gh_audio.sound_get_position_ms(sound, channel)



    gh_audio.sound_set_paused

    Description

    Sets the paused state of a particular sound instance.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance
  • state [INTEGER]: paused (1) or not (0)

    Return Values

    This function has no return value(s).

    Code sample


    gh_audio.sound_set_paused(sound, channel, 1)



    gh_audio.sound_spectrum_read

    Description

    Reads the audio buffer.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance

    Return Values

    This function has no return value(s).

    Code sample


    gh_audio.sound_spectrum_read(sound, channel)



    gh_audio.sound_spectrum_get_num_values

    Description

    Gets the number of entries in the audio buffer.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance

    Return Values

  • num_values [INTEGER]: number of entries

    Code sample


    num_values = gh_audio.sound_spectrum_get_num_values(sound, channel)



    gh_audio.sound_spectrum_get_value

    Description

    Gets a particular value from the audio buffer.

    Languages

    Lua - Python

    Parameters

  • sound [INTEGER]: sound identifier
  • channel [INTEGER]: sound instance
  • value_index [INTEGER]: entry index (from 0 to num_values-1)

    Return Values

  • value [FLOAT]: value

    Code sample


    local value = gh_audio.sound_spectrum_get_value(sound, channel, value_index)





    2013-2015 Geeks3D. All Rights Reserved.

    .:- G3D Network -:.