1 | /* |
---|---|
2 | Copyright 2018 Google Inc. All Rights Reserved. |
3 | |
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | you may not use this file except in compliance with the License. |
6 | You may obtain a copy of the License at |
7 | |
8 | http://www.apache.org/licenses/LICENSE-2.0 |
9 | |
10 | Unless required by applicable law or agreed to in writing, software |
11 | distributed under the License is distributed on an "AS-IS" BASIS, |
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | See the License for the specific language governing permissions and |
14 | limitations under the License. |
15 | */ |
16 | |
17 | #include "graph/mono_from_soundfield_node.h" |
18 | |
19 | #include "base/constants_and_types.h" |
20 | |
21 | namespace vraudio { |
22 | |
23 | MonoFromSoundfieldNode::MonoFromSoundfieldNode( |
24 | SourceId source_id, const SystemSettings& system_settings) |
25 | : output_buffer_(kNumMonoChannels, system_settings.GetFramesPerBuffer()) { |
26 | output_buffer_.set_source_id(source_id); |
27 | output_buffer_.Clear(); |
28 | } |
29 | |
30 | const AudioBuffer* MonoFromSoundfieldNode::AudioProcess( |
31 | const NodeInput& input) { |
32 | |
33 | |
34 | const AudioBuffer* input_buffer = input.GetSingleInput(); |
35 | DCHECK(input_buffer); |
36 | DCHECK_EQ(input_buffer->source_id(), output_buffer_.source_id()); |
37 | DCHECK_NE(input_buffer->num_channels(), 0U); |
38 | DCHECK_EQ(input_buffer->num_frames(), output_buffer_.num_frames()); |
39 | // Get W channel of the ambisonic input. |
40 | output_buffer_[0] = (*input_buffer)[0]; |
41 | |
42 | return &output_buffer_; |
43 | } |
44 | |
45 | } // namespace vraudio |
46 |