procxx / kepka

Unofficial Telegram Desktop messaging app
https://procxx.github.io
Other
114 stars 29 forks source link

Improve audio playback #66

Open vyamkovyi opened 6 years ago

vyamkovyi commented 6 years ago

So this is going to be something painful but I've done everything I can to prove this issue. If you don't have a good headphones, you're not helpful here. Basically, the issue title says it all: the sound quality is terrible, music is distorted, and, considering that thousands of people are using Telegram mobile client for music and Kepka is going to be cross-compilable, it's not just issue, it's a nightmare of any contributor.

Steps to reproduce

The easy way

Just download any music piece and compare sound that comes out of Telegram with sound from any other software.

The hard way

Here I'm actually going to explain my analysis. I've done it with MP3 for the first time, just for fun, but in this case I'm going to use a song from Monstercat FLAC pack. For obvious reasons, I can't post it fully, but if you have a FLAC record, the song name is Muzzy - Spectrum, and here's SHA512 sum: d2f04f81c8bfd51fb8eb9d6b05cebfce58a3781b648e2324edc02b8341cab2fa40856aa4784463a9b4eb945a420602085110a1664048ad45fd293f866e70cc72 AUDIOCHECKER report:

AUDIOCHECKER v2.0 beta (build 457) - by Dester - opdester@freemail.hu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Path: ...\2017 - [MCEP113] - Muzzy - Spectrum EP

01 -=- 01. Muzzy - Spectrum.flac -=- CDDA (100%)
02 -=- 02. Muzzy - Lost Forever.flac -=- CDDA (100%)
03 -=- 03. Muzzy - Break Away (feat. Priority One).flac -=- CDDA (99%)
04 -=- 04. Muzzy - Outsiders (feat. Charlotte Haining).flac -=- CDDA (100%)

Summary: 99,75% CDDA

105067060

Music is distorted on ANY OS, but following procedure is correct only for Linux.

  1. You need PulseAudio and Audacity. It's also advised to use following configuration for crystal clear sound.
    resample-method = src-sinc-best-quality
    default-sample-format = s24le
  2. Turn off your mic and set monitor of your output device as a default recording device, here's what Google gave me if you're banned
  3. Download any music piece (FLAC advised), load it into Telegram. Launch Audacity. While recording, Audacity should now listen for sounds from PulseAudio output, i.e. sound from your computer. Make sure volume in all software you're gonna test is equal or almost equal.
  4. Record piece by playing it from any music software
  5. Stop recording, mute track so it will not be played while recording next time
  6. Repeat from 4 for all software used, including telegram
  7. Profit. Now you have several tracks that you can analyse in any way you want: visually, mathematically or just by listening to each track and thinking.

The differences in volume and the meaning of "volume" itself for each software piece may differ, so that may harden further analysis. But, assuming differences are negligible, I'm posting my own observations: https://imgur.com/a/Y9JdV I've done my best on sliding and slicing parts to synchronize pieces. On circled parts it's clearly visible that the difference not just in the volume, but in the structure of wave. After all, I don't think this needs much explanation because it goes too deep into music theory. Another interesting point is that it's clearly a software issue since software->software sound transition ended up with distorted sound.

Expected behaviour

Music should be clear just like in any other music software.

Actual behaviour

Probably at some frequencies or some specific wave shape, the timbre of music "shifts" and distorts.

Configuration

Operating system: (Almost) clean Debian 9.3 (Stretch) installation, Linux.

Version of Telegram Desktop: 1.1.23 and 1.2.6

Used theme: not applicable

berkus commented 6 years ago

Is this reproducible on the official Telegram Desktop as well?

vyamkovyi commented 6 years ago

Yes, can be reproduced on any Telegram version actually. Doesn't affects official mobile Telegram client. I'm amazed that nobody reported this to developers before, but I've managed to reproduce this on other machine on Windows. Which is quite confusing, since other users also reported that they actually hear distorted sound on official client. Edit: nobody reported exactly this issue, but here's what I found

berkus commented 6 years ago

It could be result of mixing OpenAL and ffmpeg for playback, but i need to dig the sources more to be sure.

vyamkovyi commented 5 years ago

Fixed in upstream (e3b6e1325e0d8dff9c428f293d468c7c2a1c3329)

foxcpp commented 5 years ago

@Hexawolf ща своруем, вроде тривиально всё