Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: 192Khz Lossless Audio LAN streaming (Read 34948 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

192Khz Lossless Audio LAN streaming

Reply #26
Hi,

I have a problem with the playout. There is some resampling going on.
Once I play file from windows (to the same sound card) and look at the oscilloscope
everything looks fine. Once I play it from Ubuntu, It looks like it has been resampled to 48Khz.
I do not understand linux audio layers and everything looks overcomplicated to me.
I would ask you phofman once again, to help me.
Maybe telling me which distro you are using, would simplify my life, off course by following your instructions.
Basically I am stuck now.
I found some Jplay for windows, and managed to send 192Khz with foobar2000 capturing from live source and sending to asio jplay driver.
However, I did not had nice readings and I would have to do further testing.
I see that sox is a salvation for me but now alsa or pulseaudio.... I simply don't know.
···---···


Cheers!

192Khz Lossless Audio LAN streaming

Reply #27
PulseAudio?
See /etc/pulse/daemon.conf options default-sample-format and default-sample-rate.
"I hear it when I see it."

192Khz Lossless Audio LAN streaming

Reply #28
How did you determine your playback part was resampling? The current stream parameters entering your soundcard are listed in the virtual interface to your drivers in /proc. For device 0.0.0 that would be

Code: [Select]
cat /proc/asound/card0/pcm0p/sub0/hw_params


The alsa device specifed in sox "plughw:0" resamples only if your soundcard cannot natively play the requested samplerate. No pulseaudio is involved. PA would open (acquire) the soundcard, making it unavailable to sox. As a result sox would throw the "device busy" error message you have already encountered.

Linux audio is no black box, you just need to learn how it works. Unlike proprietary solutions which only their authors know what they actually do.

 

192Khz Lossless Audio LAN streaming

Reply #29
The current stream parameters entering your soundcard are listed in the virtual interface to your drivers in /proc.

Handy script (adevices.sh) that lists ALSA devices, what programs are using them, and with what parameters:

Code: [Select]
#!/bin/bash

if [ "$1" = '-h' -o "$1" = '--help' ]; then
me="${0##*/}"
echo "$me: list ALSA devices and relevant information."
exit 0
fi

if [ -e '/proc/asound/version' ]; then
cat '/proc/asound/version'
echo
fi

for (( i=0; i<100; i++ )); do
if [ -d "/proc/asound/card${i}" ]; then
cname="$( cat "/proc/asound/card${i}/id" )"
echo "Card ${i} (${cname}):"

for t in 'p' 'c'; do
case "$t" in
p) typeString='Playback' ;;
c) typeString='Recording' ;;
esac

for (( j=0; j<100; j++ )); do
if [ -d "/proc/asound/card${i}/pcm${j}${t}" ]; then
dname=''
if [ -e "/proc/asound/card${i}/pcm${j}${t}/info" ]; then
dname="$( grep -E '^name: ' "/proc/asound/card${i}/pcm${j}${t}/info" 2>/dev/null | cut -d ' ' -f 2- )"
fi
echo
if [ -n "$dname" ]; then
echo "  * ${typeString} Device ${j} (${dname}):"
else
echo "  * ${typeString} Device ${j}:"
fi
ownerPID="$( grep -E '^owner_pid' "/proc/asound/card${i}/pcm${j}${t}/sub0/status" 2>/dev/null | tr -cd '0-9' )"
if [ -n "$ownerPID" ]; then
tgid="$( grep -F 'Tgid:' "/proc/${ownerPID}/status" 2>/dev/null | tr -cd '0-9' )"
if [ -n "$tgid" ]; then
ownerPID="$tgid"
fi
ownerName="$( cat "/proc/${ownerPID}/comm" 2>/dev/null )"
echo "    used by: ${ownerName} (PID ${ownerPID})"
fi
while read line; do
echo "    $line"
done < "/proc/asound/card${i}/pcm${j}${t}/sub0/hw_params"
fi
done
done
echo
fi
done

Sample output:

Code: [Select]
Advanced Linux Sound Architecture Driver Version k3.11.6-1-ARCH.

Card 0 (PCH):

  * Playback Device 0 (ALC663 Analog):
    used by: chromium (PID 6819)
    access: MMAP_INTERLEAVED
    format: S32_LE
    subformat: STD
    channels: 2
    rate: 44100 (44100/1)
    period_size: 5513
    buffer_size: 16539

  * Playback Device 1 (ALC663 Digital):
    closed

  * Recording Device 0 (ALC663 Analog):
    closed

Card 1 (USB):

  * Playback Device 0 (USB Audio):
    used by: jackd (PID 609)
    access: MMAP_INTERLEAVED
    format: S24_3LE
    subformat: STD
    channels: 2
    rate: 44100 (44100/1)
    period_size: 512
    buffer_size: 1536

  * Recording Device 0 (USB Audio):
    closed

192Khz Lossless Audio LAN streaming

Reply #30
Very nice script, thanks!

192Khz Lossless Audio LAN streaming

Reply #31
Wasn't reading hardware info from the process filesystem deprecated like 10 years ago in favor of sysfs?
"I hear it when I see it."

192Khz Lossless Audio LAN streaming

Reply #32
xnor, I can't find the same /proc/asound information in /sys. If I'm missing something, can you point me in the right direction?

192Khz Lossless Audio LAN streaming

Reply #33
Wasn't reading hardware info from the process filesystem deprecated like 10 years ago in favor of sysfs?


Alsa drivers (even new ones) keep generating information into proc. Perhaps outdated but works very well. I understand why alsa devs would not migrate (too much other more important work to do :-) )

192Khz Lossless Audio LAN streaming

Reply #34
PulseAudio?
See /etc/pulse/daemon.conf options default-sample-format and default-sample-rate.


Code: [Select]
resample-method = speex-float-1
; default-sample-format = s16le
; default-sample-rate = 192000
; alternate-sample-rate = 192000
; default-sample-channels = 2
; default-channel-map = front-left,front-right

192Khz Lossless Audio LAN streaming

Reply #35
skamp here is the output:

Advanced Linux Sound Architecture Driver Version k3.11.0-12-generic.

Card 0 (AudioPCI):

* Playback Device 0 (ES1371 DAC2/ADC):
used by: alsa-sink-ES137 (PID 1377)
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (1572864000/32768)
period_size: 441
buffer_size: 3528

* Playback Device 1 (ES1371 DAC1):
closed

* Recording Device 0 (ES1371 DAC2/ADC):
closed

192Khz Lossless Audio LAN streaming

Reply #36
How did you determine your playback part was resampling? The current stream parameters entering your soundcard are listed in the virtual interface to your drivers in /proc. For device 0.0.0 that would be

Code: [Select]
cat /proc/asound/card0/pcm0p/sub0/hw_params


The alsa device specifed in sox "plughw:0" resamples only if your soundcard cannot natively play the requested samplerate. No pulseaudio is involved. PA would open (acquire) the soundcard, making it unavailable to sox. As a result sox would throw the "device busy" error message you have already encountered.

Linux audio is no black box, you just need to learn how it works. Unlike proprietary solutions which only their authors know what they actually do.


content is:

access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (1572864000/32768)
period_size: 441
buffer_size: 3528

Regards.

192Khz Lossless Audio LAN streaming

Reply #37
logicom, obviously you're supposed to run that script while playing something, i.e. while your soundcard is being used. It appears that your soundcard is set to 16 bit, 48kHz, stereo.

192Khz Lossless Audio LAN streaming

Reply #38
logicom, obviously you're supposed to run that script while playing something, i.e. while your soundcard is being used. It appears that your soundcard is set to 16 bit, 48kHz, stereo.

sorry I just modified the post, please look at it.

Kind Regards.

192Khz Lossless Audio LAN streaming

Reply #39
That doesn't look like the Asus Xonar D1. It looks more like the Ensoniq Audio PCI, which is very old, and only supports 48 kHz. Did you run the script on the same PC where your Xonar sound card is installed?

192Khz Lossless Audio LAN streaming

Reply #40
That doesn't look like the Asus Xonar D1. It looks more like the Ensoniq Audio PCI, which is very old, and only supports 48 kHz. Did you run the script on the same PC where your Xonar sound card is installed?


No, it is not, you are right. I will post output from xonar latter,since I am working under VMware at the moment.

192Khz Lossless Audio LAN streaming

Reply #41
Here is output from real host with xonar D1:

Code: [Select]
Advanced Linux Sound Architecture Driver Version k3.11.0-12-generic.

Card 0 (D1):

* Playback Device 0 (Multichannel):
used by: alsa-sink-Multi (PID 3615)
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 88200
buffer_size: 88200

* Playback Device 1 (Digital):
closed

* Recording Device 0 (Multichannel):
closed

* Recording Device 1 (Digital):
closed


same issue...

192Khz Lossless Audio LAN streaming

Reply #42
Your device is taken by pulseaudio. You have to stop pulseaudio first. The sox playback command does not use pulseaudio, you must be getting the "device busy" error.

Or pick your internal soundcard as pulseaudio default, perhaps it will release your xonar.

192Khz Lossless Audio LAN streaming

Reply #43
In order to force 16/192 playback on your Xonar, I suggest putting this in /etc/asound.conf (create the file if it doesn't exist already):

Code: [Select]
defaults.pcm.rate_converter "samplerate_best"
#defaults.pcm.rate_converter "samplerate_medium"
#defaults.pcm.rate_converter "samplerate"

pcm.!default "plugXonar"
ctl.!default "plugXonar"

pcm.xonar {
    type hw
    card D1
    device 0
    format S16_LE
    rate 192000
}

ctl.xonar {
    type hw
    card D1
}

pcm.plugXonar { type plug; slave.pcm "xonar"; }
ctl.plugXonar { type hw; card D1; }


Then restart your audio apps (reboot if necessary), and set your apps to use either the 'xonar', 'plugXonar' or 'default' ALSA device, in that order, whichever works.

192Khz Lossless Audio LAN streaming

Reply #44
I do not think that will help. Logicom's sox uses plughw:xx directly. PA uses hw:xx directly as it must communicate with the lowest buffer directly. Notice the equal buffer and period sizes. Only PA timed by HPETs can afford such setup, any other alsa application timed by soundcard interrupts needs at least two periods per buffer for proper operation.

The device is opened by PA, the only way forward is to release the device first and keep PA claws away from it. Every general desktop linux distribution user will encounter this situation as PA is a desktop standard.

https://www.google.com/search?client=ubuntu...io&start=10

http://installion.co.uk/ubuntu/saucy/main/.../uninstall.html

192Khz Lossless Audio LAN streaming

Reply #45
I do not think that will help. Logicom's sox uses plughw:xx directly.


It does force the bit depth and sampling rate. "plughw" alone doesn't say what parameters ALSA should use when opening the device. Without any specific instructions regarding the format, ALSA ends up using the default 48 kHz.

With that configuration, ALSA will return an error when a program tries to use the "xonar" device with anything other that 16/192 PCM; and any program that uses "plugXonar" or the default device will have its output resampled to 16/192 if it's anything different.

192Khz Lossless Audio LAN streaming

Reply #46
It is the playback application which controls (asks for, to be correct) hwparams (i.e. rate and bitdepth, among others).

hw:X: no other but hwparams directly supported by the soundcard will be accepted . For xonar these are http://git.kernel.org/cgit/linux/kernel/gi...xygen_pcm.c#n44 .

plughw:X any hw params will be accepted and the smallest minimum conversion to fit the closest card parameters will be applied.

In logicom's case it is the parameters of incoming flac stream to sox which define the samplerate and bit depth sox will ask the plughw:xonar to accept (sox always uses the incoming file params for output file params, unless specified otherwise). If we specified the  the -b32 parameter in sox output stream, we could avoid the plug plugin as xonar accepts S16_LE and S32_LE. But the samplerate will not be changed.

48kHz are default dmix values, IIRC. It is a different alsa device than logicom is using.  Of course you can create a device which forces only a single samplerate/bitwidth etc. but there is no need for such setup here. Sox alone with plug plugin will pick the right samplerate/bitdepth needed.

Also, PA uses hw:X directly, avoiding any alsa setup in .asoundrc.

192Khz Lossless Audio LAN streaming

Reply #47
Hi,

I completely removed pulseaudio, (I did that before as per suggestion by phofman on real host with xonar D1) and this is where I am. Playout is bad.
But before I go to shopping for a new card, or switching to debian, fedora/redhat and putting server OS,
maybe someone could help me with this,
hda
Code: [Select]
https://lkml.org/lkml/2013/1/8/549


It would be nice to experiment in virtual environment. Yet I would be able connect to the audio pin with  software and measure signal characteristics...  but I don't know... and knowledge is the power. I am not a jedy yet...

I will try once again all of your suggestions. In a mean time...
Thank you!

P.S. Just to mention that bitperfect transport with jplay works up to 384Khz. I play from wavelab. In addition with HIFI CABLE & ASIO BRIDGE it seems like something close to what I am looking for minus FLAC compression, anyway it is good for comparisons.

192Khz Lossless Audio LAN streaming

Reply #48
May i ask what is wrong with using UPNP for your uses? Apart from a lack of compression (passing a wav file instead) it seems like an easy way to manage what you are after, foobar2000 + upnp output plugin -> any renderer set to directly play to your hardware. gmediarender-ressurect does a great job of this.

Or am i missing something entirely?

192Khz Lossless Audio LAN streaming

Reply #49
I completely removed pulseaudio, (I did that before as per suggestion by phofman on real host with xonar D1) and this is where I am. Playout is bad.


What specifically do you call "bad"?

If you want to troubleshoot your setup, there are numerous ways to find out what is going on. Does the soundcard play? If your setup is just copy/paste from those lines I posted, notice sox is sending data at 48kHz 16 bits, therefore your soundcard setup would be correct. It will be what you specify there.

Basically we have not done any troubleshooting yet, that script says your device is taken by some process alsa-sink... which we do not know what is (IMO PA). Absolutely no reason to reinstall linux with some other distribution or even go shopping for a different card.

Virtual environment will not provide you with any more information than you have available (but not explored) now.

JPlay has network operation built-in. Just like jackd or network pulseaudio.