LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Play sound on USB audio dongle (https://www.linuxquestions.org/questions/linux-newbie-8/play-sound-on-usb-audio-dongle-4175680812/)

mackowiakp 08-21-2020 01:57 PM

Play sound on USB audio dongle
 
I would like to stream radio stations from the Internet on the satellite receiver when it is in standby mode and the TV is turned off. This receiver is based on Ubuntu/Debian. The operation of the satellite functions is handled by the Enigma 2 software.
The receiver is built on a 4 core ARMv7 and there is 4.6 GB of free Flash and 0.5 GB of free RAM. CPU usage is also low.
The goal is to stream radio station via plugged USB sound dongle.
USB audio dongle is properly recognized by the system of Sat receiver (type Zgemma H9 Combo):

Code:

root@zegmma-p:/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HISIAIAO [HISI-AIAO], device 0: Playback aiao-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

And:

Code:

root@zegmma-p:/# cat /proc/asound/cards
 0 [HISIAIAO      ]: HISI-AIAO - HISI-AIAO
                      HISI-AIAO
 2 [Set            ]: USB-Audio - C-Media USB Headphone Set
                      C-Media USB Headphone Set at usb-f9880000.ohci-1, full speed

Alsamixer shows controls for this USB card too (correctly).

It very easy to control it such streaming via home automation suite like Domoticz, and thats the way I want to do. It works perfectly on Raspberry Pi.
So my question is. What command and syntax I have to use to playback (using mpg123 for example) to play mp3 file or stream from Internet?

sgosnell 08-21-2020 03:41 PM

What are you using for input to the USB dongle? Is it truly both a sink and source, meaning does it accept input as well as output via headphones? I know nothing about that device, so I need more information to even be sure exactly what you're doing.

mackowiakp 08-22-2020 10:46 AM

1 Attachment(s)
Sorry for too perfunctory description of the situation.

This dongle has audio input (dedicated for microphone) and output dedicated for stereo headphones. Hardware input will not be used in this project. Output will be connected to AUX input of soundbar.
The input for USB dongle audio output should be a stream taken from internet. In other post I wrote about streaming radio station via Bluetooth from Raspberry Pi to soundbar. It works using script like below (part of it):

Code:

******
/usr/bin/bluealsa &
/usr/bin/mkfifo /dev/shm/pipe
*****
/usr/bin/curl -Ls $url -o /dev/shm/pipe > /dev/null 2>&1 & mpg123 -a bluealsa:DEV=30:21:45:12:E2:F8 /dev/shm/pipe >/dev/null 2>&1 &
*****

where $url is a URL of streamed radio station. I use "curl" piped via fifo file to "mpg123" because "mpg123" does not support HTTPS streams. Only HTTP is supported. "bluealsa" is daemon compiled from sources (project taken from GitHub).
But the problem is BT and WiFi interference, because of huge amount of WiFi devices (the sound is distorted very often).
So my decision to use free resources in Linux based Sat receiver and connect soundbar using cable (and audio USB dongle).
As You can see on attached picture, "alsamixer" of Sat receiver shows correctly controls for this USB dongle connected.
So my question is. How to modify the script above to playback stream not via Bluetooth but via this audio dongle to headphone output?

It is strange, however, that there is no "alsa" command/daemon in the FW of the Sat receiver. It is also not in the default repository. But the sound through the HDMI output is of course played by the TV while receiving the Sat signals.

Look, what concerning "alsa" is installed on Sat receiver

Code:

root@zegmma-p:~# opkg list-installed|grep alsa 
alsa-conf - 1.1.9-r0
alsa-state - 0.2.0-r5.6
alsa-states - 0.2.0-r5.6
alsa-utils-alsactl - 1.1.9-r0
alsa-utils-alsamixer - 1.1.9-r0
alsa-utils-aplay - 1.1.9-r0
gstreamer1.0-plugins-base-alsa - 1.17.0.1+git20028+dd556cc-r0
packagegroup-base-alsa - 1.0-r83

and what could be installed.

Code:

root@zegmma-p:~# opkg list|grep alsa         
alsa-conf - 1.1.9-r0 - ALSA sound library
alsa-plugins - 1.1.9-r0 - ALSA Plugins
alsa-plugins-pulseaudio-conf - 1.1.9-r0 - ALSA Plugins
alsa-server - 1.1.9-r0 - ALSA sound library
alsa-state - 0.2.0-r5.6 - Alsa scenario files to enable alsa state restoration
alsa-states - 0.2.0-r5.6 - Alsa scenario files to enable alsa state restoration
alsa-utils - 1.1.9-r0 - ALSA sound utilities
alsa-utils-aconnect - 1.1.9-r0 - ALSA sequencer connection manager
alsa-utils-alsactl - 1.1.9-r0 - Saves/restores ALSA-settings in /etc/asound.state
alsa-utils-alsaloop - 1.1.9-r0 - ALSA PCM loopback utility
alsa-utils-alsamixer - 1.1.9-r0 - ncurses-based control for ALSA mixer and settings
alsa-utils-alsatplg - 1.1.9-r0 - Converts topology text files into binary format for kernel
alsa-utils-alsaucm - 1.1.9-r0 - ALSA Use Case Manager
alsa-utils-amixer - 1.1.9-r0 - Command-line control for ALSA mixer and settings
alsa-utils-aplay - 1.1.9-r0 - Play (and record) sound files using ALSA
alsa-utils-aseqdump - 1.1.9-r0 - Shows the events received at an ALSA sequencer port
alsa-utils-aseqnet - 1.1.9-r0 - Network client/server for ALSA sequencer
alsa-utils-iecset - 1.1.9-r0 - ALSA utility for setting/showing IEC958 (S/PDIF) status bits
alsa-utils-midi - 1.1.9-r0 - Miscellaneous MIDI utilities for ALSA
alsa-utils-speakertest - 1.1.9-r0 - ALSA surround speaker test utility
bluez-alsa - 1.4.0-r0 - Bluetooth Audio ALSA Backend
bluez-alsa-staticdev - 1.4.0-r0 - Bluetooth Audio ALSA Backend - Development files (Static Libraries)
gstreamer1.0-plugins-base-alsa - 1.17.0.1+git20028+dd556cc-r0 - GStreamer plugin for alsa
 GStreamer plugin for alsa
kernel-module-cx231xx-alsa-4.4.35 - 4.4.35-31 - cx231xx-alsa kernel module
 cx231xx-alsa kernel module; Cx231xx Audio driver
kernel-module-em28xx-alsa-4.4.35 - 4.4.35-31 - em28xx-alsa kernel module
 em28xx-alsa kernel module; Empia em28xx device driver - audio interface
kernel-module-tm6000-alsa-4.4.35 - 4.4.35-31 - tm6000-alsa kernel module
 tm6000-alsa kernel module; ALSA driver module for tm5600/tm6000/tm6010
packagegroup-base-alsa - 1.0-r83 - ALSA sound support
pulseaudio-lib-alsa-util - 12.2-r0 - PulseAudio library for alsa-util
 PulseAudio library for alsa-util
pulseaudio-module-alsa-card - 12.2-r0 - PulseAudio module for alsa-card
 PulseAudio module for alsa-card
pulseaudio-module-alsa-sink - 12.2-r0 - PulseAudio module for alsa-sink
 PulseAudio module for alsa-sink
pulseaudio-module-alsa-source - 12.2-r0 - PulseAudio module for alsa-source
 PulseAudio module for alsa-source

I hope that now the problem is presented more clearly.

sgosnell 08-22-2020 11:28 AM

I haven't dealt with alsa directly in a long time. I use pulseaudio, which should make it easy enough to configure the inputs and outputs. You need both pulseaudio and pavucontrol installed. The latter is the volume control applet, in which you configure everything. It should be mostly self-explanatory.

mackowiakp 08-22-2020 11:33 AM

Quote:

The latter is the volume control applet
Yep, but there is any GUI env installed.

GPGAgent 08-22-2020 12:03 PM

3 Attachment(s)
Quote:

Originally Posted by mackowiakp (Post 6158147)
I would like to stream radio stations from the Internet on the satellite receiver when it is in standby mode and the TV is turned off. This receiver is based on Ubuntu/Debian. ......

Why not get an SDR - Software Defined Receiver, something like this:

Nooelec NESDR SMArt v4 SDR - Premium RTL-SDR w/ Aluminum Enclosure, 0.5PPM TCXO, SMA Input. RTL2832U & R820T2-Based Software Defined Radio

Easy to install the s/w on linux, dc-light frequency coverage

All available on Amazon

sgosnell 08-22-2020 12:17 PM

OK, I didn't realize there is no GUI installed. I would have to spend time researching alsa, because I don't remember much about it.

What you have should work. Do you have the headphone jack on the USB dongle connected to the soundbar? Can you hear the radio station through earphones? What inputs does the soundbar have? I'm not familiar with current Raspberry Pi models. Does it have HDMI output?

mackowiakp 08-22-2020 12:28 PM

Quote:

Why not get an SDR - Software Defined Receiver,
Because I want ti listen radio station not available on my territory via FM or DAB. Only via Internet.

mackowiakp 08-22-2020 01:19 PM

Quote:

Do you have the headphone jack on the USB dongle connected to the soundbar?
Yes. The soundbar is connected to USB dongle using this jack.

Quote:

Can you hear the radio station through earphones?
At this moment - no. Because I dont know how to redirect audio stream to USB dongle instead default. But this USB dongle is not connected to RPi but to Linux Sat receiver. I never try this dongle with RPi but it work perfectly with my Mageia 7 desktop PC, using pulseaudio in KDE env.
BTW. The model of RPi I have, has no video chip too (nano version dedicated for control).

Quote:

What inputs does the soundbar have?
AUX/jack (line-in, I want to use), Bluetooth and "copper" Spdif

Quote:

Does it have HDMI output?
RPi - no (as wrote it is nano version). But Linux Sat receiver - of course yes. But it must be reserved for playback sound on TV set during watching TV. Thats why I plugged audio device to USB as device totally independent from Enigma2, that is software responsible for Sat receiving.
Streaming radio stations is something like add-on to Sat receiver, utilizing free flash/RAM/CPU resources.

BTW. As I wrote, At this moment it is possible to playback from RPi via BT to soundbar, but the sound is distorted because of WiFi interference. Because of layout of electronic devices in my house, to connect RPi and soundbar over cable, it should be necessary to use 6-7 m of cable (dangerous and distortion possibility), drill hole in the wall and so on.
But using Sat receiver instead RPi it is needed only 0,5m cable jack-jack.

sgosnell 08-22-2020 01:46 PM

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.

mackowiakp 08-22-2020 02:08 PM

Quote:

I don't understand exactly what you mean by "linux satellite receiver"
This is separated HW box. But it is regular computer based on ARMv7 (4 core), 8 GB Flash, 2 GB RAM with added satellite tuner with build-in HW decoding of x264/265 (up to 4k resolution).
All works under regular Ubuntu/Debian (core version). The difference is that there is busybox instead regular shell set of commands.
For receiving and playback TV channel on TV-set there is installed application named Enigma2 (Open ATV project).
But ones more. You have to look at this unit as regular Ubuntu/Debian computer.

BTW. It is possible to buy Satellite USB dongle, plug to desktop PC or laptop and install Enigma2 and watch Sat channels.

Shadow_7 08-22-2020 02:54 PM

alsa is fine by itself. Most media players let you explicitly state what device to use. You can also use the .asoundrc to override defaults (HW:0,0).

FILE: $HOME/.asoundrc
Code:

defaults.ctl.card 2
defaults.pcm.card 2
defaults.pcm.device 0
defaults.pcm.subdevice 0

$ mpv --ao=alsa --audio-device=alsa/sysdefault:CARD=Generic https://streams.pacifica.org:9000/wbai_128

sgosnell 08-22-2020 03:18 PM

I agree alsa should work. I've just forgotten almost everything I ever knew about it from disuse. And I have little incentive to relearn it. Thanks for the updates. As I said, I'm not going to be much help.

tofino_surfer 08-22-2020 09:29 PM

Quote:

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.
As always Google is your friend. If you simply search for "Zgemma H9 Combo" you get the following page:

http://zgemma.org/zgemma-h9-combo.html

mackowiakp 08-22-2020 11:24 PM

Quote:

You can also use the .asoundrc to override defaults (HW:0,0).
I dont want to change defaults because Enigma2 use it already. I simply want to add second audio card to sink parallel audio stream to it.
What concerning actual configuration look at outputs below:

Code:

root@zegmma-p:~# cat /etc/asound.conf
pcm.!default {
    type plug
    slave.pcm "hw:0"
}

ctl.mixer0 {
    type hw
    card 0
}
root@zegmma-p:~# cat $HOME/.asoundrc
cat: can't open '/home/root/.asoundrc': No such file or directory



All times are GMT -5. The time now is 12:55 AM.