RavEngine
Loading...
Searching...
No Matches
reverb_node.h
1/*
2Copyright 2018 Google Inc. All Rights Reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS-IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef RESONANCE_AUDIO_GRAPH_REVERB_NODE_H_
18#define RESONANCE_AUDIO_GRAPH_REVERB_NODE_H_
19
20#include "api/resonance_audio_api.h"
21#include "base/audio_buffer.h"
22#include "dsp/fft_manager.h"
23#include "dsp/reverb_onset_compensator.h"
24#include "dsp/spectral_reverb.h"
25#include "graph/system_settings.h"
26#include "node/processing_node.h"
27
28namespace vraudio {
29
30// Implements a spectral reverb producing a decorrelated stereo output with
31// onset compensated by a pair of convolution filters.
32class ReverbNode : public ProcessingNode {
33 public:
34 // Constructs a |ReverbNode|.
35 //
36 // @param system_settings Global system configuration.
37 // @param fft_manager Pointer to a manager to perform FFT transformations.
38 ReverbNode(const SystemSettings& system_settings, FftManager* fft_manager);
39
40 // Updates the |SpectralReverb| using the current room properties or RT60
41 // values depending on the system settings.
42 void Update();
43
44 protected:
45 // Implements ProcessingNode.
46 const AudioBuffer* AudioProcess(const NodeInput& input) override;
47
48 private:
49 // Global system configuration.
50 const SystemSettings& system_settings_;
51
52 // Current reverb properties.
53 ReverbProperties reverb_properties_;
54
55 // New reverb properties.
56 ReverbProperties new_reverb_properties_;
57
58 // Per band reverb time update step sizes.
59 std::vector<float> rt60_band_update_steps_;
60
61 // Update step size for the gain parameter.
62 float gain_update_step_;
63
64 // Denotes whether the rt60s are currently being updated.
65 bool rt60_updating_;
66
67 // Denotes whether the gain is currently being updated.
68 bool gain_updating_;
69
70 // Number of buffers to updae rt60s over.
71 float buffers_to_update_;
72
73 // DSP class to perform filtering associated with the reverb.
74 SpectralReverb spectral_reverb_;
75
76 // DSP class to perform spectral reverb onset compensation.
77 ReverbOnsetCompensator onset_compensator_;
78
79 // Number of frames of zeroed out data to be processed by the node to ensure
80 // the entire tail is rendered after input has ceased.
81 size_t num_frames_processed_on_empty_input_;
82
83 // Longest current reverb time, across all bands, in frames.
84 size_t reverb_length_frames_;
85
86 // Output buffers for mixing spectral reverb and compensator output.
87 AudioBuffer output_buffer_;
88 AudioBuffer compensator_output_buffer_;
89
90 // Silence mono buffer to render reverb tails during the absence of input
91 // buffers.
92 AudioBuffer silence_mono_buffer_;
93};
94
95} // namespace vraudio
96
97#endif // RESONANCE_AUDIO_GRAPH_REVERB_NODE_H_
Definition audio_buffer.h:78
Definition fft_manager.h:28
Definition processing_node.h:39
Definition processing_node.h:33
Definition reverb_node.h:32
Definition reverb_onset_compensator.h:32
Definition spectral_reverb.h:33
Definition system_settings.h:30
Definition resonance_audio_api.h:111