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

View file

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

View file

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