Skip to content

Commit

Permalink
Implement GainEffect node
Browse files Browse the repository at this point in the history
  • Loading branch information
SirBob01 committed May 17, 2023
1 parent 242377c commit 8580edc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Sound/Filters/GainEffect.cpp
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
28 changes: 28 additions & 0 deletions src/Sound/Filters/GainEffect.hpp
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

0 comments on commit 8580edc

Please sign in to comment.