Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: webrtc/modules/audio_mixer/audio_frame_manipulator_unittest.cc

Issue 2398083005: Changed ramping functionality of the AudioMixer. (Closed)
Patch Set: Changed argument names and comment in Ramp. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <algorithm>
12
13 #include "webrtc/modules/audio_mixer/audio_frame_manipulator.h"
14 #include "webrtc/modules/include/module_common_types.h"
15 #include "webrtc/test/gtest.h"
16
17 namespace webrtc {
18 namespace {
19
20 void FillFrameWithConstants(size_t samples_per_channel,
21 size_t number_of_channels,
22 int16_t value,
23 AudioFrame* frame) {
24 frame->num_channels_ = number_of_channels;
25 frame->samples_per_channel_ = samples_per_channel;
26 std::fill(frame->data_,
27 frame->data_ + samples_per_channel * number_of_channels, value);
28 }
29 } // namespace
30
31 TEST(AudioFrameManipulator, CompareForwardRampWithExpectedResultStereo) {
32 constexpr int kSamplesPerChannel = 5;
33 constexpr int kNumberOfChannels = 2;
34
35 // Create a frame with values 5, 5, 5, ... and channels & samples as above.
36 AudioFrame frame;
37 FillFrameWithConstants(kSamplesPerChannel, kNumberOfChannels, 5, &frame);
38
39 Ramp(0.0f, 1.0f, &frame);
40
41 const int total_samples = kSamplesPerChannel * kNumberOfChannels;
42 const int16_t expected_result[total_samples] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
43 EXPECT_TRUE(
44 std::equal(frame.data_, frame.data_ + total_samples, expected_result));
45 }
46
47 TEST(AudioFrameManipulator, CompareBackwardRampWithExpectedResultMono) {
48 constexpr int kSamplesPerChannel = 5;
49 constexpr int kNumberOfChannels = 1;
50
51 // Create a frame with values 5, 5, 5, ... and channels & samples as above.
52 AudioFrame frame;
53 FillFrameWithConstants(kSamplesPerChannel, kNumberOfChannels, 5, &frame);
54
55 Ramp(1.0f, 0.0f, &frame);
56
57 const int total_samples = kSamplesPerChannel * kNumberOfChannels;
58 const int16_t expected_result[total_samples] = {5, 4, 3, 2, 1};
59 EXPECT_TRUE(
60 std::equal(frame.data_, frame.data_ + total_samples, expected_result));
61 }
62
63 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_mixer/audio_frame_manipulator.cc ('k') | webrtc/modules/audio_mixer/audio_mixer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698