From 8fea9ce5c18c2bebd5451dcfc89830e99e22d687 Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Wed, 20 Sep 2006 22:30:42 +0000 Subject: [PATCH] TTS Volume adjustable git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@369 05730e5d-ab1b-0410-a4ac-84af385074fa --- Log.cpp | 22 ++++++++++++++++++++++ Log.h | 1 + Settings.cpp | 3 +++ Settings.h | 1 + TextToSpeech.h | 1 + TextToSpeech_win.cpp | 9 +++++++++ 6 files changed, 37 insertions(+) diff --git a/Log.cpp b/Log.cpp index a74b307f8..07ed802a1 100644 --- a/Log.cpp +++ b/Log.cpp @@ -82,8 +82,27 @@ LogConfig::LogConfig(QWidget *p) : ConfigWidget(p) { qgbMessages->setLayout(l); + QGroupBox *qgbTTS = new QGroupBox(tr("Text To Speech")); + l = new QGridLayout(); + + lab=new QLabel(tr("Volume")); + l->addWidget(lab,0,0); + qsVolume = new QSlider(Qt::Horizontal); + qsVolume->setRange(0, 100); + qsVolume->setSingleStep(5); + qsVolume->setPageStep(20); + qsVolume->setValue(g.s.iTTSVolume); + qsVolume->setObjectName("Volume"); + qsVolume->setToolTip(tr("Volume of Text-To-Speech Engine")); + qsVolume->setWhatsThis(tr("This is the volume used for the speech synthesis.")); + l->addWidget(qsVolume,0,1); + + qgbTTS->setLayout(l); + + QVBoxLayout *v = new QVBoxLayout; v->addWidget(qgbMessages); + v->addWidget(qgbTTS); v->addStretch(1); setLayout(v); @@ -105,6 +124,8 @@ void LogConfig::accept() { ms->bConsole = (qlConsole[i]->checkState() == Qt::Checked); ms->bTTS = (qlTTS[i]->checkState() == Qt::Checked); } + g.s.iTTSVolume=qsVolume->value(); + g.l->tts->setVolume(g.s.iTTSVolume); } MsgSettings::MsgSettings() { @@ -118,6 +139,7 @@ Log::Log(QObject *p) : QObject(p) { qhSettings[static_cast(i)]=new MsgSettings(); tts=new TextToSpeech(this); loadSettings(); + tts->setVolume(g.s.iTTSVolume); } const char *Log::msgNames[] = { diff --git a/Log.h b/Log.h index b2cb51f7e..7627b141e 100644 --- a/Log.h +++ b/Log.h @@ -48,6 +48,7 @@ class LogConfig : public ConfigWidget { protected: QList qlConsole; QList qlTTS; + QSlider *qsVolume; public: LogConfig(QWidget *p = NULL); virtual QString title() const; diff --git a/Settings.cpp b/Settings.cpp index a865fc5cd..54c9ffc9a 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -36,6 +36,7 @@ Settings::Settings() { a3dModel = None; bMute = bDeaf = false; bTTS = true; + iTTSVolume = 75; iQuality = 8; iComplexity = 4; iMinLoudness = 4000; @@ -69,6 +70,7 @@ void Settings::load() { bMute = g.qs->value("AudioMute", false). toBool(); bDeaf = g.qs->value("AudioDeaf", false). toBool(); bTTS = g.qs->value("TextToSpeech", bTTS). toBool(); + iTTSVolume = g.qs->value("TTSVolume", iTTSVolume).toInt(); atTransmit = static_cast(g.qs->value("AudioTransmit", atTransmit).toInt()); a3dModel = static_cast(g.qs->value("Audio3D", a3dModel).toInt()); iQuality = g.qs->value("AudioQuality", iQuality).toInt(); @@ -107,6 +109,7 @@ void Settings::save() { g.qs->setValue("AudioMute", g.s.bMute); g.qs->setValue("AudioDeaf", g.s.bDeaf); g.qs->setValue("TextToSpeech", g.s.bTTS); + g.qs->setValue("TTSVolume", g.s.iTTSVolume); g.qs->setValue("PosTransmit", g.s.bTransmitPosition); g.qs->setValue("AudioTransmit", g.s.atTransmit); g.qs->setValue("Audio3D", g.s.a3dModel); diff --git a/Settings.h b/Settings.h index d030ffd15..44af1929f 100644 --- a/Settings.h +++ b/Settings.h @@ -46,6 +46,7 @@ struct Settings { Audio3D a3dModel; bool bMute, bDeaf; bool bTTS; + int iTTSVolume; int iQuality, iComplexity, iMinLoudness, iVoiceHold, iJitterBufferSize; int iFramesPerPacket; bool bTCPCompat; diff --git a/TextToSpeech.h b/TextToSpeech.h index b1bdb5b8f..416fde8e8 100644 --- a/TextToSpeech.h +++ b/TextToSpeech.h @@ -46,6 +46,7 @@ class TextToSpeech : public QObject { public slots: void say(QString text); void setEnabled(bool ena); + void setVolume(int volume); private: TextToSpeechPrivate *d; }; diff --git a/TextToSpeech_win.cpp b/TextToSpeech_win.cpp index c32f7b1e6..028c9bbc4 100644 --- a/TextToSpeech_win.cpp +++ b/TextToSpeech_win.cpp @@ -42,6 +42,7 @@ class TextToSpeechPrivate { TextToSpeechPrivate(); ~TextToSpeechPrivate(); void say(QString text); + void setVolume(int v); }; TextToSpeechPrivate::TextToSpeechPrivate() { @@ -62,6 +63,10 @@ void TextToSpeechPrivate::say(QString text) { pVoice->Speak((const wchar_t *) text.utf16(), SPF_ASYNC, NULL); } +void TextToSpeechPrivate::setVolume(int volume) { + if (pVoice) + pVoice->SetVolume(volume); +} TextToSpeech::TextToSpeech(QObject *p) : QObject(p) { enabled = true; @@ -81,6 +86,10 @@ void TextToSpeech::setEnabled(bool e) { enabled = e; } +void TextToSpeech::setVolume(int volume) { + d->setVolume(volume); +} + bool TextToSpeech::isEnabled() const { return enabled; }