Raspberry Pi + Rune Audio ::: Một trải nghiệm nghe nhạc mới

tml3nr

Moderator
Trong bản SPMD này mình thấy trong file spotify-connect.service ở ExexStart phần âm thanh xuất ra divice chọn: --device /run/pipeout &
Mã:
ExecStart=/usr/local/bin/librespot --name symphonic-mpd --initial-volume 100
--onevent /home/pi/configs/spotify_event.sh
--cache /run --bitrate 320
--zeroconf-port 4000
--backend pipe
--device /run/pipeout  &
SpoSV.png

- Khi install TC trong bản SMPD này mình thấy file ifi-streamer-tidal-connect.service cũng có chọn device xuất âm thanh như hình:
TCSV.png

MÌnh thắc mắc là nếu trong ifi-streamer-tidal-connect.service, phần -- playback-device mình sửa thành
-- playback-device /run/pipeout (giống như trong spotify-connect.service) -> thì TC có chạy ko (vì như vậy sẽ tận dụng được pipe.service (aplay-rt ?) của smpd ko phải tắt mpd.service, và lúc này có cân thêm file tidal-connect-even.sh để release Alsa cho TC?)
Nhờ bác @quatmo , bác Hải @tml3nr xem thử vụ này.
- Về lý thuyết thì một app có thể output ra được những cách gì là đã được xác định từ đầu ạ. Thí dụ như librespot và mpd từ đầu họ đã công bố là có support pipe.

- Tham số "--playback-device" mô tả sound device chứ không phải là "type" của backend. Mặc nhiên em nghĩ là TC out ra alsa.

Nhưng em thấy status của TC có dòng này:

Mã:
pi@raspberrypi:~ $ systemctl status ifi-streamer-tidal-connect
● ifi-streamer-tidal-connect.service - RasPi Streamer Tidal Connect Service
  Loaded: loaded (/lib/systemd/system/ifi-streamer-tidal-connect.service; enabled; vendor preset: enabled)
  Active: active (running) since Fri 2021-04-16 08:10:10 +07; 13h ago
  Process: 308 ExecStartPost=/home/pi/ssettidal.sh (code=exited, status=0/SUCCESS)
Main PID: 307 (tidal_connect_a)
  Tasks: 14 (limit: 2181)
  CGroup: /system.slice/ifi-streamer-tidal-connect.service --tc-certificate-path /usr/ifi/ifi-tidal-release/id_certificate/IfiAudio_ZenStream.dat -f HiTide Streamer --codec-mpegh true --codec-mqa false --model-name HiTide RasPi Streamer --disable-app-security false --disable-web-security false --enable-mqa-passthrough false --log-level 3 --enable-websocket-log 0

Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: Cannot connect to server socket err = No such file or directory
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: Cannot connect to server request channel
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: jack server is not running or cannot be started
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Apr 16 07:01:05 raspberrypi tidal_connect_application[674]: STARTED TidalConnect services.

jack server is not running or cannot be started ???

Vậy có thể ngoài alsa TC có support jack audio? Có nghĩa là mình có thể bridge âm thanh sang một output khác?

Anh em mình ráng mò thêm anh nhỉ. Em rất ấn tượng với aplay-rt nhưng tiếc chưa có thời gian tìm hiểu kỹ.

- TC sẽ realease alsa khi mình đổi sang output khác trên app Tidal. Vậy mình không cần làm gì thêm.

Trong các bản smpd, có rất nhiều service được set để thực thi khi có một event nào nó xảy ra. Vì vậy mình hay bị ngậm alsa khi smpd init pipe hay aplay-rt. Cần phải theo dõi thật kỹ các process phát sinh và kiểm tra hết các script (pipe.sh, pcminfo.sh).
 

quatmo

Well-Known Member
jack server is not running or cannot be started ???

Vậy có thể ngoài alsa TC có support jack audio? Có nghĩa là mình có thể bridge âm thanh sang một output khác?
Đúng vậy anh, bridge sang ouput khác Ok. PulseAudio Server.
Không biết anh xem cái script này chưa? Là cách Belena làm, họ làm TC bridge từ Alsa sang PulseAudio.
https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh

https://github.com/balenalabs/balen...cb580fbfaca/plugins/tidal/Dockerfile.template
 

toi511

Well-Known Member
Bản này ngon anh, TC Ok ngay, khỏi phải cài. Thanks anh!

Em add thêm Asset/database, streaming đến AP. Khỏi cần bật mpd/upnp làm chi nữa.

Không dùng MPD thì tắt luôn 2 dòng này (rc.local) để nó không update mpd datatbase
#mpc update RAM
#mpc update USB



Chiều nay nghe qua lại giữa TC và SC.
Review nhẹ, đúng là hay hết hồn các bác. Máy mình SC sự ngân nga của nhạc cụ kéo dài hơn TC.
Bản anh gởi em AP khơi động nó chạy được chút là mất luôn anh.
 

tml3nr

Moderator
Đúng vậy anh, bridge sang ouput khác Ok. PulseAudio Server.
Không biết anh xem cái script này chưa? Là cách Belena làm, họ làm TC bridge từ Alsa sang PulseAudio.
https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh

https://github.com/balenalabs/balen...cb580fbfaca/plugins/tidal/Dockerfile.template
Em có rình TC của dev shawaj trong balena nhưng chưa thấy cái này. Hay quá anh nhỉ @@

Hiện tại chung quanh TC có quá nhiều hướng để mò: Set kernel sao cho âm thanh hay, test các loại output, phối hợp với các services khác...

Riêng về việc liên kết volume với alsa mixer. Em thấy có vài manh mối. Hiện tại nếu như mình dùng sound có mixer "Analogue". Set như bài bên dưới sẽ sync được volume của app và alsa:

https://www.raspberrypi.org/forums/...482274aa433a29918b7a8ab37b0&start=25#p1835793

asifjahmed đã viết:
Hey Everyone!

I got this working nicely on the RPi 4 so I figured I would share my learnings here for others:

-DietPi was the platform of choice for me, default install is fine except you also have to install avahi-daemon

-Once I got Tidal connect itself working, I didn't have any volume control. I learned that the "speaker_controller"application" needs to be running in order for that part to work. In order to have this run in the background (and at startup) like the underlying tidal connect service, I created a new service description:

Mã:
[Unit]
Description=Speaker Controller
After=ifi-streamer-tidal-connect.service

[Service]
Type=forking
Restart=on-failure
RestartSec=3
ExecStart=/usr/bin/screen -L -dmS root /usr/ifi/ifi-tidal-release/bin/speaker_controller_application

[Install]
WantedBy=multi-user.target

Create that file in /etc/systemd/system/, chmod+x it, and enable it via systemctl in order to have it start up after tidal connect, at startup. Works great!
 

tml3nr

Moderator
Em báo cáo sơ bộ tình hình wifi usb trên pi.

Hiện tại em test với raspbian buster 5.10.17 hầu hết các wifi usb chạy rất ngon. Nếu như wifi nào không có driver sẵn mình dùng script install-wifi của dev MrEngman setup rất nhanh và chạy OK chứ không lag lag như những năm trước.

Có mấy cái wifi em mua 2016 đến giờ chạy mới ngọt.

Những chipset dev MrEngman đang support là: rtl8188eu, rtl8188fu, rtl8192eu, rtl8812au, rtl8821cu, 8822bu, mt7610 và mt7612.

Chỉ cần chạy lệnh sau:

Mã:
sudo wget http://downloads.fars-robotics.net/wifi-drivers/install-wifi -O /usr/bin/install-wifi
sudo chmod +x /usr/bin/install-wifi
sudo /usr/bin/install-wifi

Thí dụ như bên dưới, em install Edimax EW-7811UTC RTL8812AU chạy OK con gà đen luôn:

Mã:
pi@raspberrypi:~ $ sudo /usr/bin/install-wifi

*** Raspberry Pi wifi driver installer by MrEngman.
*** Performing self-update
*** Relaunching after update

*** Raspberry Pi wifi driver installer by MrEngman.

Your current kernel revision = 5.10.17-v7+
Your current kernel build  = #1403

Checking for a wifi module to determine the driver to install.

Your wifi module is Bus 001 Device 004: ID 7392:a812 Edimax Technology Co., Ltd

And it uses the 8812au driver.

Your Pi revision number is 2a01041
You have a Pi 2B v1.1
Checking for a 8812au wifi driver module for your current kernel.
There is a driver module available for this kernel revision.
Downloading the 8812au driver, 8812au-5.10.17-v7-1403.tar.gz.
Installing the 8812au driver.

Installing driver config file 8812au.conf.
mv 8812au.conf /etc/modprobe.d/.
Installing driver module 8812au.ko.
install -p -m 644 8812au.ko /lib/modules/5.10.17-v7+/kernel/drivers/net/wireless
Loading and running the 8812au driver, 8812au.ko.

More info:

http://downloads.fars-robotics.net/

wifi-usb-all.jpg
 
Chỉnh sửa lần cuối:

tml3nr

Moderator
Em bình chọn cho anh là nhà sưu tập wifi Pi khủng nhất nam bộ. :D:D:D:D:D
Dạ không biết sao em mê wifi dữ lắm :D

May mắn nữa là cái apple TC 2TB của em nó kết nối với pi2 bằng wifi của Raspberry tiếng rất sạch và êm hơn rất nhiều so với cắm dây. Nên em test wifi miệt mài luôn.

Em thấy khi dùng wifi. Chipset của bên nhận và bên phát nếu cùng hãng kết nối với nhau sẽ rất smooth và tiếng rất êm.

Cái apple TC của em dùng chipset Broadcom. wifi raspberry cũng vậy.

Lúc trước em dùng airport express. Chỉ có wifi phát từ chip broadcom là cho tiếng hay nhất và không bao giờ lag.
 
Chỉnh sửa lần cuối:

toi511

Well-Known Member
Dạ không biết sao em mê wifi dữ lắm :D

May mắn nữa là cái apple TC 2TB của em nó kết nối với pi2 bằng wifi của Raspberry tiếng rất sạch và êm hơn rất nhiều so với cắm dây. Nên em test wifi miệt mài luôn.

Em thấy khi dùng wifi. Chipset của bên nhận và bên phát nếu cùng hãng kết nối với nhau sẽ rất smooth và tiếng rất êm.

Cái apple TC của em dùng chipset Broadcom. wifi raspberry cũng vậy.

Lúc trước em dùng airport express. Chỉ có wifi phát từ chip broadcom là cho tiếng hay nhất và không bao giờ lag.
Bản smpd của anh anh quatmo gởi em ap khơi động lên được 30s là biến mất. Tc play ok. Lỗi gì anh
 

tml3nr

Moderator
Bản smpd của anh anh quatmo gởi em ap khơi động lên được 30s là biến mất. Tc play ok. Lỗi gì anh
aprenderer bị out thường là do alsa đang bị một service nào đó giành alsa lúc nó start anh ạ.

Mình có thể chạy lệnh sau để xem alsa đang rảnh hay không:

Mã:
cat /proc/asound/card*/pcm*p/sub*/hw_params

Nếu báo "closed" là alsa đang free:

Mã:
pi@raspberrypi:~ $ cat /proc/asound/card*/pcm*p/sub*/hw_params
closed

Nếu báo như bên dưới là alsa đang bị hold:

Mã:
pi@raspberrypi:~ $ cat /proc/asound/card*/pcm*p/sub*/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (705600/16)
period_size: 2258
buffer_size: 11290

Mình nên cho aprenderer start trước, rồi sau đó mới tới TC.

Cách dễ nhất là dùng service để chạy một script. Trong đó mình dùng lệnh "/bin/sleep x second" để delay start service aprenderer và service TC.

Thí dụ như em tạo soundset.service để chạy soundset.sh:

Mã:
#!/bin/bash

/bin/sleep 4; sudo systemctl restart aprenderer

/bin/sleep 2; sudo systemctl restart ifi-streamer-tidal-connect
 
Chỉnh sửa lần cuối:

toi511

Well-Known Member
aprenderer bị out thường là do alsa đang bị một service nào đó giành alsa lúc nó start anh ạ.

Mình có thể chạy lệnh sau để xem alsa đang rảnh hay không:

cat /proc/asound/card*/pcm*p/sub*/hw_params

Nếu báo "closed" là alsa đang free:

pi@raspberrypi:~ $ cat /proc/asound/card*/pcm*p/sub*/hw_params
closed

Nếu báo như bên dưới là alsa đang bị hold:

pi@raspberrypi:~ $ cat /proc/asound/card*/pcm*p/sub*/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (705600/16)
period_size: 2258
buffer_size: 11290

Mình nên cho aprenderer start trước, rồi sau đó mới tới TC.

Cách dễ nhất là dùng service để chạy một script. Trong đó mình dùng lệnh "/bin/sleep x second" để delay start service aprenderer và service TC.

Thí dụ như em tạo soundset.service để chạy soundset.sh:

Mã:
#!/bin/bash

/bin/sleep 4; sudo systemctl restart aprenderer

/bin/sleep 2; sudo systemctl restart ifi-streamer-tidal-connect
ap chay thấy rồi anh, nhưng 30 s là nó stop. khởi đông lai nó chạy đúng 30s lại mất.
 

tml3nr

Moderator
ap chay thấy rồi anh, nhưng 30 s là nó stop. khởi đông lai nó chạy đúng 30s lại mất.
aprenderer sẽ bị lỗi nếu như thời điểm nó start alsa đang bị hold.

Có khả năng là pipe.service hoặc pipe.sh đã chạy. Khi đó alsa sẽ bị hold.

Hiện tại em chưa test việc dùng luân phiên pipe và alsa.

Anh test như sau:

Disable aprenderer và tc, restart. Kiểm tra alsa có được release hay không bằng lệnh "cat /proc/asound/card*/pcm*p/sub*/hw_params".

Start thủ công aprenderer, kiểm tra aprenderer webui trong vài phút. Nếu nó ok mình start tc

Nếu ổn anh tạo file setsound.service:

Mã:
[Unit]
Description=Kernel Optimizations
After=network.target

[Service]
ExecStart=/usr/bin/soundset
Type=simple

[Install]
WantedBy=multi-user.target

File /usr/bin/soundset chứa nội dung sau:

Mã:
#!/bin/bash

/bin/sleep 4; sudo systemctl restart aprenderer

/bin/sleep 2; sudo systemctl restart ifi-streamer-tidal-connect
 

toi511

Well-Known Member
aprenderer sẽ bị lỗi nếu như thời điểm nó start alsa đang bị hold.

Có khả năng là pipe.service hoặc pipe.sh đã chạy. Khi đó alsa sẽ bị hold.

Hiện tại em chưa test việc dùng luân phiên pipe và alsa.

Anh test như sau:

Disable aprenderer và tc, restart. Kiểm tra alsa có được release hay không bằng lệnh "cat /proc/asound/card*/pcm*p/sub*/hw_params".

Start thủ công aprenderer, kiểm tra aprenderer webui trong vài phút. Nếu nó ok mình start tc

Nếu ổn anh tạo file setsound.service:

Mã:
[Unit]
Description=Kernel Optimizations
After=network.target

[Service]
ExecStart=/usr/bin/soundset
Type=simple

[Install]
WantedBy=multi-user.target

File /usr/bin/soundset chứa nội dung sau:

Mã:
#!/bin/bash

/bin/sleep 4; sudo systemctl restart aprenderer

/bin/sleep 2; sudo systemctl restart ifi-streamer-tidal-connect
chắc do set drive chưa đúng hay sao anh. ap chạy bình thường nhưng chỉ cần bấm play nhạc là webgui không vào được. mặc dù dùng lênh của anh báo vẫn close
 

toi511

Well-Known Member
nhận xét bản smpd build TC nghe hay nhất trong tất cả các bản cua anh Hải em từng nghe. :D:D:D:D:D độ động tốt, âm thanh không bị flash như mấy bản trước. AP em chưa nghe được lỗi không play được nên không đánh giá được.
ps. anh rảnh temvier sửa em cái :p:p:p:p:p
 

tml3nr

Moderator
nhận xét bản smpd build TC nghe hay nhất trong tất cả các bản cua anh Hải em từng nghe. :D:D:D:D:D độ động tốt, âm thanh không bị flash như mấy bản trước. AP em chưa nghe được lỗi không play được nên không đánh giá được.
ps. anh rảnh temvier sửa em cái :p:p:p:p:p
Dạ mấy bản smpd tiếng hay hết hồn :D

Em đang kẹt việc nhà, trưa em teamview cho anh nhé.

Anh kiểm tra trước dùm em vài việc sau:

Kiểm tra file aprenderer.service có nằm trong /etc/systemd/system/aprenderer.service hay không?

Nội dung như sau:

Mã:
[Unit]
Description=APlayer Media Renderer Service
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=forking
WorkingDirectory=/usr/aprenderer
ExecStart=/usr/aprenderer/ap2renderer
StandardOutput=null

[Install]
WantedBy=multi-user.target

Anh nhớ mỗi khi có thay đổi bất kỳ file .service nào là phải chạy lệnh:

Mã:
sudo systemctl daemon-reload

Anh có dùng soundset.service để start aprenderer và tc hay không ạ? Theo em nên dùng cách đó sẽ ổn hơn là chạy độc lập cả 2.
 
Bên trên