Merge "EnvironmentalReverb : Add minimum and maximum capabilities for params."

This commit is contained in:
Treehugger Robot 2023-01-10 08:25:28 +00:00 committed by Gerrit Code Review
commit 5616efe88b
5 changed files with 375 additions and 252 deletions

View file

@ -44,22 +44,6 @@ union EnvironmentalReverb {
int diffusionPm;
int densityPm;
boolean bypass;
const int MIN_ROOM_LEVEL_MB = (-6000);
const int MAX_ROOM_LEVEL_MB = 0;
const int MIN_ROOM_HF_LEVEL_MB = (-4000);
const int MAX_ROOM_HF_LEVEL_MB = 0;
const int MIN_DECAY_TIME_MS = 100;
const int MAX_DECAY_TIME_MS = 20000;
const int MIN_DECAY_HF_RATIO_PM = 100;
const int MAX_DECAY_HF_RATIO_PM = 1000;
const int MIN_LEVEL_MB = (-6000);
const int MAX_LEVEL_MB = 0;
const int MIN_DELAY_MS = 0;
const int MAX_DELAY_MS = 65;
const int MIN_DIFFUSION_PM = 0;
const int MAX_DIFFUSION_PM = 1000;
const int MIN_DENSITY_PM = 0;
const int MAX_DENSITY_PM = 1000;
@VintfStability
union Id {
int vendorExtensionTag;
@ -68,6 +52,17 @@ union EnvironmentalReverb {
@VintfStability
parcelable Capability {
android.hardware.audio.effect.VendorExtension extension;
int minRoomLevelMb;
int maxRoomLevelMb;
int minRoomHfLevelMb;
int maxRoomHfLevelMb;
int maxDecayTimeMs;
int minDecayHfRatioPm;
int maxDecayHfRatioPm;
int minLevelMb;
int maxLevelMb;
int maxDelayMs;
int maxDiffusionPm;
int maxDensityPm;
}
}

View file

@ -49,113 +49,97 @@ union EnvironmentalReverb {
parcelable Capability {
VendorExtension extension;
/**
* Max decay time supported in millisecond.
*/
int maxDecayTimeMs;
}
/**
* Minimal possible room level in millibels.
*/
const int MIN_ROOM_LEVEL_MB = -6000;
int minRoomLevelMb;
/**
* Maximum possible room level in millibels.
*/
const int MAX_ROOM_LEVEL_MB = 0;
/**
* Room level apply to the reverb effect in millibels.
*/
int roomLevelMb;
int maxRoomLevelMb;
/**
* Minimal possible room hf level in millibels.
*/
const int MIN_ROOM_HF_LEVEL_MB = -4000;
int minRoomHfLevelMb;
/**
* Maximum possible room hf level in millibels.
*/
const int MAX_ROOM_HF_LEVEL_MB = 0;
int maxRoomHfLevelMb;
/**
* Room HF level apply to the reverb effect in millibels.
* Max decay time supported in millisecond.
*/
int roomHfLevelMb;
/**
* Minimal possible decay time in milliseconds.
*/
const int MIN_DECAY_TIME_MS = 100;
/**
* Maximum possible decay time in milliseconds.
*/
const int MAX_DECAY_TIME_MS = 20000;
/**
* Delay time apply to the reverb effect in milliseconds.
*/
int decayTimeMs;
int maxDecayTimeMs;
/**
* Minimal possible per mille decay hf ratio.
*/
const int MIN_DECAY_HF_RATIO_PM = 100;
int minDecayHfRatioPm;
/**
* Maximum possible per mille decay hf ratio.
*/
const int MAX_DECAY_HF_RATIO_PM = 1000;
/**
* HF decay ratio in permilles.
*/
int decayHfRatioPm;
int maxDecayHfRatioPm;
/**
* Minimal possible room level in millibels.
*/
const int MIN_LEVEL_MB = -6000;
int minLevelMb;
/**
* Maximum possible room level in millibels.
*/
const int MAX_LEVEL_MB = 0;
/**
* Reverb level in millibels.
*/
int levelMb;
/**
* Minimal possible delay time in milliseconds.
*/
const int MIN_DELAY_MS = 0;
int maxLevelMb;
/**
* Maximum possible delay time in milliseconds.
*/
const int MAX_DELAY_MS = 65;
/**
* Reverb delay in milliseconds.
*/
int delayMs;
/**
* Minimal possible per mille diffusion.
*/
const int MIN_DIFFUSION_PM = 0;
int maxDelayMs;
/**
* Maximum possible per mille diffusion.
*/
const int MAX_DIFFUSION_PM = 1000;
/**
* Diffusion in permilles.
*/
int diffusionPm;
/**
* Minimal possible per mille density.
*/
const int MIN_DENSITY_PM = 0;
int maxDiffusionPm;
/**
* Maximum possible per mille density.
*/
const int MAX_DENSITY_PM = 1000;
int maxDensityPm;
}
/**
* Density in permilles.
* Room level apply to the reverb effect in millibels. The value of the roomLevelMb must be in
* range of the value specified by the 'minRoomLevelMb' capability and the 'maxRoomLevelMb'
* capability.
*/
int roomLevelMb;
/**
* Room HF level apply to the reverb effect in millibels. The value of the roomHfLevelMb must be
* in range of the value specified by the 'minRoomHfLevelMb' capability and the
* 'maxRoomHfLevelMb' capability.
*/
int roomHfLevelMb;
/**
* Delay time apply to the reverb effect in milliseconds.The value of the decayTimeMs must
* be non-negative and not exceed the value specified by the 'maxDecayTimeMs' capability.
*/
int decayTimeMs;
/**
* HF decay ratio in permilles. The value of the decayHfRatioPm must be in range
* of the value specified by the 'minDecayHfRatioPm' capability and the 'maxDecayHfRatioPm'
* capability.
*/
int decayHfRatioPm;
/**
* Reverb level in millibels. The value of the levelMb must be in range
* of the value specified by the 'minLevelMb' capability and the 'maxLevelMb' capability.
*/
int levelMb;
/**
* Reverb delay in milliseconds. The value of the delayMs must be non-negative and not
* exceed the value specified by the 'maxDelayMs' capability.
*/
int delayMs;
/**
* Diffusion in permilles. The value of the diffusionPm must be non-negative and not
* exceed the value specified by the 'maxDiffusionPm' capability.
*/
int diffusionPm;
/**
* Density in permilles. The value of the densityPm must be non-negative and not
* exceed the value specified by the 'maxDensityPm' capability.
*/
int densityPm;

View file

@ -60,8 +60,18 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
namespace aidl::android::hardware::audio::effect {
const std::string EnvReverbSw::kEffectName = "EnvReverbSw";
const EnvironmentalReverb::Capability EnvReverbSw::kCapability = {
.maxDecayTimeMs = EnvironmentalReverb::MAX_DECAY_TIME_MS};
const EnvironmentalReverb::Capability EnvReverbSw::kCapability = {.minRoomLevelMb = -6000,
.maxRoomLevelMb = 0,
.minRoomHfLevelMb = -4000,
.maxRoomHfLevelMb = 0,
.maxDecayTimeMs = 7000,
.minDecayHfRatioPm = 100,
.maxDecayHfRatioPm = 2000,
.minLevelMb = -6000,
.maxLevelMb = 0,
.maxDelayMs = 65,
.maxDiffusionPm = 1000,
.maxDensityPm = 1000};
const Descriptor EnvReverbSw::kDescriptor = {
.common = {.id = {.type = kEnvReverbTypeUUID,
.uuid = kEnvReverbSwImplUUID,
@ -251,4 +261,88 @@ IEffect::Status EnvReverbSw::effectProcessImpl(float* in, float* out, int sample
return {STATUS_OK, samples, samples};
}
RetCode EnvReverbSwContext::setErRoomLevel(int roomLevel) {
if (roomLevel < EnvReverbSw::kCapability.minRoomLevelMb ||
roomLevel > EnvReverbSw::kCapability.maxRoomLevelMb) {
LOG(ERROR) << __func__ << " invalid roomLevel: " << roomLevel;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new room level
mRoomLevel = roomLevel;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErRoomHfLevel(int roomHfLevel) {
if (roomHfLevel < EnvReverbSw::kCapability.minRoomHfLevelMb ||
roomHfLevel > EnvReverbSw::kCapability.maxRoomHfLevelMb) {
LOG(ERROR) << __func__ << " invalid roomHfLevel: " << roomHfLevel;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new room HF level
mRoomHfLevel = roomHfLevel;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDecayTime(int decayTime) {
if (decayTime < 0 || decayTime > EnvReverbSw::kCapability.maxDecayTimeMs) {
LOG(ERROR) << __func__ << " invalid decayTime: " << decayTime;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new decay time
mDecayTime = decayTime;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDecayHfRatio(int decayHfRatio) {
if (decayHfRatio < EnvReverbSw::kCapability.minDecayHfRatioPm ||
decayHfRatio > EnvReverbSw::kCapability.maxDecayHfRatioPm) {
LOG(ERROR) << __func__ << " invalid decayHfRatio: " << decayHfRatio;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new decay HF ratio
mDecayHfRatio = decayHfRatio;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErLevel(int level) {
if (level < EnvReverbSw::kCapability.minLevelMb ||
level > EnvReverbSw::kCapability.maxLevelMb) {
LOG(ERROR) << __func__ << " invalid level: " << level;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new level
mLevel = level;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDelay(int delay) {
if (delay < 0 || delay > EnvReverbSw::kCapability.maxDelayMs) {
LOG(ERROR) << __func__ << " invalid delay: " << delay;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new delay
mDelay = delay;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDiffusion(int diffusion) {
if (diffusion < 0 || diffusion > EnvReverbSw::kCapability.maxDiffusionPm) {
LOG(ERROR) << __func__ << " invalid diffusion: " << diffusion;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new diffusion
mDiffusion = diffusion;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDensity(int density) {
if (density < 0 || density > EnvReverbSw::kCapability.maxDensityPm) {
LOG(ERROR) << __func__ << " invalid density: " << density;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new density
mDensity = density;
return RetCode::SUCCESS;
}
} // namespace aidl::android::hardware::audio::effect

View file

@ -33,100 +33,28 @@ class EnvReverbSwContext final : public EffectContext {
LOG(DEBUG) << __func__;
}
RetCode setErRoomLevel(int roomLevel) {
if (roomLevel < EnvironmentalReverb::MIN_ROOM_LEVEL_MB ||
roomLevel > EnvironmentalReverb::MAX_ROOM_LEVEL_MB) {
LOG(ERROR) << __func__ << " invalid roomLevel: " << roomLevel;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new room level
mRoomLevel = roomLevel;
return RetCode::SUCCESS;
}
RetCode setErRoomLevel(int roomLevel);
int getErRoomLevel() const { return mRoomLevel; }
RetCode setErRoomHfLevel(int roomHfLevel) {
if (roomHfLevel < EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB ||
roomHfLevel > EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB) {
LOG(ERROR) << __func__ << " invalid roomHfLevel: " << roomHfLevel;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new room HF level
mRoomHfLevel = roomHfLevel;
return RetCode::SUCCESS;
}
RetCode setErRoomHfLevel(int roomHfLevel);
int getErRoomHfLevel() const { return mRoomHfLevel; }
RetCode setErDecayTime(int decayTime) {
if (decayTime < EnvironmentalReverb::MIN_DECAY_TIME_MS ||
decayTime > EnvironmentalReverb::MAX_DECAY_TIME_MS) {
LOG(ERROR) << __func__ << " invalid decayTime: " << decayTime;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new decay time
mDecayTime = decayTime;
return RetCode::SUCCESS;
}
RetCode setErDecayTime(int decayTime);
int getErDecayTime() const { return mDecayTime; }
RetCode setErDecayHfRatio(int decayHfRatio) {
if (decayHfRatio < EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM ||
decayHfRatio > EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM) {
LOG(ERROR) << __func__ << " invalid decayHfRatio: " << decayHfRatio;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new decay HF ratio
mDecayHfRatio = decayHfRatio;
return RetCode::SUCCESS;
}
RetCode setErDecayHfRatio(int decayHfRatio);
int getErDecayHfRatio() const { return mDecayHfRatio; }
RetCode setErLevel(int level) {
if (level < EnvironmentalReverb::MIN_LEVEL_MB ||
level > EnvironmentalReverb::MAX_LEVEL_MB) {
LOG(ERROR) << __func__ << " invalid level: " << level;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new level
mLevel = level;
return RetCode::SUCCESS;
}
RetCode setErLevel(int level);
int getErLevel() const { return mLevel; }
RetCode setErDelay(int delay) {
if (delay < EnvironmentalReverb::MIN_DELAY_MS ||
delay > EnvironmentalReverb::MAX_DELAY_MS) {
LOG(ERROR) << __func__ << " invalid delay: " << delay;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new delay
mDelay = delay;
return RetCode::SUCCESS;
}
RetCode setErDelay(int delay);
int getErDelay() const { return mDelay; }
RetCode setErDiffusion(int diffusion) {
if (diffusion < EnvironmentalReverb::MIN_DIFFUSION_PM ||
diffusion > EnvironmentalReverb::MAX_DIFFUSION_PM) {
LOG(ERROR) << __func__ << " invalid diffusion: " << diffusion;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new diffusion
mDiffusion = diffusion;
return RetCode::SUCCESS;
}
RetCode setErDiffusion(int diffusion);
int getErDiffusion() const { return mDiffusion; }
RetCode setErDensity(int density) {
if (density < EnvironmentalReverb::MIN_DENSITY_PM ||
density > EnvironmentalReverb::MAX_DENSITY_PM) {
LOG(ERROR) << __func__ << " invalid density: " << density;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
// TODO : Add implementation to apply new density
mDensity = density;
return RetCode::SUCCESS;
}
RetCode setErDensity(int density);
int getErDensity() const { return mDensity; }
RetCode setErBypass(bool bypass) {
@ -137,14 +65,14 @@ class EnvReverbSwContext final : public EffectContext {
bool getErBypass() const { return mBypass; }
private:
int mRoomLevel = EnvironmentalReverb::MIN_ROOM_LEVEL_MB; // Default room level
int mRoomHfLevel = EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB; // Default room hf level
int mRoomLevel = -6000; // Default room level
int mRoomHfLevel = 0; // Default room hf level
int mDecayTime = 1000; // Default decay time
int mDecayHfRatio = 500; // Default decay hf ratio
int mLevel = EnvironmentalReverb::MIN_LEVEL_MB; // Default level
int mLevel = -6000; // Default level
int mDelay = 40; // Default delay
int mDiffusion = EnvironmentalReverb::MAX_DIFFUSION_PM; // Default diffusion
int mDensity = EnvironmentalReverb::MAX_DENSITY_PM; // Default density
int mDiffusion = 1000; // Default diffusion
int mDensity = 1000; // Default density
bool mBypass = false; // Default bypass
};

View file

@ -18,6 +18,7 @@
#include <Utils.h>
#include <aidl/Vintf.h>
#include <unordered_set>
#include "EffectHelper.h"
using namespace android;
@ -38,30 +39,6 @@ using aidl::android::hardware::audio::effect::Parameter;
* any index supported value test expects EX_NONE from IEffect.setParameter(), otherwise expects
* EX_ILLEGAL_ARGUMENT.
*/
const std::vector<int> kRoomLevelValues = {
EnvironmentalReverb::MIN_ROOM_LEVEL_MB - 1, EnvironmentalReverb::MIN_ROOM_LEVEL_MB,
EnvironmentalReverb::MAX_ROOM_LEVEL_MB, EnvironmentalReverb::MAX_ROOM_LEVEL_MB + 1};
const std::vector<int> kRoomHfLevelValues = {
EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB - 1, EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB,
EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB, EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB + 1};
const std::vector<int> kDecayTimeValues = {
EnvironmentalReverb::MIN_DECAY_TIME_MS - 1, EnvironmentalReverb::MIN_DECAY_TIME_MS,
EnvironmentalReverb::MAX_DECAY_TIME_MS, EnvironmentalReverb::MAX_DECAY_TIME_MS + 1};
const std::vector<int> kDecayHfRatioValues = {
EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM - 1, EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM,
EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM, EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM + 1};
const std::vector<int> kLevelValues = {
EnvironmentalReverb::MIN_LEVEL_MB - 1, EnvironmentalReverb::MIN_LEVEL_MB,
EnvironmentalReverb::MAX_LEVEL_MB, EnvironmentalReverb::MAX_LEVEL_MB + 1};
const std::vector<int> kDelayValues = {
EnvironmentalReverb::MIN_DELAY_MS - 1, EnvironmentalReverb::MIN_DELAY_MS,
EnvironmentalReverb::MAX_DELAY_MS, EnvironmentalReverb::MAX_DELAY_MS + 1};
const std::vector<int> kDiffusionValues = {
EnvironmentalReverb::MIN_DIFFUSION_PM - 1, EnvironmentalReverb::MIN_DIFFUSION_PM,
EnvironmentalReverb::MAX_DIFFUSION_PM, EnvironmentalReverb::MAX_DIFFUSION_PM + 1};
const std::vector<int> kDensityValues = {
EnvironmentalReverb::MIN_DENSITY_PM - 1, EnvironmentalReverb::MIN_DENSITY_PM,
EnvironmentalReverb::MAX_DENSITY_PM, EnvironmentalReverb::MAX_DENSITY_PM + 1};
class EnvironmentalReverbHelper : public EffectHelper {
public:
@ -88,8 +65,7 @@ class EnvironmentalReverbHelper : public EffectHelper {
}
Parameter::Specific getDefaultParamSpecific() {
EnvironmentalReverb er = EnvironmentalReverb::make<EnvironmentalReverb::roomLevelMb>(
EnvironmentalReverb::MIN_ROOM_LEVEL_MB);
EnvironmentalReverb er = EnvironmentalReverb::make<EnvironmentalReverb::roomLevelMb>(-6000);
Parameter::Specific specific =
Parameter::Specific::make<Parameter::Specific::environmentalReverb>(er);
return specific;
@ -99,14 +75,14 @@ class EnvironmentalReverbHelper : public EffectHelper {
std::shared_ptr<IFactory> mFactory;
std::shared_ptr<IEffect> mEffect;
Descriptor mDescriptor;
int mRoomLevel = EnvironmentalReverb::MIN_ROOM_LEVEL_MB;
int mRoomHfLevel = EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB;
int mRoomLevel = -6000;
int mRoomHfLevel = 0;
int mDecayTime = 1000;
int mDecayHfRatio = 500;
int mLevel = EnvironmentalReverb::MIN_LEVEL_MB;
int mLevel = -6000;
int mDelay = 40;
int mDiffusion = EnvironmentalReverb::MAX_DIFFUSION_PM;
int mDensity = EnvironmentalReverb::MAX_DENSITY_PM;
int mDiffusion = 1000;
int mDensity = 1000;
bool mBypass = false;
void SetAndGetReverbParameters() {
@ -202,11 +178,11 @@ class EnvironmentalReverbHelper : public EffectHelper {
switch (tag) {
case EnvironmentalReverb::roomLevelMb: {
int roomLevel = er.get<EnvironmentalReverb::roomLevelMb>();
return isRoomLevelInRange(roomLevel);
return isRoomLevelInRange(erCap, roomLevel);
}
case EnvironmentalReverb::roomHfLevelMb: {
int roomHfLevel = er.get<EnvironmentalReverb::roomHfLevelMb>();
return isRoomHfLevelInRange(roomHfLevel);
return isRoomHfLevelInRange(erCap, roomHfLevel);
}
case EnvironmentalReverb::decayTimeMs: {
int decayTime = er.get<EnvironmentalReverb::decayTimeMs>();
@ -214,23 +190,23 @@ class EnvironmentalReverbHelper : public EffectHelper {
}
case EnvironmentalReverb::decayHfRatioPm: {
int decayHfRatio = er.get<EnvironmentalReverb::decayHfRatioPm>();
return isDecayHfRatioInRange(decayHfRatio);
return isDecayHfRatioInRange(erCap, decayHfRatio);
}
case EnvironmentalReverb::levelMb: {
int level = er.get<EnvironmentalReverb::levelMb>();
return isLevelInRange(level);
return isLevelInRange(erCap, level);
}
case EnvironmentalReverb::delayMs: {
int delay = er.get<EnvironmentalReverb::delayMs>();
return isDelayInRange(delay);
return isDelayInRange(erCap, delay);
}
case EnvironmentalReverb::diffusionPm: {
int diffusion = er.get<EnvironmentalReverb::diffusionPm>();
return isDiffusionInRange(diffusion);
return isDiffusionInRange(erCap, diffusion);
}
case EnvironmentalReverb::densityPm: {
int density = er.get<EnvironmentalReverb::densityPm>();
return isDensityInRange(density);
return isDensityInRange(erCap, density);
}
case EnvironmentalReverb::bypass: {
return true;
@ -241,45 +217,191 @@ class EnvironmentalReverbHelper : public EffectHelper {
return false;
}
bool isRoomLevelInRange(int roomLevel) const {
return roomLevel >= EnvironmentalReverb::MIN_ROOM_LEVEL_MB &&
roomLevel <= EnvironmentalReverb::MAX_ROOM_LEVEL_MB;
bool isRoomLevelInRange(const EnvironmentalReverb::Capability& cap, int roomLevel) const {
return roomLevel >= cap.minRoomLevelMb && roomLevel <= cap.maxRoomLevelMb;
}
bool isRoomHfLevelInRange(int roomHfLevel) const {
return roomHfLevel >= EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB &&
roomHfLevel <= EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB;
bool isRoomHfLevelInRange(const EnvironmentalReverb::Capability& cap, int roomHfLevel) const {
return roomHfLevel >= cap.minRoomHfLevelMb && roomHfLevel <= cap.maxRoomHfLevelMb;
}
bool isDecayTimeInRange(const EnvironmentalReverb::Capability& cap, int decayTime) const {
return decayTime >= EnvironmentalReverb::MIN_DECAY_TIME_MS &&
decayTime <= EnvironmentalReverb::MAX_DECAY_TIME_MS &&
decayTime <= cap.maxDecayTimeMs;
return decayTime >= 0 && decayTime <= cap.maxDecayTimeMs;
}
bool isDecayHfRatioInRange(int decayHfRatio) const {
return decayHfRatio >= EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM &&
decayHfRatio <= EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM;
bool isDecayHfRatioInRange(const EnvironmentalReverb::Capability& cap, int decayHfRatio) const {
return decayHfRatio >= cap.minDecayHfRatioPm && decayHfRatio <= cap.maxDecayHfRatioPm;
}
bool isLevelInRange(int level) const {
return level >= EnvironmentalReverb::MIN_LEVEL_MB &&
level <= EnvironmentalReverb::MAX_LEVEL_MB;
bool isLevelInRange(const EnvironmentalReverb::Capability& cap, int level) const {
return level >= cap.minLevelMb && level <= cap.maxLevelMb;
}
bool isDelayInRange(int delay) const {
return delay >= EnvironmentalReverb::MIN_DELAY_MS &&
delay <= EnvironmentalReverb::MAX_DELAY_MS;
bool isDelayInRange(const EnvironmentalReverb::Capability& cap, int delay) const {
return delay >= 0 && delay <= cap.maxDelayMs;
}
bool isDiffusionInRange(int diffusion) const {
return diffusion >= EnvironmentalReverb::MIN_DIFFUSION_PM &&
diffusion <= EnvironmentalReverb::MAX_DIFFUSION_PM;
bool isDiffusionInRange(const EnvironmentalReverb::Capability& cap, int diffusion) const {
return diffusion >= 0 && diffusion <= cap.maxDiffusionPm;
}
bool isDensityInRange(int density) const {
return density >= EnvironmentalReverb::MIN_DENSITY_PM &&
density <= EnvironmentalReverb::MAX_DENSITY_PM;
bool isDensityInRange(const EnvironmentalReverb::Capability& cap, int density) const {
return density >= 0 && density <= cap.maxDensityPm;
}
static std::unordered_set<int> getRoomLevelValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
int minRoomLevelMb = std::numeric_limits<int>::max();
int maxRoomLevelMb = std::numeric_limits<int>::min();
for (const auto& it : descList) {
maxRoomLevelMb = std::max(
it.second.capability.get<Capability::environmentalReverb>().maxRoomLevelMb,
maxRoomLevelMb);
minRoomLevelMb = std::min(
it.second.capability.get<Capability::environmentalReverb>().minRoomLevelMb,
minRoomLevelMb);
}
return {std::numeric_limits<int>::min(), minRoomLevelMb - 1, minRoomLevelMb,
(minRoomLevelMb + maxRoomLevelMb) >> 1, maxRoomLevelMb, maxRoomLevelMb + 1,
std::numeric_limits<int>::max()};
}
static std::unordered_set<int> getRoomHfLevelValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
int minRoomHfLevelMb = std::numeric_limits<int>::max();
int maxRoomHfLevelMb = std::numeric_limits<int>::min();
for (const auto& it : descList) {
maxRoomHfLevelMb = std::max(
it.second.capability.get<Capability::environmentalReverb>().maxRoomHfLevelMb,
maxRoomHfLevelMb);
minRoomHfLevelMb = std::min(
it.second.capability.get<Capability::environmentalReverb>().minRoomHfLevelMb,
minRoomHfLevelMb);
}
return {std::numeric_limits<int>::min(),
minRoomHfLevelMb - 1,
minRoomHfLevelMb,
(minRoomHfLevelMb + maxRoomHfLevelMb) >> 1,
maxRoomHfLevelMb,
maxRoomHfLevelMb + 1,
std::numeric_limits<int>::max()};
}
static std::unordered_set<int> getDecayTimeValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
const auto max = std::max_element(
descList.begin(), descList.end(),
[](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
return a.second.capability.get<Capability::environmentalReverb>()
.maxDecayTimeMs <
b.second.capability.get<Capability::environmentalReverb>()
.maxDecayTimeMs;
});
if (max == descList.end()) {
return {0};
}
int maxDecayTimeMs =
max->second.capability.get<Capability::environmentalReverb>().maxDecayTimeMs;
return {-1, 0, maxDecayTimeMs >> 1, maxDecayTimeMs - 1, maxDecayTimeMs, maxDecayTimeMs + 1};
}
static std::unordered_set<int> getDecayHfRatioValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
int minDecayHfRatioPm = std::numeric_limits<int>::max();
int maxDecayHfRatioPm = std::numeric_limits<int>::min();
for (const auto& it : descList) {
maxDecayHfRatioPm = std::max(
it.second.capability.get<Capability::environmentalReverb>().maxDecayHfRatioPm,
maxDecayHfRatioPm);
minDecayHfRatioPm = std::min(
it.second.capability.get<Capability::environmentalReverb>().minDecayHfRatioPm,
minDecayHfRatioPm);
}
return {std::numeric_limits<int>::min(),
minDecayHfRatioPm - 1,
minDecayHfRatioPm,
(minDecayHfRatioPm + maxDecayHfRatioPm) >> 1,
maxDecayHfRatioPm,
maxDecayHfRatioPm + 1,
std::numeric_limits<int>::max()};
}
static std::unordered_set<int> getLevelValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
int minLevelMb = std::numeric_limits<int>::max();
int maxLevelMb = std::numeric_limits<int>::min();
for (const auto& it : descList) {
maxLevelMb =
std::max(it.second.capability.get<Capability::environmentalReverb>().maxLevelMb,
maxLevelMb);
minLevelMb =
std::min(it.second.capability.get<Capability::environmentalReverb>().minLevelMb,
minLevelMb);
}
return {std::numeric_limits<int>::min(), minLevelMb - 1, minLevelMb,
(minLevelMb + maxLevelMb) >> 1, maxLevelMb, maxLevelMb + 1,
std::numeric_limits<int>::max()};
}
static std::unordered_set<int> getDelayValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
const auto max = std::max_element(
descList.begin(), descList.end(),
[](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
return a.second.capability.get<Capability::environmentalReverb>().maxDelayMs <
b.second.capability.get<Capability::environmentalReverb>().maxDelayMs;
});
if (max == descList.end()) {
return {0};
}
int maxDelayMs = max->second.capability.get<Capability::environmentalReverb>().maxDelayMs;
return {-1, 0, maxDelayMs >> 1, maxDelayMs - 1, maxDelayMs, maxDelayMs + 1};
}
static std::unordered_set<int> getDiffusionValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
const auto max = std::max_element(
descList.begin(), descList.end(),
[](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
return a.second.capability.get<Capability::environmentalReverb>()
.maxDiffusionPm <
b.second.capability.get<Capability::environmentalReverb>()
.maxDiffusionPm;
});
if (max == descList.end()) {
return {0};
}
int maxDiffusionPm =
max->second.capability.get<Capability::environmentalReverb>().maxDiffusionPm;
return {-1, 0, maxDiffusionPm >> 1, maxDiffusionPm - 1, maxDiffusionPm, maxDiffusionPm + 1};
}
static std::unordered_set<int> getDensityValues() {
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kEnvReverbTypeUUID);
const auto max = std::max_element(
descList.begin(), descList.end(),
[](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
return a.second.capability.get<Capability::environmentalReverb>().maxDensityPm <
b.second.capability.get<Capability::environmentalReverb>().maxDensityPm;
});
if (max == descList.end()) {
return {0};
}
int maxDensityPm =
max->second.capability.get<Capability::environmentalReverb>().maxDensityPm;
return {-1, 0, maxDensityPm >> 1, maxDensityPm - 1, maxDensityPm, maxDensityPm + 1};
}
private:
@ -310,7 +432,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbRoomLevelTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kRoomLevelValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getRoomLevelValues())),
[](const testing::TestParamInfo<EnvironmentalReverbRoomLevelTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string roomLevel = std::to_string(std::get<1>(info.param));
@ -347,7 +469,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbRoomHfLevelTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kRoomHfLevelValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getRoomHfLevelValues())),
[](const testing::TestParamInfo<EnvironmentalReverbRoomHfLevelTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string roomHfLevel = std::to_string(std::get<1>(info.param));
@ -384,7 +506,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDecayTimeTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kDecayTimeValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getDecayTimeValues())),
[](const testing::TestParamInfo<EnvironmentalReverbDecayTimeTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string decayTime = std::to_string(std::get<1>(info.param));
@ -421,7 +543,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDecayHfRatioTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kDecayHfRatioValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getDecayHfRatioValues())),
[](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string decayHfRatio = std::to_string(std::get<1>(info.param));
@ -459,7 +581,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbLevelTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kLevelValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getLevelValues())),
[](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string level = std::to_string(std::get<1>(info.param));
@ -496,7 +618,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDelayTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kDelayValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getDelayValues())),
[](const testing::TestParamInfo<EnvironmentalReverbDelayTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string delay = std::to_string(std::get<1>(info.param));
@ -533,7 +655,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDiffusionTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kDiffusionValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getDiffusionValues())),
[](const testing::TestParamInfo<EnvironmentalReverbDiffusionTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string diffusion = std::to_string(std::get<1>(info.param));
@ -570,7 +692,7 @@ INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDensityTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
testing::ValuesIn(kDensityValues)),
testing::ValuesIn(EnvironmentalReverbHelper::getDensityValues())),
[](const testing::TestParamInfo<EnvironmentalReverbDensityTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string density = std::to_string(std::get<1>(info.param));