My latest project is to provide a simple MP3 player to play sound effects at our local Model Town. It is running Raspbian Lite on a Pi Zero with a USB Audio Adaptor to hear the sound, but I've also tested this problem with the full Raspbian installation through the analogue jack socket. Both installations use the latest, fully updated version of Stretch.
My code invokes mpg321 from Python to play two MP3 files. However, the sound is awful! There is a persistent background clicking noise which is almost a loud as the sound we want. The annoying thing is that I used almost identical code in an earlier project (c2017) to play bells, chimes and church music and that did not have this problem and is working still.
To try to get to the bottom of this, I've copied an audio file to an SD Card containing full Raspbian and invoked the playback from the command line. Here is what it looks like:
Code: Select all
pi@raspberrypi:~ $ mpg321 01-Giacomo_Puccini-Madama_Butterfly-Un_bel_dì_vedremo.mp3 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2, and 3. Version 0.3.2-1 (2012/03/25). Written and copyrights by Joe Drew, now maintained by Nanakos Chrysostomos and others. Uses code from various people. See 'README' for more! THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! Title : Madama Butterfly: Un bel d� ve Artist : Giacomo Puccini Album : The Best of � Romantic Callas Year : 2001 Comment : Genre : Unknown Playing MPEG stream from 01-Giacomo_Puccini-Madama_Butterfly-Un_bel_dì_vedremo.mp3 ... MPEG 1.0 layer III, 48 kbit/s, 44100 Hz mono
I had read somewhere that someone had solved an audio problem using mplayer instead of mpg321, so I installed it. This works, here is what I get:
Code: Select all
pi@raspberrypi:~ $ mplayer 01-Giacomo_Puccini-Madama_Butterfly-Un_bel_dì_vedremo.mp3 MPlayer 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team do_connect: could not connect to socket connect: No such file or directory Failed to open LIRC support. You will not be able to use your remote control. Playing 01-Giacomo_Puccini-Madama_Butterfly-Un_bel_dì_vedremo.mp3. libavformat version 57.56.101 (external) Mismatching header version 57.56.100 Audio only file format detected. Load subtitles in ./ ========================================================================== Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III AUDIO: 44100 Hz, 2 ch, s16le, 160.0 kbit/11.34% (ratio: 20000->176400) Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III) ========================================================================== AO: [pulse] Init failed: Connection refused Failed to initialize audio driver 'pulse' AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample) Video: no video Starting playback... A: 284.2 (04:44.1) of 283.0 (04:43.0) 1.6% Exiting... (End of file)
Can anyone shed any light on what's going on?
BTW. I posted this here instead of in the Audio Topics area because the only difference I can see between the system that I completed in 2017 and this one is the version of Raspbian.