Debian Codegraph @

servers/audio/effects/audio_effect_delay.h

raw symbols SCIP
1 /**************************************************************************/
2 /* audio_effect_delay.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "servers/audio/audio_effect.h"
34
35 class AudioEffectDelay;
36
37 class AudioEffectDelayInstance : public AudioEffectInstance {
38 GDCLASS(AudioEffectDelayInstance, AudioEffectInstance);
39
40 friend class AudioEffectDelay;
41 Ref<AudioEffectDelay> base;
42
43 Vector<AudioFrame> ring_buffer;
44
45 unsigned int ring_buffer_pos;
46 unsigned int ring_buffer_mask;
47
48 /* feedback buffer */
49 Vector<AudioFrame> feedback_buffer;
50
51 unsigned int feedback_buffer_pos;
52
53 AudioFrame h;
54 void _process_chunk(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count);
55
56 public:
57 virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) override;
58 };
59
60 class AudioEffectDelay : public AudioEffect {
61 GDCLASS(AudioEffectDelay, AudioEffect);
62
63 friend class AudioEffectDelayInstance;
64 enum {
65 MAX_DELAY_MS = 3000,
66 MAX_TAPS = 2
67 };
68
69 float dry = 1.0f;
70
71 bool tap_1_active = true;
72 float tap_1_delay_ms = 250.0f;
73 float tap_1_level = -6.0f;
74 float tap_1_pan = 0.2f;
75
76 bool tap_2_active = true;
77 float tap_2_delay_ms = 500.0f;
78 float tap_2_level = -12.0f;
79 float tap_2_pan = -0.4f;
80
81 bool feedback_active = false;
82 float feedback_delay_ms = 340.0f;
83 float feedback_level = -6.0f;
84 float feedback_lowpass = 16000.0f;
85
86 protected:
87 static void _bind_methods();
88
89 public:
90 void set_dry(float p_dry);
91 float get_dry();
92
93 void set_tap1_active(bool p_active);
94 bool is_tap1_active() const;
95
96 void set_tap1_delay_ms(float p_delay_ms);
97 float get_tap1_delay_ms() const;
98
99 void set_tap1_level_db(float p_level_db);
100 float get_tap1_level_db() const;
101
102 void set_tap1_pan(float p_pan);
103 float get_tap1_pan() const;
104
105 void set_tap2_active(bool p_active);
106 bool is_tap2_active() const;
107
108 void set_tap2_delay_ms(float p_delay_ms);
109 float get_tap2_delay_ms() const;
110
111 void set_tap2_level_db(float p_level_db);
112 float get_tap2_level_db() const;
113
114 void set_tap2_pan(float p_pan);
115 float get_tap2_pan() const;
116
117 void set_feedback_active(bool p_active);
118 bool is_feedback_active() const;
119
120 void set_feedback_delay_ms(float p_delay_ms);
121 float get_feedback_delay_ms() const;
122
123 void set_feedback_level_db(float p_level_db);
124 float get_feedback_level_db() const;
125
126 void set_feedback_lowpass(float p_lowpass);
127 float get_feedback_lowpass() const;
128
129 Ref<AudioEffectInstance> instantiate() override;
130
131 AudioEffectDelay() {}
132 };