Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 99bc4d5

Browse files
committed
Fix merge issue
1 parent 94a71b5 commit 99bc4d5

4 files changed

Lines changed: 52 additions & 37 deletions

File tree

module/includes/components/AudioSource.hpp

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,50 @@ namespace sw
2323

2424
class SW_GRAPH_MODULE_EXPORT AudioSource : public sw::Component
2525
{
26-
private:
27-
ALuint m_source;
28-
bool m_loop;
29-
float m_currentSample;
30-
float m_startPoint;
31-
float m_startLoopPoint;
32-
float m_endPoint;
33-
float m_endLoopPoint;
34-
bool m_randomized;
35-
int m_maxOccurence;
36-
std::vector<std::string> m_audios;
37-
std::string m_last;
38-
int m_lastOccurence;
26+
private:
27+
ALuint m_source;
28+
bool m_loop;
29+
float m_currentSample;
30+
float m_startPoint;
31+
float m_startLoopPoint;
32+
float m_endPoint;
33+
float m_endLoopPoint;
34+
bool m_randomized;
35+
int m_maxOccurence;
36+
std::vector<std::string> m_audios;
37+
std::string m_last;
38+
int m_lastOccurence;float m_volume;
39+
float m_pitch;
40+
bool m_playOnStart;
41+
YAML::Node save() const;
42+
43+
void playOnStart();
3944

4045
void defineBuffer(std::string name);
4146
std::string randomHandler();
4247

43-
public:
44-
explicit AudioSource(sw::GameObject& entity);
45-
~AudioSource() override;
48+
public:
49+
explicit AudioSource(sw::GameObject& entity);
50+
~AudioSource() override;
51+
52+
AudioSource& addAudio(std::string audio);
53+
AudioSource& play();
54+
AudioSource& pause();
55+
AudioSource& stop();
56+
AudioSource& setVolume(float volume);
57+
AudioSource& setPitch(float pitch);
58+
AudioSource& setLoop(bool loop);
59+
AudioSource& setStartPoint(float second);
60+
AudioSource& setStartLoopPoint(float second);
61+
AudioSource& setEndPoint(float second);
62+
AudioSource& setEndLoopPoint(float second);
63+
AudioSource& setRandomized(bool random);
64+
AudioSource& setMaxOccurrence(int occurence);
65+
AudioSource& setPlayOnStart(bool value);
4666

47-
AudioSource& addAudio(std::string audio);
48-
AudioSource& play();
49-
AudioSource& pause();
50-
AudioSource& stop();
51-
AudioSource& setVolume(float volume);
52-
AudioSource& setPitch(float pitch);
53-
AudioSource& setLoop(bool loop);
54-
AudioSource& setStartPoint(float second);
55-
AudioSource& setStartLoopPoint(float second);
56-
AudioSource& setEndPoint(float second);
57-
AudioSource& setEndLoopPoint(float second);
58-
AudioSource& setRandomized(bool random);
59-
AudioSource& setMaxOccurence(int occurence);
67+
[[nodiscard]]const bool& isPlayOnStart() const;
6068

61-
friend AudioSourceManager;
69+
friend AudioSourceManager;
6270
};
6371
}
6472

module/includes/managers/AudioSourceManager.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace sw
2424
YAML::Node save() const;
2525
void onUpdate() override {};
2626
void onLoad(YAML::Node& node) override;
27-
void onUpdate() override;
2827
}; // class AudioSourceManager
2928

3029
} // namespace sw

module/sources/components/AudioSource.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ m_randomized(false),
2424
m_maxOccurence(-1),
2525
m_audios(),
2626
m_last(),
27-
m_lastOccurence(0)
27+
m_lastOccurence(0),
28+
m_volume(),
29+
m_pitch(),
30+
m_playOnStart(true)
2831
{
2932
alGenSources(1, &m_source);
3033
gameObject.scene().eventManager["Start"].subscribe(this, &AudioSource::playOnStart);
@@ -36,6 +39,12 @@ sw::AudioSource::~AudioSource() noexcept
3639
alDeleteSources(1, &m_source);
3740
}
3841

42+
void sw::AudioSource::playOnStart()
43+
{
44+
if (m_playOnStart)
45+
play();
46+
}
47+
3948
void sw::AudioSource::defineBuffer(std::string name)
4049
{
4150
auto buffer = sw::OpenResources::m_naudio[name];
@@ -150,9 +159,9 @@ sw::AudioSource &sw::AudioSource::setRandomized(bool random)
150159
return (*this);
151160
}
152161

153-
sw::AudioSource &sw::AudioSource::setMaxOccurence(int occurence)
162+
sw::AudioSource &sw::AudioSource::setMaxOccurrence(int occurrence)
154163
{
155-
m_maxOccurence = occurence;
164+
m_maxOccurence = occurrence;
156165
return (*this);
157166
}
158167

@@ -161,15 +170,14 @@ YAML::Node sw::AudioSource::save() const
161170
YAML::Node node;
162171

163172
node["entity_name"] = name();
164-
node["audioFile"] = m_audioFile;
165173
node["volume"] = m_volume;
166174
node["pitch"] = m_pitch;
167175
node["playOnStart"] = m_playOnStart;
168176

169177
return (node);
170178
}
171179

172-
const bool &sw::AudioSource::getPlayOnStart()
180+
const bool &sw::AudioSource::isPlayOnStart() const
173181
{
174182
return (m_playOnStart);
175183
}

module/sources/managers/AudioSourceManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void sw::AudioSourceManager::onLoad(YAML::Node& node)
1212
{
1313
for (auto component : node["components"]) {
1414
sw::AudioSource& audio = createComponent(component["entity_name"].as<std::string>());
15-
audio.setAudio(component["audioFile"].as<std::string>());
15+
//audio.setAudio(component["audioFile"].as<std::string>());
1616
audio.setVolume(component["volume"].as<float>());
1717
audio.setPitch(component["pitch"].as<float>());
1818
audio.m_playOnStart = component["playOnStart"].as<bool>();

0 commit comments

Comments
 (0)