audio_effect_phaser.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef AUDIO_EFFECT_PHASER_H
  2. #define AUDIO_EFFECT_PHASER_H
  3. #include "servers/audio/audio_effect.h"
  4. class AudioEffectPhaser;
  5. class AudioEffectPhaserInstance : public AudioEffectInstance {
  6. GDCLASS(AudioEffectPhaserInstance,AudioEffectInstance)
  7. friend class AudioEffectPhaser;
  8. Ref<AudioEffectPhaser> base;
  9. float phase;
  10. AudioFrame h;
  11. class AllpassDelay{
  12. float a, h;
  13. public:
  14. _ALWAYS_INLINE_ void delay( float d ) {
  15. a = (1.f - d) / (1.f + d);
  16. }
  17. _ALWAYS_INLINE_ float update( float s ){
  18. float y = s * -a + h;
  19. h = y * a + s;
  20. return y;
  21. }
  22. AllpassDelay() { a =0; h = 0;}
  23. };
  24. AllpassDelay allpass[2][6];
  25. public:
  26. virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
  27. };
  28. class AudioEffectPhaser : public AudioEffect {
  29. GDCLASS(AudioEffectPhaser,AudioEffect)
  30. friend class AudioEffectPhaserInstance;
  31. float range_min;
  32. float range_max;
  33. float rate;
  34. float feedback;
  35. float depth;
  36. protected:
  37. static void _bind_methods();
  38. public:
  39. Ref<AudioEffectInstance> instance();
  40. void set_range_min_hz(float p_hz);
  41. float get_range_min_hz() const;
  42. void set_range_max_hz(float p_hz);
  43. float get_range_max_hz() const;
  44. void set_rate_hz(float p_hz);
  45. float get_rate_hz() const;
  46. void set_feedback(float p_fbk);
  47. float get_feedback() const;
  48. void set_depth(float p_depth);
  49. float get_depth() const;
  50. AudioEffectPhaser();
  51. };
  52. #endif // AUDIO_EFFECT_PHASER_H