Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Problem: Latency reduction when using audio/video player as input
#11
Hi,

My setup is Raspberry Pi 4 + official touchscreen + Native Instruments Komplete Audio 6 Mk2 on USB3 (https://www.native-instruments.com/en/pr...e-audio-6/).

Here is the verbose log of MPD :


Code:
Jan 15 18:46 : state_file: Saving state file /var/lib/mpd/state
Jan 15 18:46 : state_file: Loading state file /var/lib/mpd/state
Jan 15 18:46 : client: [0] opened from 127.0.0.1:60188
Jan 15 18:46 : client: [0] process command "status"
Jan 15 18:46 : client: [0] command returned 0
Jan 15 18:46 : client: [0] process command "currentsong"
Jan 15 18:46 : client: [0] command returned 0
Jan 15 18:46 : client: [0] process command "lsinfo "alsa://plug:spdifinput""
Jan 15 18:46 : alsa: buffer: size=768..768 time=16000..16000
Jan 15 18:46 : alsa: period: size=384..384 time=8000..8000
Jan 15 18:46 : alsa: buffer_size=768 period_size=384
Jan 15 18:46 : client: [0] command returned 3
Jan 15 18:46 : client: [0] process command "close"
Jan 15 18:46 : client: [0] command returned 4
Jan 15 18:46 : client: [0] closed
Jan 15 18:46 : client: [1] opened from 127.0.0.1:60190
Jan 15 18:46 : client: [1] process command "status"
Jan 15 18:46 : client: [1] command returned 0
Jan 15 18:46 : client: [1] process command "idle"
Jan 15 18:46 : client: [1] command returned 1
Jan 15 18:46 : client: [2] opened from 127.0.0.1:60194
Jan 15 18:46 : client: [2] process command "playlistinfo"
Jan 15 18:46 : client: [2] command returned 0
Jan 15 18:46 : client: [2] process command "close"
Jan 15 18:46 : client: [2] command returned 4
Jan 15 18:46 : client: [2] closed
Jan 15 18:46 : client: [3] opened from 127.0.0.1:60196
Jan 15 18:46 : client: [3] process command "playlistinfo"
Jan 15 18:46 : client: [3] command returned 0
Jan 15 18:46 : client: [3] process command "close"
Jan 15 18:46 : client: [3] command returned 4
Jan 15 18:46 : client: [3] closed
Jan 15 18:47 : client: [4] opened from 127.0.0.1:60198
Jan 15 18:47 : client: [4] process command list
Jan 15 18:47 : client: process command "clear"
Jan 15 18:47 : client: command returned 0
Jan 15 18:47 : client: process command "load "SPDIF Input""
Jan 15 18:47 : client: command returned 0
Jan 15 18:47 : client: process command "play"
Jan 15 18:47 : playlist: play 0:"alsa://plug:spdifinput"
Jan 15 18:47 : client: command returned 0
Jan 15 18:47 : client: [4] process command list returned 0
Jan 15 18:47 : alsa: buffer: size=768..768 time=16000..16000
Jan 15 18:47 : alsa: period: size=384..384 time=8000..8000
Jan 15 18:47 : alsa: buffer_size=768 period_size=384
Jan 15 18:47 : decoder_thread: probing plugin pcm
Jan 15 18:47 : decoder: audio_format=48000:16:2, seekable=false
Jan 15 18:47 : client: [1] process command "status"
Jan 15 18:47 : alsa_output: opened _audioout type=COPY
Jan 15 18:47 : alsa_output: buffer: size=12..43690 time=250..910209
Jan 15 18:47 : alsa_output: period: size=6..21845 time=125..455105
Jan 15 18:47 : alsa_output: default period_time = buffer_time/4 = 500000/4 = 125000
Jan 15 18:47 : alsa_output: format=S16_LE (Signed 16 bit Little Endian)
Jan 15 18:47 : alsa_output: buffer_size=24000 period_size=6000
Jan 15 18:47 : output: opened "ALSA Default" (alsa) audio_format=48000:16:2
Jan 15 18:47 : client: [1] command returned 0
Jan 15 18:47 : client: [1] process command "currentsong"
Jan 15 18:47 : client: [1] command returned 0
Jan 15 18:47 : client: [4] process command "close"
Jan 15 18:47 : client: [4] command returned 4
Jan 15 18:47 : client: [4] closed
Jan 15 18:47 : client: [1] process command "lsinfo "alsa://plug:spdifinput""
Jan 15 18:47 : alsa: buffer: size=768..768 time=16000..16000
Jan 15 18:47 : alsa: period: size=384..384 time=8000..8000
Jan 15 18:47 : alsa: buffer_size=768 period_size=384
Jan 15 18:47 : client: [1] command returned 3
Jan 15 18:47 : client: [1] process command "close"
Jan 15 18:47 : client: [1] command returned 4
Jan 15 18:47 : client: [1] closed
Jan 15 18:47 : client: [5] opened from 127.0.0.1:60200
Jan 15 18:47 : client: [5] process command "status"
Jan 15 18:47 : client: [5] command returned 0
Jan 15 18:47 : client: [5] process command "idle"
Jan 15 18:47 : client: [5] command returned 1
Jan 15 18:47 : client: [6] opened from 127.0.0.1:60202
Jan 15 18:47 : client: [6] process command "playlistinfo"
Jan 15 18:47 : client: [6] command returned 0
Jan 15 18:47 : client: [6] process command "close"
Jan 15 18:47 : client: [6] command returned 4
Jan 15 18:47 : client: [6] closed
Jan 15 18:48 : client: [7] opened from 127.0.0.1:60204
Jan 15 18:48 : client: [7] process command "pause"
Jan 15 18:48 : client: [7] command returned 0
Jan 15 18:48 : client: [7] process command "close"
Jan 15 18:48 : client: [7] command returned 4
Jan 15 18:48 : client: [7] closed
Jan 15 18:48 : client: [5] process command "status"
Jan 15 18:48 : client: [5] command returned 0
Jan 15 18:48 : client: [5] process command "currentsong"
Jan 15 18:48 : client: [5] command returned 0
Jan 15 18:48 : output: closed "ALSA Default" (alsa)
Jan 15 18:48 : client: [5] process command "lsinfo "alsa://plug:spdifinput""
Jan 15 18:48 : alsa: buffer: size=768..768 time=16000..16000
Jan 15 18:48 : alsa: period: size=384..384 time=8000..8000
Jan 15 18:48 : alsa: buffer_size=768 period_size=384
Jan 15 18:48 : client: [5] command returned 3
Jan 15 18:48 : client: [5] process command "close"
Jan 15 18:48 : client: [5] command returned 4
Jan 15 18:48 : client: [5] closed
Jan 15 18:48 : client: [8] opened from 127.0.0.1:60206
Jan 15 18:48 : client: [8] process command "status"
Jan 15 18:48 : client: [8] command returned 0
Jan 15 18:48 : client: [8] process command "idle"
Jan 15 18:48 : client: [8] command returned 1
Jan 15 18:48 : client: [9] opened from 127.0.0.1:60208
Jan 15 18:48 : client: [9] process command "playlistinfo"
Jan 15 18:48 : client: [9] command returned 0
Jan 15 18:48 : client: [9] process command "close"
Jan 15 18:48 : client: [9] command returned 4
Jan 15 18:48 : client: [9] closed

I am surprised to see alsa output in 16 bits, whereas the input given by the interface is 32 bits.

Here is the result of cat /proc/asound/MK2/stream0
Code:
Native Instruments Komplete Audio 6 MK2 at usb-0000:01:00.0-1.2, high speed : USB Audio

Playback:
 Status: Stop
 Interface 1
   Altset 1
   Format: S32_LE
   Channels: 6
   Endpoint: 0x06 (6 OUT) (ASYNC)
   Rates: 44100, 48000, 88200, 96000, 176400, 192000
   Data packet interval: 125 us
   Bits: 24
   Channel map: FL FR FC LFE RL RR
   Sync Endpoint: 0x86 (6 IN)
   Sync EP Interface: 1
   Sync EP Altset: 1
   Implicit Feedback Mode: No

Capture:
 Status: Stop
 Interface 2
   Altset 1
   Format: S32_LE
   Channels: 6
   Endpoint: 0x87 (7 IN) (ASYNC)
   Rates: 44100, 48000, 88200, 96000, 176400, 192000
   Data packet interval: 125 us
   Bits: 24
   Channel map: FL FR FC LFE RL RR
Reply
#12
False alarm about alsa output in 16 bits. Changed my m3u playlist from alsa://plugConfusedpdifinput to alsa://plugConfusedpdifinput?format=48000:32:2 (didn't forced these before by thinking it would follow source format).

Still latency is exactly the same.
Reply
#13
If you already tried with mpd.conf default "hw:N,0" then perhaps the latency is occurring on the capture side when MPD preps to play

Code:
alsa://plug:spdifinput

In order to explore this theory you would prolly need to create a generic test using plain RaspiOS Lite, MPD and your ALSA config. If the latency is still present then you could post an issue to MPD Git repo explaining that there is no latency when playing same URI with arecord piped to aplay.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#14
(01-15-2023, 09:06 PM)jiemdev Wrote: False alarm about alsa output in 16 bits. Changed my m3u playlist from alsa://plugConfusedpdifinput to alsa://plugConfusedpdifinput?format=48000:32:2 (didn't forced these before by thinking it would follow source format).

Still latency is exactly the same.

Have you tried the part of the tutorial from Bitlab that describes how to bypass MPD and use directly ALSA for capturing the input?
Maybe it's MPD the root cause of the delay... just speculating here, have no other ideas.
Reply
#15
(01-15-2023, 09:50 PM)Nutul Wrote:
(01-15-2023, 09:06 PM)jiemdev Wrote: False alarm about alsa output in 16 bits. Changed my m3u playlist from alsa://plugConfusedpdifinput to alsa://plugConfusedpdifinput?format=48000:32:2 (didn't forced these before by thinking it would follow source format).

Still latency is exactly the same.

Have you tried the part of the tutorial from Bitlab that describes how to bypass MPD and use directly ALSA for capturing the input?
Maybe it's MPD the root cause of the delay... just speculating here, have no other ideas.

This is the next step in my todo list. Wink
Then if I find a free sd card, will try Tim suggestion.
Reply


Forum Jump: