blob: 79dc9ee07d57eac3a9876dd83904fed3448b89a8 [file] [log] [blame]
Mikhail Naganov40be06c2016-09-27 17:01:34 -07001/*
2 * Copyright (C) 2016 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
17package android.hardware.audio.effect@2.0;
18
19import android.hardware.audio.common@2.0;
20import IEffect;
21
22interface IVisualizerEffect extends IEffect {
Steven Morelandd26dc502016-11-29 14:07:27 -080023 enum CaptureSizeRange : int32_t {
Mikhail Naganov40be06c2016-09-27 17:01:34 -070024 MAX = 1024, // maximum capture size in samples
25 MIN = 128 // minimum capture size in samples
26 };
27
28 /*
29 * Sets the number PCM samples in the capture.
30 */
31 setCaptureSize(uint16_t captureSize) generates (Result retval);
32
33 /*
34 * Gets the number PCM samples in the capture.
35 */
36 getCaptureSize() generates (Result retval, uint16_t captureSize);
37
Steven Morelandd26dc502016-11-29 14:07:27 -080038 enum ScalingMode : int32_t {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070039 // Keep in sync with SCALING_MODE_... in
Mikhail Naganov40be06c2016-09-27 17:01:34 -070040 // frameworks/base/media/java/android/media/audiofx/Visualizer.java
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070041 NORMALIZED = 0,
42 AS_PLAYED = 1
Mikhail Naganov40be06c2016-09-27 17:01:34 -070043 };
44
45 /*
46 * Specifies the way the captured data is scaled.
47 */
48 setScalingMode(ScalingMode scalingMode) generates (Result retval);
49
50 /*
51 * Retrieves the way the captured data is scaled.
52 */
53 getScalingMode() generates (Result retval, ScalingMode scalingMode);
54
55 /*
56 * Informs the visualizer about the downstream latency.
57 */
58 setLatency(uint32_t latencyMs) generates (Result retval);
59
60 /*
61 * Gets the downstream latency.
62 */
63 getLatency() generates (Result retval, uint32_t latencyMs);
64
Steven Morelandd26dc502016-11-29 14:07:27 -080065 enum MeasurementMode : int32_t {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070066 // Keep in sync with MEASUREMENT_MODE_... in
Mikhail Naganov40be06c2016-09-27 17:01:34 -070067 // frameworks/base/media/java/android/media/audiofx/Visualizer.java
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070068 NONE = 0x0,
69 PEAK_RMS = 0x1
Mikhail Naganov40be06c2016-09-27 17:01:34 -070070 };
71
72 /*
73 * Specifies which measurements are to be made.
74 */
75 setMeasurementMode(MeasurementMode measurementMode)
76 generates (Result retval);
77
78 /*
79 * Retrieves which measurements are to be made.
80 */
81 getMeasurementMode() generates (
82 Result retval, MeasurementMode measurementMode);
83
84 /*
85 * Retrieves the latest PCM snapshot captured by the visualizer engine. The
86 * number of samples to capture is specified by 'setCaptureSize' parameter.
87 *
88 * @return retval operation completion status.
89 * @return samples samples in 8 bit unsigned format (0 = 0x80)
90 */
91 capture() generates (Result retval, vec<uint8_t> samples);
92
93 struct Measurement {
94 MeasurementMode mode; // discriminator
95 union Values {
96 struct PeakAndRms {
97 int32_t peakMb; // millibels
98 int32_t rmsMb; // millibels
99 } peakAndRms;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700100 } value;
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700101 };
102 /*
103 * Retrieves the lastest measurements. The measurements to be made
104 * are specified by 'setMeasurementMode' parameter.
105 *
106 * @return retval operation completion status.
107 * @return result measurement.
108 */
109 measure() generates (Result retval, Measurement result);
110};