MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_audio_wave_stream_voice.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_AUDIO_WAVE_STREAM_VOICE_H_1611969320
12#define INCGUARD_MGL_AUDIO_WAVE_STREAM_VOICE_H_1611969320
13
18
19#include <condition_variable>
20#include <future>
21#include <mutex>
22#include <thread>
23
24namespace MGL::Audio
25{
27class WaveStreamVoice : public Voice
28{
29public:
30 WaveStreamVoice(VoiceKey key, const File::PathView &path, bool isLoop = false, uint32_t loopFrame = 0) noexcept;
31 ~WaveStreamVoice() noexcept override;
32
33 bool Load() noexcept override;
34 bool GetSample(float &outDataL, float &outDataR) noexcept override;
35 bool Start(uint32_t trackIndex, LoopType loopType) noexcept override;
36 void Stop() noexcept override;
37
38 /* ------------------------------------------------------------------------- */
44 /* ------------------------------------------------------------------------- */
45 uint32_t GetTotalFrame([[maybe_unused]] uint32_t trackIndex) const noexcept override
46 {
47 return _totalFrame;
48 }
49
50 /* ------------------------------------------------------------------------- */
57 /* ------------------------------------------------------------------------- */
58 bool IsLoop([[maybe_unused]] uint32_t trackIndex) const noexcept override
59 {
60 return _isDefaultLoop;
61 }
62
63 /* ------------------------------------------------------------------------- */
69 /* ------------------------------------------------------------------------- */
70 uint32_t GetLoopFrame([[maybe_unused]] uint32_t trackIndex) const noexcept override
71 {
72 return _loopFrame;
73 }
74
75 /* ------------------------------------------------------------------------- */
80 /* ------------------------------------------------------------------------- */
81 uint32_t GetTrackCount() const noexcept override
82 {
83 return 1;
84 }
85
86private:
87 bool LoadWaveFile() noexcept;
88 void ReadSample() noexcept;
89
90 File::Path _path;
91 uint32_t _totalFrame{0};
92 uint32_t _loopFrame;
93 WaveLoader _wave;
94 StreamQueue _streamQueue;
95 std::atomic<bool> _isBusy{false};
96 std::atomic<bool> _isFinished{false};
97 bool _isLoop{false};
98 bool _isDefaultLoop;
99
100 std::thread _readSampleThread;
101 std::future<void> _loadFuture;
102
103 std::mutex _mutex;
104 std::condition_variable _condition;
105};
106} // namespace MGL::Audio
107
108#endif // INCGUARD_MGL_AUDIO_WAVE_STREAM_VOICE_H_1611969320
109
110// vim: et ts=4 sw=4 sts=4
MGL オーディオボイス
Definition mgl_audio_voice.h:24
MGL WAVEストリームボイス
Definition mgl_audio_wave_stream_voice.h:28
~WaveStreamVoice() noexcept override
デストラクタ
Definition mgl_audio_wave_stream_voice.cc:50
bool Start(uint32_t trackIndex, LoopType loopType) noexcept override
ボイスの開始処理
Definition mgl_audio_wave_stream_voice.cc:142
uint32_t GetLoopFrame(uint32_t trackIndex) const noexcept override
指定したトラックのループフレームを取得
Definition mgl_audio_wave_stream_voice.h:70
bool IsLoop(uint32_t trackIndex) const noexcept override
指定したトラックのループ設定を取得
Definition mgl_audio_wave_stream_voice.h:58
bool GetSample(float &outDataL, float &outDataR) noexcept override
ダイナミックボイスのサンプルの取得
Definition mgl_audio_wave_stream_voice.cc:250
void Stop() noexcept override
ボイスの再生終了
Definition mgl_audio_wave_stream_voice.cc:171
bool Load() noexcept override
ボイスの読み込み処理
Definition mgl_audio_wave_stream_voice.cc:68
uint32_t GetTrackCount() const noexcept override
ボイスが持つトラックの数を取得
Definition mgl_audio_wave_stream_voice.h:81
WaveStreamVoice(VoiceKey key, const File::PathView &path, bool isLoop=false, uint32_t loopFrame=0) noexcept
コンストラクタ
Definition mgl_audio_wave_stream_voice.cc:35
uint32_t GetTotalFrame(uint32_t trackIndex) const noexcept override
ボイスの最大フレーム数を取得
Definition mgl_audio_wave_stream_voice.h:45
文字列の参照のみを行うファイルパスクラス
Definition mgl_file_path_view.h:20
VoiceKey
ボイスキー
Definition mgl_audio_defs.h:22
LoopType
ループタイプ
Definition mgl_audio_defs.h:71
MGL オーディオストリームキュー
MGL オーディオボイス
MGL WAVEローダー
MGL STL文字列クラスの代替