LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-23-2020, 04:18 AM   #16
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133

Quote:
Originally Posted by mackowiakp View Post
Because I want ti listen radio station not available on my territory via FM or DAB. Only via Internet.
Plenty of internet radio apps on Linux http://radiotray.sourceforge.net/
or https://gitlab.com/goodvibes/goodvibes to name but two, find one that does what you want. Good luck
 
Old 08-23-2020, 04:22 AM   #17
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by sgosnell View Post
OK, perhaps the trouble is that I don't understand exactly what you mean by "linux satellite receiver". Is this separate hardware, a computer, or what? I think I'm beyond the limits of my competency here.
I presumed his satellite receiver is connected to the internet and can receive radio stations that stream online, so I've suggested an SDR or probably closer to what he needs is Radio Tray
 
Old 08-25-2020, 06:28 AM   #18
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Finally I got something to work/play. Just look the output from "aplay":

Code:
root@zegmma-p:~# aplay -L | grep :CARD
sysdefault:CARD=HISIAIAO
sysdefault:CARD=Set
front:CARD=Set,DEV=0
surround21:CARD=Set,DEV=0
surround40:CARD=Set,DEV=0
surround41:CARD=Set,DEV=0
surround50:CARD=Set,DEV=0
surround51:CARD=Set,DEV=0
surround71:CARD=Set,DEV=0
iec958:CARD=Set,DEV=0
So the command:

Code:
root@zegmma-p:~# aplay -D sysdefault:Set Music/Pralka.wav 
Playing WAVE 'Music/Pralka.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
The command above can play via USB sound dongle the "Pralka.wav" file, parallel to watching TV and/or even Sat receiver is in standby mode. Of course soundbar is connected to USB dongle via 3,5 mm Jack cable.

But when mpg123 is used, I got an error:

Code:
root@zegmma-p:~# mpg123 -D sysdefault:Set test.mp3      
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
        version 1.25.11; written and copyright by Michael Hipp and others
        free software (LGPL) without any warranty but with best wishes
[../mpg123-1.25.11/src/libout123/modules/pulse.c:107] error: Failed to open pulse audio output: Connection refused
[../mpg123-1.25.11/src/libout123/libout123.c:454] error: Found no driver out of [pulse] working with device <default>.
main: [../mpg123-1.25.11/src/mpg123.c:313] error: out123 error 3: failure loading driver module
So now the problem is. How to play mp3 stream/file without pulseaudio from CLI? Any idea?

[ EDIT]

Maybe using ffmpeg without video output with redirection to USB, transcode in pipe mp3 -> wav?

Last edited by mackowiakp; 08-25-2020 at 07:51 AM.
 
Old 08-25-2020, 04:29 PM   #19
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
Quote:
So now the problem is. How to play mp3 stream/file without pulseaudio from CLI? Any idea?
This is very simple. You can stream PCM output from mpg123 to standard output and pipe it to aplay. From the mpg123 manpage

Code:
 NAME
       mpg123 - play audio MPEG 1.0/2.0/2.5 stream (layers 1, 2 and 3)

SYNOPSIS
       mpg123 [ options ] file-or-URL...

DESCRIPTION
       mpg123  reads  one  or more files (or standard input if ``-'' is specified) or URLs and plays them on the audio device (default) or outputs them to stdout.  file/URL is as‐
       sumed to be an MPEG audio bit stream.
....
      -s, --stdout
              The decoded audio samples are written to standard output, instead of playing them through the audio device.  This option must be used if your audio hardware  is  not
              supported by mpg123.  The output format per default is raw (headerless) linear PCM audio data, 16 bit, stereo, host byte order (you can force mono or 8bit).
You would pipe the mpg123 output to aplay as follows:

Code:
$mpg123 --stdout test.mp3 | aplay -D sysdefault:Set --file-type raw --format=cd
This assumes that mpg123 outputs cd format audio.

Code:
The available format shortcuts are:
              -f cd (16 bit little endian, 44100, stereo) [-f S16_LE -c2 -r44100]
If you don't specify a filename for aplay it will default to reading the standard input from the pipe.

Code:
NAME
       arecord, aplay - command-line sound recorder and player for ALSA soundcard driver

SYNOPSIS
       arecord [flags] [filename]
       aplay [flags] [filename [filename]] ...

DESCRIPTION
       arecord  is  a  command-line  soundfile recorder for the ALSA soundcard driver. It supports several file formats and multiple soundcards with multiple devices. If recording
       with interleaved mode samples the file is automatically split before the 2GB filesize.

       aplay is much the same, only it plays instead of recording. For supported soundfile formats, the sampling rate, bit depth, and so forth can be automatically determined from
       the soundfile header.

       If filename is not specified, the standard output or input is used. The aplay utility accepts multiple filenames.

Last edited by tofino_surfer; 08-25-2020 at 06:05 PM.
 
2 members found this post helpful.
Old 08-26-2020, 05:14 AM   #20
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
OMG! THANK YOU!

As our Finance Minister said, "We were standing on the edge of the abyss, but we took a big step forward".

Now, it is possible play internet stations by using the command (taken from script):

Code:
mpg123 --stdout $url | aplay -D sysdefault:Set --file-type raw --format=cd &
Where $url - URL of the radio internet station stream.

The problem, however, is that mpg123 supports HTTP streams but not HTTPS. And about 20% of stations use HTTPS.
That's why I use the following command to play the station (script fragment):

Code:
*****

[ ! -d /dev/shm ] && mkdir /dev/shm
/bin/rm -f /dev/shm/*
/usr/bin/mkfifo /dev/shm/pipe

******

/usr/bin/curl -Ls $url -o /dev/shm/pipe & mpg123 --stdout /dev/shm/pipe | aplay -D sysdefault:Set --file-type raw --format=cd &

*****
So where is FIFO pipe file used, located in RAM (to eliminate FLASH usage). In this case CURL is responsible for Internet transmission not mpg123 itself. Now it works properly with HTTPS transmitted stations, but not with all HTTP streams.
First command (without CURL) works perfectly with all HTTP based sources.
For example, two URLs that can be inserted in place of the $url variable in both commands.
The first address works fine with CURL but the second one does not. But using the first command, both works properly.

Code:
http://stream.rcs.revma.com/ypqt40u0x1zuv 
http://zet-net-01.cdn.eurozet.pl:8400
FFPROBE does not show any playback-relevant differences between these addresses.

Any idea what to do?

Last edited by mackowiakp; 08-26-2020 at 07:53 AM.
 
Old 08-26-2020, 03:55 PM   #21
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
All you would have to do is use an if else structure to run different commands depending on whether the url has https:// in it or not. You can use grep with the --quiet flag to return an exit code of 0 with a match.

Code:
if echo $url | grep --quiet "https://"; then
    /usr/bin/curl -Ls $url -o /dev/shm/pipe & mpg123 --stdout /dev/shm/pipe | aplay -D sysdefault:Set --file-type raw --format=cd &
else
    mpg123 --stdout $url | aplay -D sysdefault:Set --file-type raw --format=cd &
fi
 
Old 08-27-2020, 03:10 AM   #22
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Yep. I use similar script but with "grep -c" instead "grep --quiet".
So far, I have not found an HTTPS broadcast station that does not work with this script.
But as the connection was made via Bluetooth, all stations were played correctly using CURL. No matter if HTTP or HTTPS.
It's a bit strange. And so for my curiosity. Maybe someone knows what the problem is?
 
  


Reply

Tags
audio, ubuntu, usb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Plug and play means of connecting 3G USB dongle that isn't Network Manager or Sakis3G? howdoI Linux - Networking 2 08-14-2016 08:00 PM
3g dongle connected via ppp daemon unable to send AT commnads to the dongle jarzi Linux - Networking 4 08-07-2015 04:45 AM
[SOLVED] How to play sound directly from input on USB sound card, a Sound Blaster X-Fi THX JunctaJuvant Other *NIX 10 06-14-2014 02:36 AM
how to connect to internet via usb dongle (MPS internet dongle) on Fedora 16 O.S danibhai Linux - Newbie 1 07-30-2012 11:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration