Debian Codegraph @

servers/audio/effects/reverb_filter.h

raw symbols SCIP
1 /**************************************************************************/
2 /* reverb_filter.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 class Reverb {
34 public:
35 enum {
36 INPUT_BUFFER_MAX_SIZE = 1024,
37
38 };
39
40 private:
41 enum {
42 MAX_COMBS = 8,
43 MAX_ALLPASS = 4,
44 MAX_ECHO_MS = 500
45
46 };
47
48 static const float comb_tunings[MAX_COMBS];
49 static const float allpass_tunings[MAX_ALLPASS];
50
51 struct Comb {
52 int size = 0;
53 float *buffer = nullptr;
54 float feedback = 0;
55 float damp = 0; //lowpass
56 float damp_h = 0; //history
57 int pos = 0;
58 int extra_spread_frames = 0;
59
60 Comb() {}
61 };
62
63 struct AllPass {
64 int size = 0;
65 float *buffer = nullptr;
66 int pos = 0;
67 int extra_spread_frames = 0;
68 AllPass() {}
69 };
70
71 Comb comb[MAX_COMBS];
72 AllPass allpass[MAX_ALLPASS];
73 float *input_buffer = nullptr;
74 float *echo_buffer = nullptr;
75 int echo_buffer_size = 0;
76 int echo_buffer_pos = 0;
77
78 float hpf_h1 = 0.0f;
79 float hpf_h2 = 0.0f;
80
81 struct Parameters {
82 float room_size;
83 float damp;
84 float wet;
85 float dry;
86 float mix_rate;
87 float extra_spread_base;
88 float extra_spread;
89 float predelay;
90 float predelay_fb;
91 float hpf;
92 } params;
93
94 void configure_buffers();
95 void update_parameters();
96 void clear_buffers();
97
98 public:
99 void set_room_size(float p_size);
100 void set_damp(float p_damp);
101 void set_wet(float p_wet);
102 void set_dry(float p_dry);
103 void set_predelay(float p_predelay); // in ms
104 void set_predelay_feedback(float p_predelay_fb); // in ms
105 void set_highpass(float p_frq);
106 void set_mix_rate(float p_mix_rate);
107 void set_extra_spread(float p_spread);
108 void set_extra_spread_base(float p_sec);
109
110 void process(float *p_src, float *p_dst, int p_frames);
111
112 Reverb();
113
114 ~Reverb();
115 };