Amuse
EffectDelay.hpp
1 #ifndef __AMUSE_EFFECTDELAY_HPP__
2 #define __AMUSE_EFFECTDELAY_HPP__
3 
4 #include "EffectBase.hpp"
5 #include "Common.hpp"
6 #include <stdint.h>
7 #include <memory>
8 
9 namespace amuse
10 {
11 template <typename T>
13 
16 {
17 protected:
18  uint32_t x3c_delay[8];
19  uint32_t x48_feedback[8];
20  uint32_t x54_output[8];
21  bool m_dirty = true;
22 public:
23  template <typename T>
24  using ImpType = EffectDelayImp<T>;
25 
26  void setDelay(uint32_t delay)
27  {
28  delay = clamp(10u, delay, 5000u);
29  for (int i=0 ; i<8 ; ++i)
30  x3c_delay[i] = delay;
31  m_dirty = true;
32  }
33  void setChanDelay(int chanIdx, uint32_t delay)
34  {
35  delay = clamp(10u, delay, 5000u);
36  x3c_delay[chanIdx] = delay;
37  m_dirty = true;
38  }
39 
40  void setFeedback(uint32_t feedback)
41  {
42  feedback = clamp(0u, feedback, 100u);
43  for (int i=0 ; i<8 ; ++i)
44  x48_feedback[i] = feedback;
45  m_dirty = true;
46  }
47 
48  void setChanFeedback(int chanIdx, uint32_t feedback)
49  {
50  feedback = clamp(0u, feedback, 100u);
51  x48_feedback[chanIdx] = feedback;
52  m_dirty = true;
53  }
54 
55  void setOutput(uint32_t output)
56  {
57  output = clamp(0u, output, 100u);
58  for (int i=0 ; i<8 ; ++i)
59  x54_output[i] = output;
60  m_dirty = true;
61  }
62  void setChanOutput(int chanIdx, uint32_t output)
63  {
64  output = clamp(0u, output, 100u);
65  x54_output[chanIdx] = output;
66  m_dirty = true;
67  }
68 };
69 
71 template <typename T>
72 class EffectDelayImp : public EffectBase<T>, public EffectDelay
73 {
74  uint32_t x0_currentSize[8];
75  uint32_t xc_currentPos[8];
76  uint32_t x18_currentFeedback[8];
77  uint32_t x24_currentOutput[8];
79  std::unique_ptr<T[]> x30_chanLines[8];
81  uint32_t m_sampsPerMs;
82  uint32_t m_blockSamples;
83  void _update();
84 public:
85  EffectDelayImp(uint32_t initDelay, uint32_t initFeedback, uint32_t initOutput, double sampleRate);
86  void applyEffect(T* audio, size_t frameCount, const ChannelMap& chanMap);
87 };
88 
89 }
90 
91 #endif // __AMUSE_EFFECTDELAY_HPP__
uint32_t x48_feedback[8]
Definition: EffectDelay.hpp:19
uint32_t x3c_delay[8]
Definition: EffectDelay.hpp:18
uint32_t x54_output[8]
Definition: EffectDelay.hpp:20