summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibAudio
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-08-03 20:06:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-06 23:50:10 +0200
commit91c9d9ee8886da58372c4dc8df958e7f26d2ed05 (patch)
tree4301b897513ee5f7e0919e5cc9ba7fd8298ae46d /Userland/Libraries/LibAudio
parent837803531a3fa0cf53cea46be402533e14dc1df7 (diff)
downloadserenity-91c9d9ee8886da58372c4dc8df958e7f26d2ed05.zip
LibAudio: Make playing lossy flacs more truthful
Playing a lossy flac file resulted in hearing something you'd not like to play. Instead of your lovely bass, you had sounds as if you put a CD-ROM disc to a CD player. It turned out that the size for making signed values was too big, making all the values unsigned. I've used lossyWav[1] (the posix port[2] to be exact) to generate such files. [1]: https://wiki.hydrogenaud.io/index.php?title=LossyWAV [2]: https://github.com/MoSal/lossywav-for-posix
Diffstat (limited to 'Userland/Libraries/LibAudio')
-rw-r--r--Userland/Libraries/LibAudio/FlacLoader.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp
index b79c9fa8f8..44f8671f01 100644
--- a/Userland/Libraries/LibAudio/FlacLoader.cpp
+++ b/Userland/Libraries/LibAudio/FlacLoader.cpp
@@ -596,7 +596,7 @@ Vector<i32> FlacLoaderPlugin::parse_subframe(FlacSubframeHeader& subframe_header
samples.ensure_capacity(m_current_frame->sample_count);
for (u32 i = 0; i < m_current_frame->sample_count; ++i) {
- samples.unchecked_append(sign_extend(constant_value, subframe_header.bits_per_sample));
+ samples.unchecked_append(sign_extend(constant_value, subframe_header.bits_per_sample - subframe_header.wasted_bits_per_sample));
}
break;
}
@@ -645,8 +645,7 @@ Vector<i32> FlacLoaderPlugin::decode_custom_lpc(FlacSubframeHeader& subframe, In
// warm-up samples
for (auto i = 0; i < subframe.order; ++i) {
- decoded.unchecked_append(sign_extend(bit_input.read_bits_big_endian(subframe.bits_per_sample - subframe.wasted_bits_per_sample), subframe.bits_per_sample));
- decoded[i] <<= subframe.wasted_bits_per_sample;
+ decoded.unchecked_append(sign_extend(bit_input.read_bits_big_endian(subframe.bits_per_sample - subframe.wasted_bits_per_sample), subframe.bits_per_sample - subframe.wasted_bits_per_sample));
}
// precision of the coefficients
@@ -695,7 +694,7 @@ Vector<i32> FlacLoaderPlugin::decode_fixed_lpc(FlacSubframeHeader& subframe, Inp
// warm-up samples
for (auto i = 0; i < subframe.order; ++i) {
- decoded.unchecked_append(sign_extend(bit_input.read_bits_big_endian(subframe.bits_per_sample - subframe.wasted_bits_per_sample), subframe.bits_per_sample));
+ decoded.unchecked_append(sign_extend(bit_input.read_bits_big_endian(subframe.bits_per_sample - subframe.wasted_bits_per_sample), subframe.bits_per_sample - subframe.wasted_bits_per_sample));
}
decode_residual(decoded, subframe, bit_input);