Audio mixer: Remove option for linear gain sliders

* always use non-linear gain sliders (was the default setting)
* remove functions and members connected to linear gain setting
* remove "(like BeOS R5)" from "Attenuate by 3 dB" option
* add "Low/High quality" to resample algorithm option

Fixes part of #17554

Change-Id: I746da3f5bcc8f0cb017c75509565b535d5442f71
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4917
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Humdinger 2022-01-28 19:12:55 +01:00 committed by Adrien Destugues
parent 4ac99e3932
commit 8b35436293
3 changed files with 25 additions and 67 deletions

View File

@ -1206,7 +1206,6 @@ float
AudioMixer::dB_to_Gain(float db) AudioMixer::dB_to_Gain(float db)
{ {
TRACE("dB_to_Gain: dB in: %01.2f ", db); TRACE("dB_to_Gain: dB in: %01.2f ", db);
if (fCore->Settings()->NonLinearGainSlider()) {
if (db > 0) { if (db > 0) {
db = db * (pow(abs(DB_MAX), (1.0 / DB_EXPONENT_POSITIVE)) db = db * (pow(abs(DB_MAX), (1.0 / DB_EXPONENT_POSITIVE))
/ abs(DB_MAX)); / abs(DB_MAX));
@ -1218,7 +1217,6 @@ AudioMixer::dB_to_Gain(float db)
db = pow(db, DB_EXPONENT_NEGATIVE); db = pow(db, DB_EXPONENT_NEGATIVE);
db = -db; db = -db;
} }
}
TRACE("dB out: %01.2f\n", db); TRACE("dB out: %01.2f\n", db);
return pow(10.0, db / 20.0); return pow(10.0, db / 20.0);
} }
@ -1229,7 +1227,6 @@ AudioMixer::Gain_to_dB(float gain)
{ {
float db; float db;
db = 20.0 * log10(gain); db = 20.0 * log10(gain);
if (fCore->Settings()->NonLinearGainSlider()) {
if (db > 0) { if (db > 0) {
db = pow(db, (1.0 / DB_EXPONENT_POSITIVE)); db = pow(db, (1.0 / DB_EXPONENT_POSITIVE));
db = db * (abs(DB_MAX) / pow(abs(DB_MAX), db = db * (abs(DB_MAX) / pow(abs(DB_MAX),
@ -1241,7 +1238,6 @@ AudioMixer::Gain_to_dB(float gain)
(1.0 / DB_EXPONENT_NEGATIVE))); (1.0 / DB_EXPONENT_NEGATIVE)));
db = -db; db = -db;
} }
}
return db; return db;
} }
@ -1262,10 +1258,6 @@ AudioMixer::GetParameterValue(int32 id, bigtime_t *last_change, void *value,
*ioSize = sizeof(int32); *ioSize = sizeof(int32);
static_cast<int32 *>(value)[0] = fCore->Settings()->AttenuateOutput(); static_cast<int32 *>(value)[0] = fCore->Settings()->AttenuateOutput();
break; break;
case 20: // Use non linear gain sliders
*ioSize = sizeof(int32);
static_cast<int32 *>(value)[0] = fCore->Settings()->NonLinearGainSlider();
break;
case 30: // Display balance control for stereo connections case 30: // Display balance control for stereo connections
*ioSize = sizeof(int32); *ioSize = sizeof(int32);
static_cast<int32 *>(value)[0] = fCore->Settings()->UseBalanceControl(); static_cast<int32 *>(value)[0] = fCore->Settings()->UseBalanceControl();
@ -1474,12 +1466,6 @@ AudioMixer::SetParameterValue(int32 id, bigtime_t when, const void *value,
// this value is special (see MixerCore.h) and we need to notify the core // this value is special (see MixerCore.h) and we need to notify the core
fCore->SetOutputAttenuation((static_cast<const int32 *>(value)[0]) ? 0.708 : 1.0); fCore->SetOutputAttenuation((static_cast<const int32 *>(value)[0]) ? 0.708 : 1.0);
break; break;
case 20: // Use non linear gain sliders
if (size != sizeof(int32))
goto err;
fCore->Settings()->SetNonLinearGainSlider(static_cast<const int32 *>(value)[0]);
update = true; // XXX should use BroadcastChangedParameter()
break;
case 30: // Display balance control for stereo connections case 30: // Display balance control for stereo connections
if (size != sizeof(int32)) if (size != sizeof(int32))
goto err; goto err;
@ -1879,9 +1865,7 @@ AudioMixer::UpdateParameterWeb()
group = top->MakeGroup(""); group = top->MakeGroup("");
group->MakeDiscreteParameter(PARAM_ETC(10), B_MEDIA_RAW_AUDIO, group->MakeDiscreteParameter(PARAM_ETC(10), B_MEDIA_RAW_AUDIO,
B_TRANSLATE("Attenuate mixer output by 3dB (like BeOS R5)"), B_ENABLE); B_TRANSLATE("Attenuate mixer output by 3 dB"), B_ENABLE);
group->MakeDiscreteParameter(PARAM_ETC(20), B_MEDIA_RAW_AUDIO,
B_TRANSLATE("Use non linear gain sliders (like BeOS R5)"), B_ENABLE);
group->MakeDiscreteParameter(PARAM_ETC(30), B_MEDIA_RAW_AUDIO, group->MakeDiscreteParameter(PARAM_ETC(30), B_MEDIA_RAW_AUDIO,
B_TRANSLATE("Display balance control for stereo connections"), B_TRANSLATE("Display balance control for stereo connections"),
B_ENABLE); B_ENABLE);
@ -1892,14 +1876,14 @@ AudioMixer::UpdateParameterWeb()
B_TRANSLATE("Allow input channel remapping"), B_ENABLE); B_TRANSLATE("Allow input channel remapping"), B_ENABLE);
dp = group->MakeDiscreteParameter(PARAM_ETC(60), B_MEDIA_RAW_AUDIO, dp = group->MakeDiscreteParameter(PARAM_ETC(60), B_MEDIA_RAW_AUDIO,
B_TRANSLATE("Input gain controls represent"), B_INPUT_MUX); B_TRANSLATE("Input gain controls represent:"), B_INPUT_MUX);
dp->AddItem(0, B_TRANSLATE("Physical input channels")); dp->AddItem(0, B_TRANSLATE("Physical input channels"));
dp->AddItem(1, B_TRANSLATE("Virtual output channels")); dp->AddItem(1, B_TRANSLATE("Virtual output channels"));
dp = group->MakeDiscreteParameter(PARAM_ETC(70), B_MEDIA_RAW_AUDIO, dp = group->MakeDiscreteParameter(PARAM_ETC(70), B_MEDIA_RAW_AUDIO,
B_TRANSLATE("Resampling algorithm"), B_INPUT_MUX); B_TRANSLATE("Resampling algorithm:"), B_INPUT_MUX);
dp->AddItem(0, B_TRANSLATE("Drop/repeat samples")); dp->AddItem(0, B_TRANSLATE("Low quality (drop/repeat samples)"));
dp->AddItem(2, B_TRANSLATE("Linear interpolation")); dp->AddItem(2, B_TRANSLATE("High quality (linear interpolation)"));
// Note: The following code is outcommented on purpose // Note: The following code is outcommented on purpose
// and is about to be modified at a later point // and is about to be modified at a later point

View File

@ -85,27 +85,6 @@ MixerSettings::SetAttenuateOutput(bool yesno)
} }
bool
MixerSettings::NonLinearGainSlider()
{
bool temp;
fLocker->Lock();
temp = fSettings.NonLinearGainSlider;
fLocker->Unlock();
return temp;
}
void
MixerSettings::SetNonLinearGainSlider(bool yesno)
{
fLocker->Lock();
fSettings.NonLinearGainSlider = yesno;
fLocker->Unlock();
StartDeferredSave();
}
bool bool
MixerSettings::UseBalanceControl() MixerSettings::UseBalanceControl()
{ {
@ -418,7 +397,6 @@ MixerSettings::Load()
fLocker->Lock(); fLocker->Lock();
// setup defaults // setup defaults
fSettings.AttenuateOutput = true; fSettings.AttenuateOutput = true;
fSettings.NonLinearGainSlider = true;
fSettings.UseBalanceControl = false; fSettings.UseBalanceControl = false;
fSettings.AllowOutputChannelRemapping = false; fSettings.AllowOutputChannelRemapping = false;
fSettings.AllowInputChannelRemapping = false; fSettings.AllowInputChannelRemapping = false;

View File

@ -26,9 +26,6 @@ class MixerSettings {
bool AttenuateOutput(); bool AttenuateOutput();
void SetAttenuateOutput(bool yesno); void SetAttenuateOutput(bool yesno);
bool NonLinearGainSlider();
void SetNonLinearGainSlider(bool yesno);
bool UseBalanceControl(); bool UseBalanceControl();
void SetUseBalanceControl(bool yesno); void SetUseBalanceControl(bool yesno);
@ -76,7 +73,6 @@ class MixerSettings {
struct settings { struct settings {
bool AttenuateOutput; bool AttenuateOutput;
bool NonLinearGainSlider;
bool UseBalanceControl; bool UseBalanceControl;
bool AllowOutputChannelRemapping; bool AllowOutputChannelRemapping;
bool AllowInputChannelRemapping; bool AllowInputChannelRemapping;