1/* 2 * Copyright (C) 2018 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@4.0; 18 19import android.hardware.audio.common@4.0; 20import IEffect; 21 22interface IVisualizerEffect extends IEffect { 23 enum CaptureSizeRange : int32_t { 24 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 38 enum ScalingMode : int32_t { 39 // Keep in sync with SCALING_MODE_... in 40 // frameworks/base/media/java/android/media/audiofx/Visualizer.java 41 NORMALIZED = 0, 42 AS_PLAYED = 1 43 }; 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 65 enum MeasurementMode : int32_t { 66 // Keep in sync with MEASUREMENT_MODE_... in 67 // frameworks/base/media/java/android/media/audiofx/Visualizer.java 68 NONE = 0x0, 69 PEAK_RMS = 0x1 70 }; 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; 100 } value; 101 }; 102 /** 103 * Retrieves the latest 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}; 111