omni.audioplayer module

This module contains bindings to the C++ omni::audio::IAudioPlayer interface. This provides functionality for playing sound assets. This is intended only as a basic audio player interface for previewing assets. This is not intended to play sounds in a USD stage or in the Kit UI. For sounds in the USD stage, the omni.usd.audio interface should be used instead. For UI sounds, the omni.kit.uiaudio interface should be used.

Sound files may be in RIFF/WAV, Ogg, or FLAC format. Data in the sound files may use 8, 16, 24, or 32 bit integer samples, or 32 bit floating point samples. Channel counts may be from 1 to 64 If more channels of data are provided than the audio device can play, some channels will be blended together automatically.

class omni.audioplayer.AudioPlayer

Bases: pybind11_builtins.pybind11_object

An individual audio player instance. This must be created in order to have something to play sounds from.

draw_waveform(self: omni.audioplayer._audio.AudioPlayer, arg0: int, arg1: int, arg2: carb._carb.Float4, arg3: carb._carb.Float4) → List[int]

Render the waveform to an image to a file.

The functionality of writing to a file is a temporary workaround. This will eventually be changed to output a memory buffer.

Args:

player The player whose image will be rendered. width The width of the output image, in pixels. height The height of the output image, in pixels. fgColor The foreground color in normalized RGBA color. bgColor The background color in normalized RGBA color.

Returns:

None on failure. True if the operation was successful. False if the file could not be generated.

draw_waveform_to_file(self: omni.audioplayer._audio.AudioPlayer, arg0: int, arg1: int, arg2: carb._carb.Float4, arg3: carb._carb.Float4) → List[int]

Render the waveform to an image to a file.

The functionality of writing to a file is a temporary workaround. This will eventually be changed to output a memory buffer.

Args:

player The player whose image will be rendered. filename The name for the output image file. width The width of the output image, in pixels. height The height of the output image, in pixels. fgColor The foreground color in normalized RGBA color. bgColor The background color in normalized RGBA color.

Returns:

True if the operation was successful. False if the file could not be generated.

get_play_cursor(self: omni.audioplayer._audio.AudioPlayer)float

Get the play cursor position in the currently playing sound.

Parameters

arguments (No) –

Returns

The play cursor position in the currently playing sound in seconds.

0.0 if there is no playing sound.

get_sound_length(self: omni.audioplayer._audio.AudioPlayer)float

Get the length of the currently playing sound.

Parameters

arguments (No) –

Returns

The length of the currently playing sound in seconds.

0.0 if there is no playing sound.

load_sound(self: omni.audioplayer._audio.AudioPlayer, path: str, onLoaded: Callable[[bool], None])None
pause_sound(self: omni.audioplayer._audio.AudioPlayer)None

Pause playback of a sound on a specific audio player.

Each player has only one voice, so this call pauses that voice.

Parameters

arguments (No) –

Returns

No return value.

play_sound(self: omni.audioplayer._audio.AudioPlayer, path: str, onLoaded: Callable[[bool], None] = None, onEnded: Callable[[], None] = None, startTime: float = 0.0)None
set_play_cursor(self: omni.audioplayer._audio.AudioPlayer, path: str, onLoaded: Callable[[bool], None] = None, onEnded: Callable[[], None] = None, startTime: float = 0.0)None
stop_sound(self: omni.audioplayer._audio.AudioPlayer)None

Immediately stops the playback on a specific audio player

Each player has only one voice, so this call stops that voice.

Parameters

arguments (No) –

Returns

No return value.

unpause_sound(self: omni.audioplayer._audio.AudioPlayer)None

Unpause playback of a sound on a specific audio player.

Each player has only one voice, so this call unpauses that voice. If no voice is paused, this does nothing.

Parameters

arguments (No) –

Returns

No return value.

omni.audioplayer.create_audio_player() → omni::audio::AudioPlayerPtr