Skip to content

Commit 88e075b

Browse files
committed
Move some methods from .h to .cpp
1 parent a044a9f commit 88e075b

File tree

2 files changed

+52
-34
lines changed

2 files changed

+52
-34
lines changed

Source/Entities/SoundContainer.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,37 @@ namespace RTE {
244244
return nullptr;
245245
}
246246

247+
void SoundContainer::SetCustomPanValue(float customPanValue) {
248+
m_CustomPanValue = std::clamp(customPanValue, -1.0f, 1.0f);
249+
if (IsBeingPlayed()) {
250+
g_AudioMan.ChangeSoundContainerPlayingChannelsCustomPanValue(this);
251+
}
252+
}
253+
254+
void SoundContainer::SetPosition(const Vector& newPosition) {
255+
if (!m_Immobile && newPosition != m_Pos) {
256+
m_Pos = newPosition;
257+
if (IsBeingPlayed()) {
258+
g_AudioMan.ChangeSoundContainerPlayingChannelsPosition(this);
259+
}
260+
}
261+
}
262+
263+
void SoundContainer::SetVolume(float newVolume) {
264+
newVolume = std::clamp(newVolume, 0.0F, 10.0F);
265+
if (IsBeingPlayed()) {
266+
g_AudioMan.ChangeSoundContainerPlayingChannelsVolume(this, newVolume);
267+
}
268+
m_Volume = newVolume;
269+
}
270+
271+
void SoundContainer::SetPitch(float newPitch) {
272+
m_Pitch = std::clamp(newPitch, 0.125F, 8.0F);
273+
if (IsBeingPlayed()) {
274+
g_AudioMan.ChangeSoundContainerPlayingChannelsPitch(this);
275+
}
276+
}
277+
247278
bool SoundContainer::Play(int player) {
248279
if (HasAnySounds()) {
249280
if (IsBeingPlayed()) {
@@ -258,6 +289,20 @@ namespace RTE {
258289
return false;
259290
}
260291

292+
bool SoundContainer::Stop(int player) {
293+
return (HasAnySounds() && IsBeingPlayed()) ? g_AudioMan.StopSoundContainerPlayingChannels(this, player) : false;
294+
}
295+
296+
bool SoundContainer::Restart(int player) {
297+
return (HasAnySounds() && IsBeingPlayed()) ? g_AudioMan.StopSoundContainerPlayingChannels(this, player) && g_AudioMan.PlaySoundContainer(this, player) : false;
298+
}
299+
300+
void SoundContainer::FadeOut(int fadeOutTime) {
301+
if (IsBeingPlayed()) {
302+
return g_AudioMan.FadeOutSoundContainerPlayingChannels(this, fadeOutTime);
303+
}
304+
}
305+
261306
FMOD_RESULT SoundContainer::UpdateSoundProperties() {
262307
FMOD_RESULT result = FMOD_OK;
263308

Source/Entities/SoundContainer.h

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,7 @@ namespace RTE {
167167

168168
/// Sets the custom pan value of this SoundContainer. Clamped between -1 and 1.
169169
/// @param customPanValue The new custom pan value.
170-
void SetCustomPanValue(float customPanValue) {
171-
m_CustomPanValue = std::clamp(customPanValue, -1.0f, 1.0f);
172-
if (IsBeingPlayed()) {
173-
g_AudioMan.ChangeSoundContainerPlayingChannelsCustomPanValue(this);
174-
}
175-
}
170+
void SetCustomPanValue(float customPanValue);
176171

177172
/// Gets the panning strength multiplier of this SoundContainer.
178173
/// @return A float with the panning strength multiplier.
@@ -224,41 +219,23 @@ namespace RTE {
224219
/// Sets the position of the SoundContainer's sounds while they're playing.
225220
/// @param position The new position to play the SoundContainer's sounds.
226221
/// @return Whether this SoundContainer's attenuation setting was successful.
227-
void SetPosition(const Vector& newPosition) {
228-
if (!m_Immobile && newPosition != m_Pos) {
229-
m_Pos = newPosition;
230-
if (IsBeingPlayed()) {
231-
g_AudioMan.ChangeSoundContainerPlayingChannelsPosition(this);
232-
}
233-
}
234-
}
222+
void SetPosition(const Vector& newPosition);
235223

236224
/// Gets the volume the sounds in this SoundContainer are played at. Note that this does not factor volume changes due to the SoundContainer's position.
237225
/// @return The volume the sounds in this SoundContainer are played at.
238226
float GetVolume() const { return m_Volume; }
239227

240228
/// Sets the volume sounds in this SoundContainer should be played at. Note that this does not factor volume changes due to the SoundContainer's position. Does not affect currently playing sounds.
241229
/// @param newVolume The new volume sounds in this SoundContainer should be played at. Limited between 0 and 10.
242-
void SetVolume(float newVolume) {
243-
newVolume = std::clamp(newVolume, 0.0F, 10.0F);
244-
if (IsBeingPlayed()) {
245-
g_AudioMan.ChangeSoundContainerPlayingChannelsVolume(this, newVolume);
246-
}
247-
m_Volume = newVolume;
248-
}
230+
void SetVolume(float newVolume);
249231

250232
/// Gets the pitch the sounds in this SoundContainer are played at. Note that this does not factor in global pitch.
251233
/// @return The pitch the sounds in this SoundContainer are played at.
252234
float GetPitch() const { return m_Pitch; }
253235

254236
/// Sets the pitch sounds in this SoundContainer should be played at and updates any playing instances accordingly.
255237
/// @param newPitch The new pitch sounds in this SoundContainer should be played at. Limited between 0.125 and 8 (8 octaves up or down).
256-
void SetPitch(float newPitch) {
257-
m_Pitch = std::clamp(newPitch, 0.125F, 8.0F);
258-
if (IsBeingPlayed()) {
259-
g_AudioMan.ChangeSoundContainerPlayingChannelsPitch(this);
260-
}
261-
}
238+
void SetPitch(float newPitch);
262239

263240
/// Gets the pitch variation the sounds in this SoundContainer are played at.
264241
/// @return The pitch variation the sounds in this SoundContainer are played at.
@@ -300,7 +277,7 @@ namespace RTE {
300277
/// Stops playback of this SoundContainer for a specific player.
301278
/// @param player Player to stop playback of this SoundContainer for.
302279
/// @return Whether this SoundContainer successfully stopped playing.
303-
bool Stop(int player) { return (HasAnySounds() && IsBeingPlayed()) ? g_AudioMan.StopSoundContainerPlayingChannels(this, player) : false; }
280+
bool Stop(int player);
304281

305282
/// Restarts playback of this SoundContainer for all players.
306283
/// @return Whether this SoundContainer successfully restarted its playback.
@@ -309,15 +286,11 @@ namespace RTE {
309286
/// Restarts playback of this SoundContainer for a specific player.
310287
/// @param player Player to restart playback of this SoundContainer for.
311288
/// @return Whether this SoundContainer successfully restarted its playback.
312-
bool Restart(int player) { return (HasAnySounds() && IsBeingPlayed()) ? g_AudioMan.StopSoundContainerPlayingChannels(this, player) && g_AudioMan.PlaySoundContainer(this, player) : false; }
289+
bool Restart(int player);
313290

314291
/// Fades out playback of the SoundContainer to 0 volume.
315292
/// @param fadeOutTime How long the fadeout should take.
316-
void FadeOut(int fadeOutTime = 1000) {
317-
if (IsBeingPlayed()) {
318-
return g_AudioMan.FadeOutSoundContainerPlayingChannels(this, fadeOutTime);
319-
}
320-
}
293+
void FadeOut(int fadeOutTime = 1000);
321294
#pragma endregion
322295

323296
#pragma region Miscellaneous

0 commit comments

Comments
 (0)