载入中...
搜索中...
未找到
eve::audio::Source类 参考

A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control except fillPendingFromDecoder(), which is synchronized for the Audio worker thread. 更多...

#include <Source.h>

Public 成员函数

 Source (Audio *audio, sound::SoundData *data)
 Creates a static source from decoded audio (both arguments required).
 
 Source (Audio *audio, sound::Decoder *decoder, bool streaming, bool takeDecoderOwnership=false)
 Creates a streaming (or static-decoder) source; ownership of decoder is optional.
 
 ~Source ()
 Source.
 
void play ()
 Starts (or resumes) playback.
 
void pause ()
 Pauses playback, keeping the play position.
 
void stop ()
 Stops playback and rewinds the play position.
 
bool isPlaying () const
 True when playing.
 
void setVolume (float v)
 Sets source gain (clamped to >= 0). Does not cancel an active fade target.
 
float getVolume () const
 Returns the audible user volume after the last advanceFade (or committed volume).
 
void setPitch (float p)
 Sets playback pitch (clamped to >= 0).
 
float getPitch () const
 Returns the pitch.
 
void setLooping (bool l)
 Enables/disables looping.
 
bool isLooping () const
 True when looping.
 
bool seek (double seconds)
 Seeks to a time in seconds; false when seeking is unsupported.
 
double tell () const
 Current play time in seconds.
 
double getDuration () const
 Total duration in seconds (0 for live/unbounded streams).
 
void setPosition (float x, float y, float z)
 Sets the source position in world units.
 
void setVelocity (float x, float y, float z)
 Sets the source velocity (used by OpenAL doppler).
 
void setDirection (float x, float y, float z)
 Sets the source directional cone orientation.
 
void setRelative (bool relative)
 Makes the source ignore the listener position (head-relative).
 
bool isRelative () const noexcept
 True when the source is head-relative.
 
void setAttenuationDistances (float ref, float max)
 Sets OpenAL reference and maximum attenuation distances.
 
Result< void > fadeTo (float targetVolume, float durationSeconds, float now)
 Ramp audible volume toward targetVolume using injected simulation time.
 
Result< void > fadeOutAndStop (float durationSeconds, float now)
 Fade audible volume to zero then stop when the ramp completes.
 
Result< void > cancelFade ()
 Abort an active fade, keeping the current audible volume.
 
Result< void > advanceFade (float now)
 Advance an active fade envelope to absolute simulation time now.
 
float getFadeWeight () const noexcept
 Fade progress in [0,1]; 1 when idle.
 
bool isFading () const noexcept
 True while a fade envelope is active.
 
Result< void > setSpatialBlend (float blend)
 Continuous 2D/3D mix: 0 = ambient bed (relative, no rolloff), 1 = full world.
 
float getSpatialBlend () const noexcept
 Returns the spatial blend in [0,1].
 
Result< void > setBalance (float balance)
 Stereo/ambient balance in [-1,1] (left..right).
 
float getBalance () const noexcept
 Returns the balance in [-1,1].
 
Result< void > setRolloffFactor (float factor)
 Sets OpenAL rolloff factor (clamped to >= 0).
 
float getRolloffFactor () const noexcept
 Returns the rolloff factor.
 
int getChannelCount () const
 Channel count of the bound buffer/decoder (1 or 2), or 0 when unknown.
 
bool isStreaming () const
 True when streaming.
 
void pump ()
 Main thread: queues/unqueues AL buffers for a streaming source.
 
void fillPendingFromDecoder ()
 Called by the Audio worker thread. Internally synchronized against concurrent decoder teardown (see decoderMutex) — safe to call even if another thread is stopping/seeking/destroying this Source.
 

友元

class Audio
 

详细描述

A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control except fillPendingFromDecoder(), which is synchronized for the Audio worker thread.

在文件 Source.h 第 30 行定义.

构造及析构函数说明

◆ Source() [1/2]

eve::audio::Source::Source ( Audio *  audio,
sound::SoundData *  data 
)

Creates a static source from decoded audio (both arguments required).

在文件 Source.cpp 第 32 行定义.

引用了 audio.

◆ Source() [2/2]

eve::audio::Source::Source ( Audio *  audio,
sound::Decoder *  decoder,
bool  streaming,
bool  takeDecoderOwnership = false 
)

Creates a streaming (or static-decoder) source; ownership of decoder is optional.

在文件 Source.cpp 第 40 行定义.

引用了 audio , 以及 eve::audio::kStreamBufferCount.

◆ ~Source()

eve::audio::Source::~Source ( )

Source.

在文件 Source.cpp 第 57 行定义.

引用了 stop() , 以及 eve::audio::Audio::unregisterSource().

成员函数说明

◆ advanceFade()

Result< void > eve::audio::Source::advanceFade ( float  now)

Advance an active fade envelope to absolute simulation time now.

Idempotent. On completion commits volume to the fade target and stops when fadeOutAndStop requested silence.

在文件 Source.cpp 第 397 行定义.

引用了 eve::Result< T >::failure(), stop() , 以及 eve::Result< T >::success().

◆ cancelFade()

Result< void > eve::audio::Source::cancelFade ( )

Abort an active fade, keeping the current audible volume.

在文件 Source.cpp 第 387 行定义.

引用了 eve::Result< T >::success().

◆ fadeOutAndStop()

Result< void > eve::audio::Source::fadeOutAndStop ( float  durationSeconds,
float  now 
)

Fade audible volume to zero then stop when the ramp completes.

参数
durationSecondsNon-negative ramp length; 0 stops immediately.
nowAbsolute simulation time in seconds.

在文件 Source.cpp 第 383 行定义.

被这些函数引用 eve::audio::applyUnderwaterAudio().

◆ fadeTo()

Result< void > eve::audio::Source::fadeTo ( float  targetVolume,
float  durationSeconds,
float  now 
)

Ramp audible volume toward targetVolume using injected simulation time.

参数
targetVolumeDestination user volume (>= 0).
durationSecondsNon-negative ramp length; 0 snaps immediately.
nowAbsolute simulation time in seconds.

在文件 Source.cpp 第 379 行定义.

被这些函数引用 eve::audio::applyUnderwaterAudio().

◆ fillPendingFromDecoder()

void eve::audio::Source::fillPendingFromDecoder ( )

Called by the Audio worker thread. Internally synchronized against concurrent decoder teardown (see decoderMutex) — safe to call even if another thread is stopping/seeking/destroying this Source.

在文件 Source.cpp 第 424 行定义.

引用了 eve::audio::PcmChunk::bytes, eve::sound::Decoder::decode(), eve::sound::Decoder::getBuffer(), n , 以及 eve::sound::Decoder::rewind().

◆ getBalance()

float eve::audio::Source::getBalance ( ) const
inlinenoexcept

Returns the balance in [-1,1].

在文件 Source.h 第 122 行定义.

◆ getChannelCount()

int eve::audio::Source::getChannelCount ( ) const

Channel count of the bound buffer/decoder (1 or 2), or 0 when unknown.

在文件 Source.cpp 第 116 行定义.

引用了 eve::sound::Decoder::getChannelCount() , 以及 eve::sound::SoundData::getChannelCount().

被这些函数引用 setBalance() , 以及 setSpatialBlend().

◆ getDuration()

double eve::audio::Source::getDuration ( ) const

Total duration in seconds (0 for live/unbounded streams).

在文件 Source.cpp 第 265 行定义.

引用了 eve::sound::Decoder::getDuration() , 以及 eve::sound::SoundData::getDuration().

被这些函数引用 eve::audio_editing::AudioSourceTransportBackend::duration().

◆ getFadeWeight()

float eve::audio::Source::getFadeWeight ( ) const
inlinenoexcept

Fade progress in [0,1]; 1 when idle.

在文件 Source.h 第 103 行定义.

◆ getPitch()

float eve::audio::Source::getPitch ( ) const

Returns the pitch.

在文件 Source.cpp 第 231 行定义.

◆ getRolloffFactor()

float eve::audio::Source::getRolloffFactor ( ) const
inlinenoexcept

Returns the rolloff factor.

在文件 Source.h 第 127 行定义.

◆ getSpatialBlend()

float eve::audio::Source::getSpatialBlend ( ) const
inlinenoexcept

Returns the spatial blend in [0,1].

在文件 Source.h 第 113 行定义.

◆ getVolume()

float eve::audio::Source::getVolume ( ) const

Returns the audible user volume after the last advanceFade (or committed volume).

在文件 Source.cpp 第 225 行定义.

◆ isFading()

bool eve::audio::Source::isFading ( ) const
inlinenoexcept

True while a fade envelope is active.

在文件 Source.h 第 105 行定义.

◆ isLooping()

bool eve::audio::Source::isLooping ( ) const

True when looping.

在文件 Source.cpp 第 237 行定义.

◆ isPlaying()

bool eve::audio::Source::isPlaying ( ) const

True when playing.

在文件 Source.cpp 第 212 行定义.

引用了 state.

被这些函数引用 eve::audio::applyUnderwaterAudio(), eve::audio_editing::AudioSourceTransportBackend::playing() , 以及 pump().

◆ isRelative()

bool eve::audio::Source::isRelative ( ) const
inlinenoexcept

True when the source is head-relative.

在文件 Source.h 第 77 行定义.

◆ isStreaming()

bool eve::audio::Source::isStreaming ( ) const
inline

True when streaming.

在文件 Source.h 第 133 行定义.

◆ pause()

void eve::audio::Source::pause ( )

Pauses playback, keeping the play position.

在文件 Source.cpp 第 175 行定义.

被这些函数引用 eve::audio_editing::AudioSourceTransportBackend::pause().

◆ play()

void eve::audio::Source::play ( )

Starts (or resumes) playback.

在文件 Source.cpp 第 161 行定义.

引用了 eve::audio::Audio::notifyWorker().

被这些函数引用 eve::audio::applyUnderwaterAudio() , 以及 eve::audio_editing::AudioSourceTransportBackend::play().

◆ pump()

void eve::audio::Source::pump ( )

Main thread: queues/unqueues AL buffers for a streaming source.

在文件 Source.cpp 第 456 行定义.

引用了 b, eve::audio::PcmChunk::bytes, isPlaying(), eve::audio::Audio::notifyWorker(), q , 以及 queued.

◆ seek()

bool eve::audio::Source::seek ( double  seconds)

Seeks to a time in seconds; false when seeking is unsupported.

在文件 Source.cpp 第 239 行定义.

引用了 eve::sound::Decoder::isSeekable(), eve::audio::Audio::notifyWorker(), eve::sound::Decoder::seek() , 以及 stop().

被这些函数引用 eve::audio_editing::AudioSourceTransportBackend::seek().

◆ setAttenuationDistances()

void eve::audio::Source::setAttenuationDistances ( float  ref,
float  max 
)

Sets OpenAL reference and maximum attenuation distances.

在文件 Source.cpp 第 288 行定义.

引用了 max.

◆ setBalance()

Result< void > eve::audio::Source::setBalance ( float  balance)

Stereo/ambient balance in [-1,1] (left..right).

Prefers AL_EXT_STEREO_ANGLES. Without it, relative mono uses position.x; relative stereo without the extension fails.

在文件 Source.cpp 第 325 行定义.

引用了 channels, eve::Result< T >::failure(), getChannelCount() , 以及 eve::Result< T >::success().

◆ setDirection()

void eve::audio::Source::setDirection ( float  x,
float  y,
float  z 
)

Sets the source directional cone orientation.

在文件 Source.cpp 第 283 行定义.

引用了 x, y , 以及 z.

◆ setLooping()

void eve::audio::Source::setLooping ( bool  l)

Enables/disables looping.

在文件 Source.cpp 第 233 行定义.

被这些函数引用 eve::audio::applyUnderwaterAudio() , 以及 eve::audio_editing::AudioSourceTransportBackend::setNativeLooping().

◆ setPitch()

void eve::audio::Source::setPitch ( float  p)

Sets playback pitch (clamped to >= 0).

在文件 Source.cpp 第 227 行定义.

引用了 p.

◆ setPosition()

void eve::audio::Source::setPosition ( float  x,
float  y,
float  z 
)

Sets the source position in world units.

在文件 Source.cpp 第 272 行定义.

引用了 x, y , 以及 z.

◆ setRelative()

void eve::audio::Source::setRelative ( bool  relative)

Makes the source ignore the listener position (head-relative).

在文件 Source.cpp 第 284 行定义.

引用了 relative.

被这些函数引用 setSpatialBlend().

◆ setRolloffFactor()

Result< void > eve::audio::Source::setRolloffFactor ( float  factor)

Sets OpenAL rolloff factor (clamped to >= 0).

在文件 Source.cpp 第 294 行定义.

引用了 eve::Result< T >::failure() , 以及 eve::Result< T >::success().

◆ setSpatialBlend()

Result< void > eve::audio::Source::setSpatialBlend ( float  blend)

Continuous 2D/3D mix: 0 = ambient bed (relative, no rolloff), 1 = full world.

Stereo with blend > 0 requires AL_SOFT_source_spatialize.

在文件 Source.cpp 第 302 行定义.

引用了 AL_SOURCE_SPATIALIZE_SOFT, blend, channels, eve::Result< T >::failure(), getChannelCount(), setRelative() , 以及 eve::Result< T >::success().

◆ setVelocity()

void eve::audio::Source::setVelocity ( float  x,
float  y,
float  z 
)

Sets the source velocity (used by OpenAL doppler).

在文件 Source.cpp 第 282 行定义.

引用了 x, y , 以及 z.

◆ setVolume()

void eve::audio::Source::setVolume ( float  v)

Sets source gain (clamped to >= 0). Does not cancel an active fade target.

在文件 Source.cpp 第 218 行定义.

引用了 v.

被这些函数引用 eve::audio::applyUnderwaterAudio().

◆ stop()

void eve::audio::Source::stop ( )

Stops playback and rewinds the play position.

在文件 Source.cpp 第 180 行定义.

引用了 b, queued , 以及 eve::sound::Decoder::rewind().

被这些函数引用 advanceFade(), eve::audio::applyUnderwaterAudio(), seek(), eve::audio_editing::AudioSourceTransportBackend::stop() , 以及 ~Source().

◆ tell()

double eve::audio::Source::tell ( ) const

Current play time in seconds.

在文件 Source.cpp 第 259 行定义.

被这些函数引用 eve::audio_editing::AudioSourceTransportBackend::tell().

友元及相关函数文档

◆ Audio

friend class Audio
friend

在文件 Source.h 第 145 行定义.


该类的文档由以下文件生成: