Separate default quality setting for encoders.

Instead of having a global quality setting for the encoder make the encoder
provide its default value by itself. Fixes the libmp3lame encoder using an
unsuitable value since the range differs greatly between the encoders.

Centralize reading the configuration values for rbspeex. The values are stored
in member variables, so it's not necessary to read them multiple times.

Change-Id: Ia26cb1fc3bb4f927d13212fe7883bdfe2571a711
This commit is contained in:
Dominik Riebeling 2012-01-29 15:36:30 +01:00
parent 933a674891
commit 0ae49c2719
3 changed files with 28 additions and 24 deletions

View file

@ -28,14 +28,15 @@ EncoderRbSpeex::EncoderRbSpeex(QObject *parent) : EncoderBase(parent)
void EncoderRbSpeex::generateSettings()
{
insertSetting(eVOLUME,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,
tr("Volume:"),RbSettings::subValue("rbspeex",RbSettings::EncoderVolume),1.0,10.0));
insertSetting(eQUALITY,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,
tr("Quality:"),RbSettings::subValue("rbspeex",RbSettings::EncoderQuality),0,10.0));
insertSetting(eCOMPLEXITY,new EncTtsSetting(this,EncTtsSetting::eINT,
tr("Complexity:"),RbSettings::subValue("rbspeex",RbSettings::EncoderComplexity),0,10));
insertSetting(eNARROWBAND,new EncTtsSetting(this,EncTtsSetting::eBOOL,
tr("Use Narrowband:"),RbSettings::subValue("rbspeex",RbSettings::EncoderNarrowBand)));
loadSettings();
insertSetting(eVOLUME, new EncTtsSetting(this, EncTtsSetting::eDOUBLE,
tr("Volume:"), volume, 1.0, 10.0));
insertSetting(eQUALITY, new EncTtsSetting(this, EncTtsSetting::eDOUBLE,
tr("Quality:"), quality, 0, 10.0));
insertSetting(eCOMPLEXITY, new EncTtsSetting(this, EncTtsSetting::eINT,
tr("Complexity:"), complexity, 0, 10));
insertSetting(eNARROWBAND,new EncTtsSetting(this, EncTtsSetting::eBOOL,
tr("Use Narrowband:"), narrowband));
}
void EncoderRbSpeex::saveSettings()
@ -53,16 +54,25 @@ void EncoderRbSpeex::saveSettings()
RbSettings::sync();
}
bool EncoderRbSpeex::start()
{
void EncoderRbSpeex::loadSettings(void)
{
// try to get config from settings
quality = RbSettings::subValue("rbspeex", RbSettings::EncoderQuality).toDouble();
if(quality < 0) {
quality = 8.0;
}
complexity = RbSettings::subValue("rbspeex", RbSettings::EncoderComplexity).toInt();
volume = RbSettings::subValue("rbspeex", RbSettings::EncoderVolume).toDouble();
narrowband = RbSettings::subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool();
}
bool EncoderRbSpeex::start()
{
// make sure configuration parameters are set.
loadSettings();
return true;
}
@ -98,18 +108,11 @@ bool EncoderRbSpeex::encode(QString input,QString output)
bool EncoderRbSpeex::configOk()
{
bool result=true;
// check config
if(RbSettings::subValue("rbspeex", RbSettings::EncoderVolume).toDouble() <= 0)
result =false;
if(RbSettings::subValue("rbspeex", RbSettings::EncoderQuality).toDouble() <= 0)
result =false;
if(RbSettings::subValue("rbspeex", RbSettings::EncoderComplexity).toInt() <= 0)
result =false;
return result;
// check config. Make sure current settings are loaded.
loadSettings();
if(volume <= 0 || quality <= 0 || complexity <= 0)
return false;
else
return true;
}

View file

@ -45,6 +45,7 @@ class EncoderRbSpeex : public EncoderBase
void saveSettings();
private:
void loadSettings(void);
float quality;
float volume;
int complexity;

View file

@ -64,7 +64,7 @@ const static struct {
{ RbSettings::WavtrimThreshold, "wavtrimthreshold", "500"},
{ RbSettings::TtsSpeed, ":tts:/speed", "175" },
{ RbSettings::EncoderComplexity, ":encoder:/complexity", "10" },
{ RbSettings::EncoderQuality, ":encoder:/quality", "8.0" },
{ RbSettings::EncoderQuality, ":encoder:/quality", "-1.0" },
{ RbSettings::EncoderVolume, ":encoder:/volume", "1.0" },
};