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 const AudioBuffer *GetOutputBuffer() const;
45
46 protected:
47 // Implements ProcessingNode.
48 const AudioBuffer* AudioProcess(const NodeInput& input) override;
49
50 private:
51 // Global system configuration.
52 const SystemSettings& system_settings_;
53
54 // Current reverb properties.
55 ReverbProperties reverb_properties_;
56
57 // New reverb properties.
58 ReverbProperties new_reverb_properties_;
59
60 // Per band reverb time update step sizes.
61 std::vector<float> rt60_band_update_steps_;
62
63 // Update step size for the gain parameter.
64 float gain_update_step_;
65
66 // Denotes whether the rt60s are currently being updated.
67 bool rt60_updating_;
68
69 // Denotes whether the gain is currently being updated.
70 bool gain_updating_;
71
72 // Number of buffers to updae rt60s over.
73 float buffers_to_update_;
74
75 // DSP class to perform filtering associated with the reverb.
76 SpectralReverb spectral_reverb_;
77
78 // DSP class to perform spectral reverb onset compensation.
79 ReverbOnsetCompensator onset_compensator_;
80
81 // Number of frames of zeroed out data to be processed by the node to ensure
82 // the entire tail is rendered after input has ceased.
83 size_t num_frames_processed_on_empty_input_;
84
85 // Longest current reverb time, across all bands, in frames.
86 size_t reverb_length_frames_;
87
88 // Output buffers for mixing spectral reverb and compensator output.
89 AudioBuffer output_buffer_;
90 AudioBuffer compensator_output_buffer_;
91
92 // Silence mono buffer to render reverb tails during the absence of input
93 // buffers.
94 AudioBuffer silence_mono_buffer_;
95};
96
97} // namespace vraudio
98
99#endif // RESONANCE_AUDIO_GRAPH_REVERB_NODE_H_
100

source code of qtmultimedia/src/3rdparty/resonance-audio/resonance_audio/graph/reverb_node.h