1 /*
2 * Copyright (C) 2020 The Android Open Source Project
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 <inttypes.h>
18 #include <type_traits>
19 #include "../../../../system/media/audio_utils/include/audio_utils/primitives.h"
20 #define LOG_ALWAYS_FATAL(...)
21
22 #include <../AudioMixerOps.h>
23
24 using namespace android;
25
26 template <int MIXTYPE, int NCHAN>
checkVolumeRampMulti()27 static void checkVolumeRampMulti() {
28 constexpr size_t FRAME_COUNT = 1000;
29 constexpr size_t SAMPLE_COUNT = FRAME_COUNT * NCHAN;
30
31 // data inialized to 0.
32 float out[SAMPLE_COUNT]{};
33 float in[SAMPLE_COUNT]{};
34 float aux[FRAME_COUNT]{};
35
36 // volume initialized to 0
37 float vola = 0.f;
38 float vol[2] = {0.f, 0.f};
39
40 // some volume increment
41 float volainc = 0.01f;
42 float volinc[2] = {0.01f, 0.01f};
43
44 // try the multi ramp code.
45 volumeRampMulti<MIXTYPE, NCHAN>(out, FRAME_COUNT, in, aux, vol, volinc, &vola, volainc);
46 }
47
48 // Use this to check the objdump to ensure reasonable code.
main()49 int main() {
50 checkVolumeRampMulti<MIXTYPE_MULTI_STEREOVOL, 5>();
51 return EXIT_SUCCESS;
52 }
53