Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::audio_source_component Class Reference

Class that contains core data for audio sources. More...

#include <audio_source_component.h>

Inheritance diagram for unravel::audio_source_component:
unravel::component_crtp< audio_source_component > unravel::basic_component

Public Member Functions

void update (const math::transform &t, delta_t dt)
 Updates the audio source with the given transform and delta time.
 
void on_play_begin ()
 Called when audio playback begins.
 
void on_play_end ()
 Called when audio playback ends.
 
void set_loop (bool on)
 Sets whether the audio source should loop.
 
void set_volume (float volume)
 Sets the volume of the audio source.
 
void set_pitch (float pitch)
 Sets the pitch of the audio source.
 
void set_volume_rolloff (float rolloff)
 Sets the volume rolloff factor of the audio source.
 
void set_range (const frange_t &range)
 Sets the range of the audio source.
 
void set_autoplay (bool on)
 Sets whether the audio source should autoplay.
 
auto get_autoplay () const -> bool
 Gets whether the audio source is set to autoplay.
 
auto get_volume () const -> float
 Gets the volume of the audio source.
 
auto get_pitch () const -> float
 Gets the pitch of the audio source.
 
auto get_volume_rolloff () const -> float
 Gets the volume rolloff factor of the audio source.
 
auto get_range () const -> const frange_t &
 Gets the range of the audio source.
 
void set_playback_position (audio::duration_t offset)
 Sets the playback position of the audio source.
 
auto get_playback_position () const -> audio::duration_t
 Gets the playback position of the audio source.
 
auto get_playback_duration () const -> audio::duration_t
 Gets the total playback duration of the audio source.
 
auto play () -> bool
 Starts playing the audio source.
 
void stop ()
 Stops playing the audio source.
 
void pause ()
 Pauses the audio source.
 
void resume ()
 Resumes playing the audio source.
 
void set_mute (bool mute)
 Sets whether the audio source is muted.
 
auto is_muted () const -> bool
 Checks if the audio source is muted.
 
auto is_playing () const -> bool
 Checks if the audio source is currently playing.
 
auto is_paused () const -> bool
 Checks if the audio source is currently paused.
 
auto is_looping () const -> bool
 Checks if the audio source is set to loop.
 
void set_clip (const asset_handle< audio_clip > &clip)
 Sets the audio clip for the audio source.
 
auto get_clip () const -> const asset_handle< audio_clip > &
 Gets the audio clip of the audio source.
 
auto has_bound_sound () const -> bool
 Checks if the audio source has a valid sound bound.
 
- Public Member Functions inherited from unravel::basic_component
void touch ()
 Marks the component as 'touched'.
 

Additional Inherited Members

- Public Types inherited from unravel::component_crtp< audio_source_component >
using base
 
- Public Attributes inherited from unravel::basic_component
bool eto {}
 Disable empty type optimizations.
 
- Static Public Attributes inherited from unravel::component_crtp< audio_source_component >
static constexpr bool in_place_delete
 Indicates if the component can be deleted in place.
 

Detailed Description

Class that contains core data for audio sources.

Definition at line 16 of file audio_source_component.h.

Member Function Documentation

◆ get_autoplay()

auto unravel::audio_source_component::get_autoplay ( ) const -> bool

Gets whether the audio source is set to autoplay.

Returns
True if autoplay is enabled, false otherwise.

Definition at line 114 of file audio_source_component.cpp.

◆ get_clip()

auto unravel::audio_source_component::get_clip ( ) const -> const asset_handle<audio_clip>&

Gets the audio clip of the audio source.

Returns
The asset handle to the audio clip.

Definition at line 275 of file audio_source_component.cpp.

◆ get_pitch()

auto unravel::audio_source_component::get_pitch ( ) const -> float

Gets the pitch of the audio source.

Returns
The pitch level.

Definition at line 124 of file audio_source_component.cpp.

◆ get_playback_duration()

auto unravel::audio_source_component::get_playback_duration ( ) const -> audio::duration_t

Gets the total playback duration of the audio source.

Returns
The playback duration.

Definition at line 157 of file audio_source_component.cpp.

◆ get_playback_position()

auto unravel::audio_source_component::get_playback_position ( ) const -> audio::duration_t

Gets the playback position of the audio source.

Returns
The playback position.

Definition at line 148 of file audio_source_component.cpp.

◆ get_range()

auto unravel::audio_source_component::get_range ( ) const -> const frange_t&

Gets the range of the audio source.

Returns
A constant reference to the range.

Definition at line 134 of file audio_source_component.cpp.

◆ get_volume()

auto unravel::audio_source_component::get_volume ( ) const -> float

Gets the volume of the audio source.

Returns
The volume level.

Definition at line 119 of file audio_source_component.cpp.

◆ get_volume_rolloff()

auto unravel::audio_source_component::get_volume_rolloff ( ) const -> float

Gets the volume rolloff factor of the audio source.

Returns
The volume rolloff factor.

Definition at line 129 of file audio_source_component.cpp.

◆ has_bound_sound()

auto unravel::audio_source_component::has_bound_sound ( ) const -> bool

Checks if the audio source has a valid sound bound.

Returns
True if a valid sound is bound, false otherwise.

Definition at line 280 of file audio_source_component.cpp.

◆ is_looping()

auto unravel::audio_source_component::is_looping ( ) const -> bool

Checks if the audio source is set to loop.

Returns
True if looping, false otherwise.

Definition at line 261 of file audio_source_component.cpp.

◆ is_muted()

auto unravel::audio_source_component::is_muted ( ) const -> bool

Checks if the audio source is muted.

Returns
True if muted, false otherwise.

Definition at line 234 of file audio_source_component.cpp.

◆ is_paused()

auto unravel::audio_source_component::is_paused ( ) const -> bool

Checks if the audio source is currently paused.

Returns
True if paused, false otherwise.

Definition at line 252 of file audio_source_component.cpp.

◆ is_playing()

auto unravel::audio_source_component::is_playing ( ) const -> bool

Checks if the audio source is currently playing.

Returns
True if playing, false otherwise.

Definition at line 243 of file audio_source_component.cpp.

◆ on_play_begin()

void unravel::audio_source_component::on_play_begin ( )

Called when audio playback begins.

Definition at line 8 of file audio_source_component.cpp.

◆ on_play_end()

void unravel::audio_source_component::on_play_end ( )

Called when audio playback ends.

Definition at line 13 of file audio_source_component.cpp.

◆ pause()

void unravel::audio_source_component::pause ( )

Pauses the audio source.

Definition at line 197 of file audio_source_component.cpp.

◆ play()

auto unravel::audio_source_component::play ( ) -> bool

Starts playing the audio source.

Definition at line 167 of file audio_source_component.cpp.

◆ resume()

void unravel::audio_source_component::resume ( )

Resumes playing the audio source.

Definition at line 206 of file audio_source_component.cpp.

◆ set_autoplay()

void unravel::audio_source_component::set_autoplay ( bool on)

Sets whether the audio source should autoplay.

Parameters
onTrue to autoplay, false otherwise.

Definition at line 109 of file audio_source_component.cpp.

◆ set_clip()

void unravel::audio_source_component::set_clip ( const asset_handle< audio_clip > & clip)

Sets the audio clip for the audio source.

Parameters
soundThe audio clip to set.

Definition at line 266 of file audio_source_component.cpp.

◆ set_loop()

void unravel::audio_source_component::set_loop ( bool on)

Sets whether the audio source should loop.

Parameters
onTrue to loop, false otherwise.

Definition at line 51 of file audio_source_component.cpp.

◆ set_mute()

void unravel::audio_source_component::set_mute ( bool mute)

Sets whether the audio source is muted.

Parameters
muteTrue to mute, false otherwise.

Definition at line 215 of file audio_source_component.cpp.

◆ set_pitch()

void unravel::audio_source_component::set_pitch ( float pitch)

Sets the pitch of the audio source.

Parameters
pitchThe pitch level. Valid range: [0.0, 5.0].

Definition at line 73 of file audio_source_component.cpp.

◆ set_playback_position()

void unravel::audio_source_component::set_playback_position ( audio::duration_t offset)

Sets the playback position of the audio source.

Parameters
offsetThe playback position offset.

Definition at line 139 of file audio_source_component.cpp.

◆ set_range()

void unravel::audio_source_component::set_range ( const frange_t & range)

Sets the range of the audio source.

Parameters
rangeThe range of the audio source. min should be <= max and both >= 0.0.

Definition at line 95 of file audio_source_component.cpp.

◆ set_volume()

void unravel::audio_source_component::set_volume ( float volume)

Sets the volume of the audio source.

Parameters
volumeThe volume level. Valid range: [0.0, 1.0].

Definition at line 62 of file audio_source_component.cpp.

◆ set_volume_rolloff()

void unravel::audio_source_component::set_volume_rolloff ( float rolloff)

Sets the volume rolloff factor of the audio source.

Parameters
rolloffThe volume rolloff factor. Valid range: [0.0, 10.0].

Definition at line 84 of file audio_source_component.cpp.

◆ stop()

void unravel::audio_source_component::stop ( )

Stops playing the audio source.

Definition at line 187 of file audio_source_component.cpp.

◆ update()

void unravel::audio_source_component::update ( const math::transform & t,
delta_t dt )

Updates the audio source with the given transform and delta time.

Parameters
tThe transform to update with.
dtThe delta time.

Definition at line 23 of file audio_source_component.cpp.


The documentation for this class was generated from the following files: