summaryrefslogtreecommitdiff
path: root/soundout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'soundout.cpp')
-rw-r--r--soundout.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/soundout.cpp b/soundout.cpp
index 9e5843e9..944f04e4 100644
--- a/soundout.cpp
+++ b/soundout.cpp
@@ -3,6 +3,7 @@
#include <QDateTime>
#include <QAudioDeviceInfo>
#include <QAudioOutput>
+#include <QSysInfo>
#include <qmath.h>
#include <QDebug>
@@ -53,12 +54,13 @@ void SoundOutput::setFormat (QAudioDeviceInfo const& device, unsigned channels,
m_msBuffered = msBuffered;
QAudioFormat format (device.preferredFormat ());
-
+// qDebug () << "Preferred audio output format:" << format;
format.setChannelCount (channels);
format.setCodec ("audio/pcm");
format.setSampleRate (48000);
format.setSampleType (QAudioFormat::SignedInt);
format.setSampleSize (16);
+ format.setByteOrder (QAudioFormat::Endian (QSysInfo::ByteOrder));
if (!format.isValid ())
{
Q_EMIT error (tr ("Requested output audio format is not valid."));
@@ -67,6 +69,7 @@ void SoundOutput::setFormat (QAudioDeviceInfo const& device, unsigned channels,
{
Q_EMIT error (tr ("Requested output audio format is not supported on device."));
}
+// qDebug () << "Selected audio output format:" << format;
m_stream.reset (new QAudioOutput (device, format));
audioError ();
@@ -140,13 +143,13 @@ void SoundOutput::stop ()
qreal SoundOutput::attenuation () const
{
- return -(10. * qLn (m_volume) / qLn (10.));
+ return -(20. * qLn (m_volume) / qLn (10.));
}
void SoundOutput::setAttenuation (qreal a)
{
Q_ASSERT (0. <= a && a <= 999.);
- m_volume = qPow (10., -a / 10.);
+ m_volume = qPow(10.0, -a/20.0);
// qDebug () << "SoundOut: attn = " << a << ", vol = " << m_volume;
if (m_stream)
{