diff --git a/audio/ToxEndCall.pcm b/audio/ToxEndCall.pcm
deleted file mode 100644
index 02757afbc..000000000
Binary files a/audio/ToxEndCall.pcm and /dev/null differ
diff --git a/audio/ToxEndCall.s16le.pcm b/audio/ToxEndCall.s16le.pcm
new file mode 100644
index 000000000..6a3c63d65
Binary files /dev/null and b/audio/ToxEndCall.s16le.pcm differ
diff --git a/audio/ToxIncomingCall.pcm b/audio/ToxIncomingCall.pcm
deleted file mode 100644
index 8239c74cf..000000000
Binary files a/audio/ToxIncomingCall.pcm and /dev/null differ
diff --git a/audio/ToxIncomingCall.s16le.pcm b/audio/ToxIncomingCall.s16le.pcm
new file mode 100644
index 000000000..b7bb2dde0
Binary files /dev/null and b/audio/ToxIncomingCall.s16le.pcm differ
diff --git a/audio/ToxOutgoingCall.pcm b/audio/ToxOutgoingCall.pcm
deleted file mode 100644
index 64aba4245..000000000
Binary files a/audio/ToxOutgoingCall.pcm and /dev/null differ
diff --git a/audio/ToxOutgoingCall.s16le.pcm b/audio/ToxOutgoingCall.s16le.pcm
new file mode 100644
index 000000000..8daf6a3f9
Binary files /dev/null and b/audio/ToxOutgoingCall.s16le.pcm differ
diff --git a/audio/format.md b/audio/format.md
new file mode 100644
index 000000000..be8544ad1
--- /dev/null
+++ b/audio/format.md
@@ -0,0 +1,17 @@
+To keep sounds consistent a sound file should follow the parameters listed
+below.
+
+# Format
+
+Internally qTox needs PCM with signed 16Bit integers and a samplerate of
+48kHz and one channel (mono).
+
+You can use ffmpeg to create those files as follows:
+```
+ffmpeg -i notification.wav -f s16le -acodec pcm_s16le -ac 1 -ar 48000 notification.s16le.pcm
+```
+
+# Normalization
+
+All sound files should have their maximum at -1.0 dB.
+To normalize them correctly you can use Audacity with the "Normalize" plugin.
diff --git a/audio/notification.pcm b/audio/notification.pcm
deleted file mode 100644
index d57ac783d..000000000
Binary files a/audio/notification.pcm and /dev/null differ
diff --git a/audio/notification.s16le.pcm b/audio/notification.s16le.pcm
new file mode 100644
index 000000000..210c646a3
Binary files /dev/null and b/audio/notification.s16le.pcm differ
diff --git a/audio/original/ToxEndCall.wav b/audio/original/ToxEndCall.wav
new file mode 100644
index 000000000..13ce1d946
Binary files /dev/null and b/audio/original/ToxEndCall.wav differ
diff --git a/audio/original/ToxIncomingCall.wav b/audio/original/ToxIncomingCall.wav
new file mode 100644
index 000000000..486e3fa3f
Binary files /dev/null and b/audio/original/ToxIncomingCall.wav differ
diff --git a/audio/original/ToxOutgoingCall.wav b/audio/original/ToxOutgoingCall.wav
new file mode 100644
index 000000000..d6b1bc2be
Binary files /dev/null and b/audio/original/ToxOutgoingCall.wav differ
diff --git a/audio/original/notification.wav b/audio/original/notification.wav
new file mode 100644
index 000000000..f5e6a52fb
Binary files /dev/null and b/audio/original/notification.wav differ
diff --git a/res.qrc b/res.qrc
index 4e53a84a7..83e8b99af 100644
--- a/res.qrc
+++ b/res.qrc
@@ -6,10 +6,10 @@
res/font/DejaVuSans.ttf
- audio/notification.pcm
- audio/ToxIncomingCall.pcm
- audio/ToxOutgoingCall.pcm
- audio/ToxEndCall.pcm
+ audio/notification.s16le.pcm
+ audio/ToxIncomingCall.s16le.pcm
+ audio/ToxOutgoingCall.s16le.pcm
+ audio/ToxEndCall.s16le.pcm
img/add.svg
img/avatar_mask.svg
img/contact.svg
diff --git a/src/audio/audio.h b/src/audio/audio.h
index c004f69ac..a1b454a29 100644
--- a/src/audio/audio.h
+++ b/src/audio/audio.h
@@ -48,15 +48,15 @@ public:
{
switch (s) {
case Sound::Test:
- return QStringLiteral(":/audio/notification.pcm");
+ return QStringLiteral(":/audio/notification.s16le.pcm");
case Sound::NewMessage:
- return QStringLiteral(":/audio/notification.pcm");
+ return QStringLiteral(":/audio/notification.s16le.pcm");
case Sound::IncomingCall:
- return QStringLiteral(":/audio/ToxIncomingCall.pcm");
+ return QStringLiteral(":/audio/ToxIncomingCall.s16le.pcm");
case Sound::OutgoingCall:
- return QStringLiteral(":/audio/ToxOutgoingCall.pcm");
+ return QStringLiteral(":/audio/ToxOutgoingCall.s16le.pcm");
case Sound::CallEnd:
- return QStringLiteral(":/audio/ToxEndCall.pcm");
+ return QStringLiteral(":/audio/ToxEndCall.s16le.pcm");
}
assert(false);
return QString();
@@ -109,6 +109,7 @@ public:
protected:
// Public default audio settings
+ // Samplerate for Tox calls and sounds
static constexpr uint32_t AUDIO_SAMPLE_RATE = 48000;
static constexpr uint32_t AUDIO_FRAME_DURATION = 20;
static constexpr uint32_t AUDIO_FRAME_SAMPLE_COUNT_PER_CHANNEL =
diff --git a/src/audio/backend/openal.cpp b/src/audio/backend/openal.cpp
index 56c86fd1e..8041a086a 100644
--- a/src/audio/backend/openal.cpp
+++ b/src/audio/backend/openal.cpp
@@ -377,7 +377,7 @@ bool OpenAL::initOutput(const QString& deviceName)
}
/**
- * @brief Play a 44100Hz mono 16bit PCM sound from a file
+ * @brief Play a 48kHz mono 16bit PCM sound from a file
*
* @param[in] path the path to the sound file
*/
@@ -389,7 +389,7 @@ void OpenAL::playMono16Sound(const QString& path)
}
/**
- * @brief Play a 44100Hz mono 16bit PCM sound
+ * @brief Play a 48kHz mono 16bit PCM sound
*/
void OpenAL::playMono16Sound(const QByteArray& data)
{
@@ -408,11 +408,11 @@ void OpenAL::playMono16Sound(const QByteArray& data)
alSourcei(alMainSource, AL_BUFFER, AL_NONE);
}
- alBufferData(alMainBuffer, AL_FORMAT_MONO16, data.constData(), data.size(), 44100);
+ alBufferData(alMainBuffer, AL_FORMAT_MONO16, data.constData(), data.size(), AUDIO_SAMPLE_RATE);
alSourcei(alMainSource, AL_BUFFER, static_cast(alMainBuffer));
alSourcePlay(alMainSource);
- int durationMs = data.size() * 1000 / 2 / 44100;
+ int durationMs = data.size() * 1000 / 2 / AUDIO_SAMPLE_RATE;
QMetaObject::invokeMethod(&playMono16Timer, "start", Q_ARG(int, durationMs + 50));
}