-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "./GainEffect.hpp" | ||
|
||
namespace Dynamo::Sound { | ||
Sound &GainEffect::process(Sound &src, | ||
u32 offset, | ||
u32 length, | ||
ListenerSet &listeners) { | ||
for (u32 c = 0; c < src.channels(); c++) { | ||
for (u32 f = 0; f < length; f++) { | ||
_output[c][f] = src[c][f + offset] * _gain; | ||
} | ||
} | ||
return _output; | ||
} | ||
} // namespace Dynamo::Sound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "../../Types.hpp" | ||
#include "../EffectNode.hpp" | ||
|
||
namespace Dynamo::Sound { | ||
/** | ||
* @brief Gain filter implementation. | ||
* | ||
*/ | ||
class GainEffect : public EffectNode { | ||
f32 _gain; | ||
Sound _output; | ||
|
||
public: | ||
/** | ||
* @brief Set the position of the sound source. | ||
* | ||
* @param position | ||
*/ | ||
inline void set_gain(f32 gain) { _gain = gain; } | ||
|
||
Sound &process(Sound &src, | ||
u32 offset, | ||
u32 length, | ||
ListenerSet &listeners) override; | ||
}; | ||
} // namespace Dynamo::Sound |