11#ifndef INCGUARD_MGL_AUDIO_SOURCE_H_1610744589
12#define INCGUARD_MGL_AUDIO_SOURCE_H_1610744589
31 : _sourceInstance(sourceInstance)
40 constexpr Source() noexcept = default;
52 Attach(voiceKey, isAutoRemove);
89 if (
auto source = _sourceInstance.lock(); source !=
nullptr)
91 if (!source->IsPlaying() || source->IsPaused())
97 source->SetAutoRemove(
true);
113 return !_sourceInstance.expired();
128 bool Play(
VoiceKey voiceKey,
bool isAutoRemove =
true, uint32_t trackIndex = 0,
LoopType loopType = LoopType::ResourceDefault,
float volume = 1.0f) noexcept
130 if (!
Attach(voiceKey, isAutoRemove))
135 return Play(trackIndex, loopType, volume);
148 bool Play(uint32_t trackIndex = 0,
LoopType loopType = LoopType::ResourceDefault,
float volume = 1.0f) noexcept
150 if (
auto source = _sourceInstance.lock(); source !=
nullptr)
152 return source->Play(trackIndex, loopType, volume);
164 void Pause(
bool isEnabled =
true) noexcept
166 if (
auto source = _sourceInstance.lock(); source !=
nullptr)
168 source->Pause(isEnabled);
192 if (
const auto source = _sourceInstance.lock(); source !=
nullptr)
194 return source->IsPaused();
207 if (
const auto source = _sourceInstance.lock(); source !=
nullptr)
223 if (
const auto source = _sourceInstance.lock(); source !=
nullptr)
225 source->SetVolume(volume);
238 void SetVolume(
float volume,
float fadeTimeSec,
bool isAutoStop =
false) noexcept
240 if (
const auto source = _sourceInstance.lock(); source !=
nullptr)
243 source->SetVolume(volume, fadeTimeSec, samplesPerSec, isAutoStop);
254 void Fadeout(
float fadeTimeSec,
bool isAutoStop =
true) noexcept
256 SetVolume(0.0f, fadeTimeSec, isAutoStop);
267 if (
const auto source = _sourceInstance.lock(); source !=
nullptr)
269 return source->GetVolume();
284 if (
const auto source = _sourceInstance.lock(); source !=
nullptr)
286 return source->IsPlaying();
301 if (
const auto source = _sourceInstance.lock(); source !=
nullptr)
303 return source->IsFading();
320 : _sourceInstance(std::move(other._sourceInstance))
336 _sourceInstance = std::move(other._sourceInstance);
オーディオソースクラス
Definition mgl_audio_source.h:22
Source(Source &&other) noexcept
ムーブコンストラクタ
Definition mgl_audio_source.h:319
bool IsAttached() const noexcept
ソースがボイスと関連付けられているかを取得
Definition mgl_audio_source.h:111
bool IsPlaying() const noexcept
再生中かどうかを取得
Definition mgl_audio_source.h:282
Source(const SharedSourceInstance &sourceInstance) noexcept
コンストラクタ
Definition mgl_audio_source.h:30
void Pause(bool isEnabled=true) noexcept
一時停止
Definition mgl_audio_source.h:164
bool Play(VoiceKey voiceKey, bool isAutoRemove=true, uint32_t trackIndex=0, LoopType loopType=LoopType::ResourceDefault, float volume=1.0f) noexcept
アタッチして再生
Definition mgl_audio_source.h:128
void SetVolume(float volume) noexcept
音量の設定
Definition mgl_audio_source.h:221
void Resume() noexcept
再開
Definition mgl_audio_source.h:178
void Stop() noexcept
停止要求
Definition mgl_audio_source.h:205
void SetVolume(float volume, float fadeTimeSec, bool isAutoStop=false) noexcept
変化時間を指定して音量を設定
Definition mgl_audio_source.h:238
constexpr Source() noexcept=default
コンストラクタ
bool Play(uint32_t trackIndex=0, LoopType loopType=LoopType::ResourceDefault, float volume=1.0f) noexcept
アタッチ済みのボイスを再生
Definition mgl_audio_source.h:148
bool IsFading() const noexcept
フェード中かどうかを取得
Definition mgl_audio_source.h:299
bool IsPaused() const noexcept
一時停止の状態を取得
Definition mgl_audio_source.h:190
~Source() noexcept
デストラクタ
Definition mgl_audio_source.h:60
Source & operator=(Source &&other) noexcept
ムーブ代入演算
Definition mgl_audio_source.h:331
bool Attach(VoiceKey voiceKey, bool isAutoRemove) noexcept
ボイスとソースの関連付け
Definition mgl_audio_source.h:74
float GetVolume() const noexcept
ボリュームの取得
Definition mgl_audio_source.h:265
void Detach() noexcept
ボイスとソースの関連付けを解除
Definition mgl_audio_source.h:87
void Fadeout(float fadeTimeSec, bool isAutoStop=true) noexcept
フェードアウト
Definition mgl_audio_source.h:254
static Player & GetInstance() noexcept
Definition mgl_singleton.h:74
VoiceKey
ボイスキー
Definition mgl_audio_defs.h:22
LoopType
ループタイプ
Definition mgl_audio_defs.h:71
std::weak_ptr< SourceInstance > WeakSourceInstance
弱参照のソースインスタンス
Definition mgl_audio_source_instance.h:190
std::shared_ptr< SourceInstance > SharedSourceInstance
共有ソースインスタンス
Definition mgl_audio_source_instance.h:187