diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl index 7f34f334dd..9edad093d2 100644 --- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl +++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl @@ -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; } } diff --git a/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl index 81c0dde8f8..fc98fe6c84 100644 --- a/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl +++ b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl @@ -49,113 +49,97 @@ union EnvironmentalReverb { parcelable Capability { VendorExtension extension; + /** + * Minimal possible room level in millibels. + */ + int minRoomLevelMb; + /** + * Maximum possible room level in millibels. + */ + int maxRoomLevelMb; + /** + * Minimal possible room hf level in millibels. + */ + int minRoomHfLevelMb; + /** + * Maximum possible room hf level in millibels. + */ + int maxRoomHfLevelMb; /** * Max decay time supported in millisecond. */ int maxDecayTimeMs; + /** + * Minimal possible per mille decay hf ratio. + */ + int minDecayHfRatioPm; + /** + * Maximum possible per mille decay hf ratio. + */ + int maxDecayHfRatioPm; + /** + * Minimal possible room level in millibels. + */ + int minLevelMb; + /** + * Maximum possible room level in millibels. + */ + int maxLevelMb; + /** + * Maximum possible delay time in milliseconds. + */ + int maxDelayMs; + /** + * Maximum possible per mille diffusion. + */ + int maxDiffusionPm; + /** + * Maximum possible per mille density. + */ + int maxDensityPm; } /** - * Minimal possible room level in millibels. - */ - const int MIN_ROOM_LEVEL_MB = -6000; - /** - * Maximum possible room level in millibels. - */ - const int MAX_ROOM_LEVEL_MB = 0; - /** - * Room level apply to the reverb effect in millibels. + * 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; - /** - * Minimal possible room hf level in millibels. - */ - const int MIN_ROOM_HF_LEVEL_MB = -4000; - /** - * Maximum possible room hf level in millibels. - */ - const int MAX_ROOM_HF_LEVEL_MB = 0; - /** - * Room HF level apply to the reverb effect in millibels. + * 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; - /** - * 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. + * 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; - /** - * Minimal possible per mille decay hf ratio. - */ - const int MIN_DECAY_HF_RATIO_PM = 100; - /** - * Maximum possible per mille decay hf ratio. - */ - const int MAX_DECAY_HF_RATIO_PM = 1000; - /** - * HF decay ratio in permilles. + * 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; - /** - * Minimal possible room level in millibels. - */ - const int MIN_LEVEL_MB = -6000; - /** - * Maximum possible room level in millibels. - */ - const int MAX_LEVEL_MB = 0; - /** - * Reverb level in millibels. + * 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; - /** - * Minimal possible delay time in milliseconds. - */ - const int MIN_DELAY_MS = 0; - /** - * Maximum possible delay time in milliseconds. - */ - const int MAX_DELAY_MS = 65; - /** - * Reverb delay in milliseconds. + * 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; - /** - * Minimal possible per mille diffusion. - */ - const int MIN_DIFFUSION_PM = 0; - /** - * Maximum possible per mille diffusion. - */ - const int MAX_DIFFUSION_PM = 1000; - /** - * Diffusion in permilles. + * Diffusion in permilles. The value of the diffusionPm must be non-negative and not + * exceed the value specified by the 'maxDiffusionPm' capability. */ int diffusionPm; - /** - * Minimal possible per mille density. - */ - const int MIN_DENSITY_PM = 0; - /** - * Maximum possible per mille density. - */ - const int MAX_DENSITY_PM = 1000; - /** - * Density in permilles. + * Density in permilles. The value of the densityPm must be non-negative and not + * exceed the value specified by the 'maxDensityPm' capability. */ int densityPm; diff --git a/audio/aidl/default/envReverb/EnvReverbSw.cpp b/audio/aidl/default/envReverb/EnvReverbSw.cpp index 9d7159a452..905dba4dfc 100644 --- a/audio/aidl/default/envReverb/EnvReverbSw.cpp +++ b/audio/aidl/default/envReverb/EnvReverbSw.cpp @@ -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 diff --git a/audio/aidl/default/envReverb/EnvReverbSw.h b/audio/aidl/default/envReverb/EnvReverbSw.h index f52121597a..77f384ed83 100644 --- a/audio/aidl/default/envReverb/EnvReverbSw.h +++ b/audio/aidl/default/envReverb/EnvReverbSw.h @@ -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 }; diff --git a/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp b/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp index e99c4a449e..82c87573ad 100644 --- a/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp +++ b/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp @@ -18,6 +18,7 @@ #include #include +#include #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 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 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 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 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 kLevelValues = { - EnvironmentalReverb::MIN_LEVEL_MB - 1, EnvironmentalReverb::MIN_LEVEL_MB, - EnvironmentalReverb::MAX_LEVEL_MB, EnvironmentalReverb::MAX_LEVEL_MB + 1}; -const std::vector kDelayValues = { - EnvironmentalReverb::MIN_DELAY_MS - 1, EnvironmentalReverb::MIN_DELAY_MS, - EnvironmentalReverb::MAX_DELAY_MS, EnvironmentalReverb::MAX_DELAY_MS + 1}; -const std::vector kDiffusionValues = { - EnvironmentalReverb::MIN_DIFFUSION_PM - 1, EnvironmentalReverb::MIN_DIFFUSION_PM, - EnvironmentalReverb::MAX_DIFFUSION_PM, EnvironmentalReverb::MAX_DIFFUSION_PM + 1}; -const std::vector 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::MIN_ROOM_LEVEL_MB); + EnvironmentalReverb er = EnvironmentalReverb::make(-6000); Parameter::Specific specific = Parameter::Specific::make(er); return specific; @@ -99,14 +75,14 @@ class EnvironmentalReverbHelper : public EffectHelper { std::shared_ptr mFactory; std::shared_ptr 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(); - return isRoomLevelInRange(roomLevel); + return isRoomLevelInRange(erCap, roomLevel); } case EnvironmentalReverb::roomHfLevelMb: { int roomHfLevel = er.get(); - return isRoomHfLevelInRange(roomHfLevel); + return isRoomHfLevelInRange(erCap, roomHfLevel); } case EnvironmentalReverb::decayTimeMs: { int decayTime = er.get(); @@ -214,23 +190,23 @@ class EnvironmentalReverbHelper : public EffectHelper { } case EnvironmentalReverb::decayHfRatioPm: { int decayHfRatio = er.get(); - return isDecayHfRatioInRange(decayHfRatio); + return isDecayHfRatioInRange(erCap, decayHfRatio); } case EnvironmentalReverb::levelMb: { int level = er.get(); - return isLevelInRange(level); + return isLevelInRange(erCap, level); } case EnvironmentalReverb::delayMs: { int delay = er.get(); - return isDelayInRange(delay); + return isDelayInRange(erCap, delay); } case EnvironmentalReverb::diffusionPm: { int diffusion = er.get(); - return isDiffusionInRange(diffusion); + return isDiffusionInRange(erCap, diffusion); } case EnvironmentalReverb::densityPm: { int density = er.get(); - 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 getRoomLevelValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + int minRoomLevelMb = std::numeric_limits::max(); + int maxRoomLevelMb = std::numeric_limits::min(); + for (const auto& it : descList) { + maxRoomLevelMb = std::max( + it.second.capability.get().maxRoomLevelMb, + maxRoomLevelMb); + minRoomLevelMb = std::min( + it.second.capability.get().minRoomLevelMb, + minRoomLevelMb); + } + return {std::numeric_limits::min(), minRoomLevelMb - 1, minRoomLevelMb, + (minRoomLevelMb + maxRoomLevelMb) >> 1, maxRoomLevelMb, maxRoomLevelMb + 1, + std::numeric_limits::max()}; + } + + static std::unordered_set getRoomHfLevelValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + int minRoomHfLevelMb = std::numeric_limits::max(); + int maxRoomHfLevelMb = std::numeric_limits::min(); + for (const auto& it : descList) { + maxRoomHfLevelMb = std::max( + it.second.capability.get().maxRoomHfLevelMb, + maxRoomHfLevelMb); + minRoomHfLevelMb = std::min( + it.second.capability.get().minRoomHfLevelMb, + minRoomHfLevelMb); + } + return {std::numeric_limits::min(), + minRoomHfLevelMb - 1, + minRoomHfLevelMb, + (minRoomHfLevelMb + maxRoomHfLevelMb) >> 1, + maxRoomHfLevelMb, + maxRoomHfLevelMb + 1, + std::numeric_limits::max()}; + } + + static std::unordered_set getDecayTimeValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + const auto max = std::max_element( + descList.begin(), descList.end(), + [](const std::pair, Descriptor>& a, + const std::pair, Descriptor>& b) { + return a.second.capability.get() + .maxDecayTimeMs < + b.second.capability.get() + .maxDecayTimeMs; + }); + if (max == descList.end()) { + return {0}; + } + int maxDecayTimeMs = + max->second.capability.get().maxDecayTimeMs; + return {-1, 0, maxDecayTimeMs >> 1, maxDecayTimeMs - 1, maxDecayTimeMs, maxDecayTimeMs + 1}; + } + + static std::unordered_set getDecayHfRatioValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + int minDecayHfRatioPm = std::numeric_limits::max(); + int maxDecayHfRatioPm = std::numeric_limits::min(); + for (const auto& it : descList) { + maxDecayHfRatioPm = std::max( + it.second.capability.get().maxDecayHfRatioPm, + maxDecayHfRatioPm); + minDecayHfRatioPm = std::min( + it.second.capability.get().minDecayHfRatioPm, + minDecayHfRatioPm); + } + return {std::numeric_limits::min(), + minDecayHfRatioPm - 1, + minDecayHfRatioPm, + (minDecayHfRatioPm + maxDecayHfRatioPm) >> 1, + maxDecayHfRatioPm, + maxDecayHfRatioPm + 1, + std::numeric_limits::max()}; + } + + static std::unordered_set getLevelValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + int minLevelMb = std::numeric_limits::max(); + int maxLevelMb = std::numeric_limits::min(); + for (const auto& it : descList) { + maxLevelMb = + std::max(it.second.capability.get().maxLevelMb, + maxLevelMb); + minLevelMb = + std::min(it.second.capability.get().minLevelMb, + minLevelMb); + } + return {std::numeric_limits::min(), minLevelMb - 1, minLevelMb, + (minLevelMb + maxLevelMb) >> 1, maxLevelMb, maxLevelMb + 1, + std::numeric_limits::max()}; + } + + static std::unordered_set getDelayValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + const auto max = std::max_element( + descList.begin(), descList.end(), + [](const std::pair, Descriptor>& a, + const std::pair, Descriptor>& b) { + return a.second.capability.get().maxDelayMs < + b.second.capability.get().maxDelayMs; + }); + if (max == descList.end()) { + return {0}; + } + int maxDelayMs = max->second.capability.get().maxDelayMs; + return {-1, 0, maxDelayMs >> 1, maxDelayMs - 1, maxDelayMs, maxDelayMs + 1}; + } + + static std::unordered_set getDiffusionValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + const auto max = std::max_element( + descList.begin(), descList.end(), + [](const std::pair, Descriptor>& a, + const std::pair, Descriptor>& b) { + return a.second.capability.get() + .maxDiffusionPm < + b.second.capability.get() + .maxDiffusionPm; + }); + if (max == descList.end()) { + return {0}; + } + int maxDiffusionPm = + max->second.capability.get().maxDiffusionPm; + return {-1, 0, maxDiffusionPm >> 1, maxDiffusionPm - 1, maxDiffusionPm, maxDiffusionPm + 1}; + } + + static std::unordered_set getDensityValues() { + auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, + kEnvReverbTypeUUID); + const auto max = std::max_element( + descList.begin(), descList.end(), + [](const std::pair, Descriptor>& a, + const std::pair, Descriptor>& b) { + return a.second.capability.get().maxDensityPm < + b.second.capability.get().maxDensityPm; + }); + if (max == descList.end()) { + return {0}; + } + int maxDensityPm = + max->second.capability.get().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& 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& 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& 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& 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& 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& 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& 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& info) { auto descriptor = std::get<0>(info.param).second; std::string density = std::to_string(std::get<1>(info.param));