EffectBundle.h revision 23e1de74359f4bb1763aef0adfebe073122b032c
1/* 2 * Copyright (C) 2010 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#ifndef ANDROID_EFFECTBUNDLE_H_ 18#define ANDROID_EFFECTBUNDLE_H_ 19 20#include <media/EffectEqualizerApi.h> 21#include <media/EffectBassBoostApi.h> 22#include <media/EffectVirtualizerApi.h> 23#include <LVM.h> 24 25#if __cplusplus 26extern "C" { 27#endif 28 29#define FIVEBAND_NUMBANDS 5 30#define MAX_NUM_BANDS 5 31#define MAX_CALL_SIZE 256 32//#define LVM_PCM 33 34#ifndef OPENSL_ES_H_ 35static const effect_uuid_t SL_IID_VOLUME_ = { 0x09e8ede0, 0xddde, 0x11db, 0xb4f6, 36 { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; 37const effect_uuid_t * const SL_IID_VOLUME = &SL_IID_VOLUME_; 38#endif //OPENSL_ES_H_ 39 40typedef enum 41{ 42 LVM_BASS_BOOST, 43 LVM_VIRTUALIZER, 44 LVM_EQUALIZER, 45 LVM_VOLUME 46} lvm_effect_en; 47 48// Preset configuration. 49struct PresetConfig { 50 // Human-readable name. 51 const char * name; 52 // An array of size nBands where each element is a configuration for the 53 // corresponding band. 54 //const BandConfig * bandConfigs; 55}; 56 57/* BundledEffectContext : One per session */ 58struct BundledEffectContext{ 59 LVM_Handle_t hInstance; /* Instance handle */ 60 int SessionNo; /* Current session number */ 61 bool bVolumeEnabled; /* Flag for Volume */ 62 bool bEqualizerEnabled; /* Flag for EQ */ 63 bool bBassEnabled; /* Flag for Bass */ 64 bool bBassTempDisabled; /* Flag for Bass to be re-enabled */ 65 bool bVirtualizerEnabled; /* Flag for Virtualizer */ 66 bool bVirtualizerTempDisabled; /* Flag for effect to be re-enabled */ 67 int NumberEffectsEnabled; /* Effects in this session */ 68 int NumberEffectsCalled; /* Effects called so far */ 69 // Saved parameters for each effect */ 70 // Bass Boost 71 int BassStrengthSaved; /* Conversion between Get/Set */ 72 // Equalizer 73 int CurPreset; /* Current preset being used */ 74 // Virtualzer 75 int VirtStrengthSaved; /* Conversion between Get/Set */ 76 // Volume 77 int levelSaved; /* for when mute is set, level must be saved */ 78 int positionSaved; 79 bool bMuteEnabled; /* Must store as mute = -96dB level */ 80 bool bStereoPositionEnabled; 81 int frameCount; 82 LVM_Fs_en SampleRate; 83 #ifdef LVM_PCM 84 FILE *PcmInPtr; 85 FILE *PcmOutPtr; 86 #endif 87}; 88 89/* SessionContext : One session */ 90struct SessionContext{ 91 bool bBundledEffectsEnabled; 92 bool bVolumeInstantiated; 93 bool bEqualizerInstantiated; 94 bool bBassInstantiated; 95 bool bVirtualizerInstantiated; 96 BundledEffectContext *pBundledContext; 97}; 98 99struct EffectContext{ 100 const struct effect_interface_s *itfe; 101 effect_config_t config; 102 lvm_effect_en EffectType; 103 BundledEffectContext *pBundledContext; 104}; 105 106 107/* enumerated parameter settings for Volume effect */ 108typedef enum 109{ 110 VOLUME_PARAM_LEVEL, // type SLmillibel = typedef SLuint16 (set & get) 111 VOLUME_PARAM_MAXLEVEL, // type SLmillibel = typedef SLuint16 (get) 112 VOLUME_PARAM_MUTE, // type SLboolean = typedef SLuint32 (set & get) 113 VOLUME_PARAM_ENABLESTEREOPOSITION, // type SLboolean = typedef SLuint32 (set & get) 114 VOLUME_PARAM_STEREOPOSITION, // type SLpermille = typedef SLuint16 (set & get) 115} t_volume_params; 116 117static const int PRESET_CUSTOM = -1; 118 119static const uint32_t bandFreqRange[FIVEBAND_NUMBANDS][2] = { 120 {30000, 120000}, 121 {120001, 460000}, 122 {460001, 1800000}, 123 {1800001, 7000000}, 124 {7000001, 1}}; 125 126static const LVM_UINT16 EQNB_5BandPresetsFrequencies[] = { 127 60, /* Frequencies in Hz */ 128 230, 129 910, 130 3600, 131 14000}; 132 133static const LVM_UINT16 EQNB_5BandPresetsQFactors[] = { 134 96, /* Q factor multiplied by 100 */ 135 96, 136 96, 137 96, 138 96}; 139 140static const LVM_INT16 EQNB_5BandNormalPresets[] = { 141 3, 0, 0, 0, 3, /* Normal Preset */ 142 8, 5, -3, 5, 6, /* Classical Preset */ 143 15, -6, 7, 13, 10, /* Dance Preset */ 144 0, 0, 0, 0, 0, /* Flat Preset */ 145 6, -2, -2, 6, -3, /* Folk Preset */ 146 8, -8, 13, -1, -4, /* Heavy Metal Preset */ 147 10, 6, -4, 5, 8, /* Hip Hop Preset */ 148 8, 5, -4, 5, 9, /* Jazz Preset */ 149 -6, 4, 9, 4, -5, /* Pop Preset */ 150 10, 6, -1, 8, 10}; /* Rock Preset */ 151 152static const LVM_INT16 EQNB_5BandSoftPresets[] = { 153 3, 0, 0, 0, 3, /* Normal Preset */ 154 5, 3, -2, 4, 4, /* Classical Preset */ 155 6, 0, 2, 4, 1, /* Dance Preset */ 156 0, 0, 0, 0, 0, /* Flat Preset */ 157 3, 0, 0, 2, -1, /* Folk Preset */ 158 4, 1, 9, 3, 0, /* Heavy Metal Preset */ 159 5, 3, 0, 1, 3, /* Hip Hop Preset */ 160 4, 2, -2, 2, 5, /* Jazz Preset */ 161 -1, 2, 5, 1, -2, /* Pop Preset */ 162 5, 3, -1, 3, 5}; /* Rock Preset */ 163 164static const PresetConfig gEqualizerPresets[] = { 165 {"Normal"}, 166 {"Classical"}, 167 {"Dance"}, 168 {"Flat"}, 169 {"Folk"}, 170 {"Heavy Metal"}, 171 {"Hip Hop"}, 172 {"Jazz"}, 173 {"Pop"}, 174 {"Rock"}}; 175 176#if __cplusplus 177} // extern "C" 178#endif 179 180 181#endif /*ANDROID_EFFECTBUNDLE_H_*/ 182