载入中...
搜索中...
未找到
DialogueVoice.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Module.h"
6
7#include <string>
8#include <unordered_map>
9#include <vector>
10
11namespace eve::audio {
12class Source;
13}
14
15namespace eve::dialogue {
16
19public:
22 ~DialogueVoice() override;
23
25 bool registerClip(const std::string& lineId, const std::string& locale, float duration,
26 const std::string& envelope);
28 bool bindSource(const std::string& lineId, const std::string& locale, audio::Source* source);
30 bool hasClip(const std::string& lineId, const std::string& locale) const;
32 void clear();
33
35 bool play(const std::string& lineId, const std::string& locale);
37 void stop();
39 void update(float dt);
41 bool isPlaying() const;
43 float getTime() const;
45 float getDuration() const;
47 float getAmplitude() const;
49 bool shouldAutoAdvance() const;
51 std::string getCurrentLineId() const { return currentLineId_; }
53 void setEnvelopeRate(float samplesPerSecond);
55 float getEnvelopeRate() const { return envelopeRate_; }
56
57private:
58 struct Clip {
59 std::string lineId;
60 std::string locale;
61 float duration = 0.f;
62 std::vector<float> envelope;
63 audio::Source* source = nullptr;
64 };
65
66 static std::string key(const std::string& lineId, const std::string& locale);
67 Clip* resolve(const std::string& lineId, const std::string& locale);
68 const Clip* resolve(const std::string& lineId, const std::string& locale) const;
69
70 std::unordered_map<std::string, Clip> clips_;
71 Clip* current_ = nullptr;
72 std::string currentLineId_;
73 float elapsed_ = 0.f;
74 float envelopeRate_ = 30.f;
75 bool simulatedPlaying_ = false;
76};
77
78} // namespace eve::dialogue
float duration
#define EVENGINE_API_ORCHESTRATION
Definition Export.h:111
std::uint32_t key
const UnitySourceAsset & source
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control ex...
Definition Source.h:30
Localized voice assets, duration-based advance, and amplitude lip sync.
float getEnvelopeRate() const
Returns the envelope rate.
std::string getCurrentLineId() const
Returns the current line id.