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_UTILS_BUFFER_CROSSFADER_H_
18#define RESONANCE_AUDIO_UTILS_BUFFER_CROSSFADER_H_
19
20#include "base/audio_buffer.h"
21
22namespace vraudio {
23
24// Class that takes two input buffers and produces an output buffer by applying
25// linear crossfade between the inputs.
26class BufferCrossfader {
27 public:
28 explicit BufferCrossfader(size_t num_frames);
29
30 // Applies linear crossfade for given input buffers and stores the result in
31 // |output| buffer. Note that, in-place processing is *not* supported by this
32 // method, the output buffer must be different than the input buffers.
33 //
34 // @param input_fade_in Input buffer to fade-in to.
35 // @param input_fade_out Input buffer to fade-out from.
36 // @param output Output buffer to store the crossfaded result.
37 void ApplyLinearCrossfade(const AudioBuffer& input_fade_in,
38 const AudioBuffer& input_fade_out,
39 AudioBuffer* output) const;
40
41 private:
42 // Stereo audio buffer to store crossfade decay and growth multipliers.
43 AudioBuffer crossfade_buffer_;
44};
45
46} // namespace vraudio
47
48#endif // RESONANCE_AUDIO_UTILS_BUFFER_CROSSFADER_H_
49

source code of qtmultimedia/src/3rdparty/resonance-audio/resonance_audio/utils/buffer_crossfader.h