Very noisy and distorted sound output on Lenovo W520 laptop powered by Debian Jessie
At the same time, file conversion (zxtune123 --convert mode=psg,filename=out.psg stracker.stc) works fine, and the resulting out.psg could be properly played by ayfly. So, the problem seems to be in sound system backend configuration, and it appeared a long time ago (first noticed in b2635 release).
Built the utility as follows:
make -j 4 system.zlib=1 platform=linux -C apps/zxtune123
The official prebuilt Ubuntu amd64 binary has the same issue.
Comments (22)
-
-
reporter Yes, out.wav sounds as expected.
Although I have PulseAudio sound server working, I assume ALSA is used by zxtune123. And I almost sure that I had no PulseAudio installed when I first noticed the problem in b2635 release.
One more observation: the sound is not just noisy and distorted, it is two times slower, (which is probably the main source of distortion). One second displayed by zxtune123 console timer actually takes two real seconds.
-
Please, try playback through different subsystems (if exists):
oss: zxtune123 --oss device=/dev/dsp stracker.stc
alsa: zxtune123 --alsa device=default stracker.stc
sdl (requires support_sdl=1 option while build): zxtune123 --sdl "" stracker.stc
-
reporter Okay, ALSA works fine. Thank you! This is OSS backend which is "broken". Note however, that "aylet" works properly via OSS on the same laptop. So, the problem is still in zxtune123.
Why not make ALSA the default backend? OSS has been in deprecated state for a long long time. I only have "oss-compat" package installed to make "aylet" work since it does not support ALSA.
Another suggestion is to give "--oss device=/dev/dsp" and "--alsa device=default" examples in --help output of zxtune123, or even better allow just --oss and --alsa to mean these defaults. (I would have tried ALSA earlier if I knew what to specify after --alsa.)
-
reporter - marked as major
-
To make alsa checked first, add to ~/.zxtune/zxtune.conf the next line:
zxtune.sound.backends.order=alsa,oss
this will change checking order.
OSS is more universal, I think. At least for some older distributions. For the new distros, it fill fail check and ALSA will be used instead (if posible, of course).
Almost all available options with their default values can be listed via zxtune123 --list-options. Also some information can be found in zxtune123_en.txt distributed with app. Adding such a specific info to --help option is not a good way since it's not actual for windows users for example.
-
Please, check out patch:
diff --git a/src/sound/backends/oss_backend.cpp b/src/sound/backends/oss_backend.cpp index e84a92e..4afa99d 100644 --- a/src/sound/backends/oss_backend.cpp +++ b/src/sound/backends/oss_backend.cpp @@ -170,11 +170,11 @@ namespace Oss private: static int GetSoundFormat(bool isSigned) { - switch (sizeof(Sample)) + switch (Sample::BITS) { - case 1: + case 8: return isSigned ? AFMT_S8 : AFMT_U8; - case 2: + case 16: return isSigned ? (isLE() ? AFMT_S16_LE : AFMT_S16_BE) : (isLE() ? AFMT_U16_LE : AFMT_U16_BE);
-
reporter Thanks! The patch solves the OSS playback issue.
Please, also pay attention that "--oss" or "--alsa" alone do not work, without additional parameter, (zxtune123 quits with 'Invalid parameter format' error), despite the --help text suggestion that the parameters should be optional, and --list-options showing correct defaults for them. (But "--oss =" and "--alsa =" seem to work.)
As for ALSA fallback when OSS is tried first, it does not work for me this way. When OSS is not available, I get the following error, and zxtune123 quits without trying ALSA next:
#! Failed to initialize playback. @b3,d60,e64 -------- Error in OSS backend while working with device '/dev/mixer': No such file or directory. @69,200,199 --------
-
Yes, parameter string after backend specifying is required (even empty string). I should fix help description. What is your full cmdline for the last case? Pay attention, if you'll specify any backend via cmdline, no other backends will be used as fallback. To check default order of backends trying, use --list-backends option.
-
reporter $ bin/linux/release/zxtune123 --list-backends Backend: oss Description: OSS sound system backend Capabilities: type_system feat_hwvolume Status: Available Backend: alsa Description: ALSA sound system backend Capabilities: type_system feat_hwvolume Status: Available [...] $ bin/linux/release/zxtune123 samples/chiptunes/AY-3-8910/stc/stracker.stc Failed to initialize playback. @b3,d60,e64 -------- Error in OSS backend while working with device '/dev/mixer': No such file or directory. @69,200,199 -------- $ bin/linux/release/zxtune123 --alsa = samples/chiptunes/AY-3-8910/stc/stracker.stc Playing: samples/chiptunes/AY-3-8910/stc/stracker.stc Type: STC Container: Program: SONG BY ST COMPILE Title: Author: Time: 2:33.30 Channels: 3 [...]
-
Please check out latest changes in develop branch. Applied sample size patch and OSS devices checking.
-
reporter It now automatically tries and uses ALSA when no OSS is available but still shows the following error at the beginning:
#! Failed to create backend 'oss'. @a6,428,4ee -------- Error in OSS backend while working with device '/dev/mixer': No such file or directory. @69,200,1e2 --------
Other than this error message, works as expected.
-
That's ok - it's just a diagnostic message. zxtune123 is developer tool rather than end-user.
-
Is there any problems with ALSA playback via PulseAudio compat layer?
-
reporter It works fine with integrated laptop audio but does not work with USB audio dongle ("Sound Blaster Play!"). At the same time "mocp" music player works fine with both. The symptoms may be different, depending on whether zxtune123 is started before or after plugging in the USB audio, (pavucontrol is used to switch audio outputs in real time), and whether mocp has been used before or not. The symptoms include complete silence, very fast playback, or missing left channel.
Update: missing left channel was actually caused by volume control - it was a little lower than the right one. And mocp seems to also have the issue with very fast playback when it is started after plugging-in the USB-audio which was previously auto-saved somehow as default sound output for mocp.
-
reporter So, to be clear, I consider the originally reported issue properly resolved, (thanks!), and I'm not quite interested in investing time into proper USB-audio support since this is not my primary configuration. But if you still want to fix playback via USB-audio I can provide some help with verification of the fixes.
-
It would be nice! I have finished support of PulseAudio (not in repo yet) and met some strange bug while playing using ALSA via PulseAudio compat layer (that was the reason of my question above). So, when I will fix that bug, the only thing you should do it's test.
-
Seems like fixed for me. Please check out.
-
reporter It's almost perfect now :)
The only minor issue is when OSS is busy, zxtune123 does not fall back to the next available backend but rather exits with the following error:
#! Failed to initialize playback. @b3,d60,e64 -------- Error in OSS backend while working with device '/dev/dsp': Device or resource busy. @69,200,1a0 --------
-
I'll fix that:) Does Alsa and PulseAudio work well?
zxtune123 --alsa = stracker.stc
zxtune123 --paudio = stracker.stc
P.S. Backend parameters are really optional, but in case of 'zxtune123 --alsa stracker.stc' input filename is treated as parameter. The alternative for above calls is 'zxtune123 --alsa --file stracker.stc'
-
reporter Yes, both --alsa and --paudio work perfectly with both integrated and USB audio.
-
- changed status to closed
Excellent! In case of sound problems in alsa, try to increase latency (100ms default). E.g. 'zxtune123 --alsa latency=200 ...' P.S. Thank you for help!
- Log in to comment
Two questions: 1) what about result of zxtune123 --wav filename=out.wav stracker.stc ? Is it sounds (out.wav) ok? 2) what sound backend is used? oss or alsa?