lundi 22 mai 2023

OrangePi 3 LTS + USB DAC + MPD (from sources) + Resampling and Equalizer

 I've buy this DAC :

A CMEDIA CM6631A

HIFI CM6631A DAC Board USB Digital interface 32 / 24Bit 192k USB To I2S/SPDIF Coaxial Output Audio Decoder Analog Converter


Note : This DAC is a little noisy when using sampling frequencies above 48000 Hz, ultimately I do not recommend it. 😒



Compiling MPD from git (version 0.24) optional and not verified ! 

~#nano buildmpd.sh

#ALL AS ROOT
sudo su
cd ~

#Stop current MPD then remove
mpd --kill
service mpd stop
apt remove mpd

#CLONE / DOWNLOAD SOURCES
git clone https://github.com/MusicPlayerDaemon/MPD.git

#DEPENDENCIES
apt install meson g++ \
  python3-sphinx \
  libfmt-dev \
  libpcre2-dev \
  libmad0-dev libmpg123-dev libid3tag0-dev \
  libflac-dev libvorbis-dev libopus-dev libogg-dev \
  libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
  libfluidsynth-dev libgme-dev libmikmod-dev libmodplug-dev \
  libmpcdec-dev libwavpack-dev libwildmidi-dev \
  libsidplay2-dev libsidutils-dev libresid-builder-dev \
  libavcodec-dev libavformat-dev \
  libmp3lame-dev libtwolame-dev libshine-dev \
  libsamplerate0-dev libsoxr-dev \
  libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
  libzzip-dev \
  libcurl4-gnutls-dev libyajl-dev libexpat-dev \
  libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
  libpulse-dev libshout3-dev \
  libsndio-dev \
  libmpdclient-dev \
  libnfs-dev \
  libupnp-dev \
  libavahi-client-dev \
  libsqlite3-dev \
  libsystemd-dev \
  libgtest-dev \
  libicu-dev \
  libchromaprint-dev \
  libgcrypt20-dev libavformat-dev libavfilter-dev libavdevice-dev ffmpeg

#Change to SOURCES folder
cd MPD

#CONFIGURE
# Add "--reconfigure \" if options have changed
meson . output/release \
 --prefix=/usr \
 --sysconfdir=/etc \
 --mandir=/usr/share/man \
 --localstatedir=/var \
 --buildtype=release \
 -Dao=disabled \
 -Daudiofile=disabled \
 -Dbzip2=enabled \
 -Dcdio_paranoia=disabled \
 -Dchromaprint=disabled \
 -Dcue=true \
 -Dcurl=auto \
 -Ddaemon=true \
 -Ddatabase=true \
 -Ddbus=enabled \
 -Ddocumentation=enabled \
 -Ddoxygen=false \
 -Ddsd=true \
 -Depoll=true \
 -Deventfd=true \
 -Dexpat=enabled \
 -Dfaad=auto \
 -Dffmpeg=enabled \
 -Dfifo=true \
 -Dflac=auto \
 -Dfluidsynth=disabled \
 -Dfuzzer=false \
 -Dgme=disabled \
 -Dhtml_manual=false \
 -Dhttpd=false \
 -Diconv=enabled \
 -Dicu=enabled \
 -Did3tag=auto \
 -Dinotify=true \
 -Dio_uring=auto \
 -Dipv6=enabled \
 -Diso9660=auto \
 -Djack=enabled \
 -Dlame=enabled \
 -Dlibfuzzer=true \
 -Dlibmpdclient=auto \
 -Dlibsamplerate=enabled \
 -Dlocal_socket=true \
 -Dmad=disabled \
 -Dmanpages=true \
 -Dmikmod=disabled \
 -Dmms=disabled \
 -Dmodplug=disabled \
 -Dmpcdec=auto \
 -Dmpg123=auto \
 -Dneighbor=false \
 -Dnfs=auto \
 -Dopenal=enabled \
 -Dopenmpt=auto \
 -Dopus=enabled \
 -Doss=disabled \
 -Dpcre=enabled \
 -Dpipe=true \
 -Dpipewire=auto \
 -Dpulse=enabled \
 -Dqobuz=disabled \
 -Drecorder=false \
 -Dshine=enabled \
 -Dshout=enabled \
 -Dsidplay=auto \
 -Dsignalfd=true \
 -Dsmbclient=auto \
 -Dsnapcast=true \
 -Dsndfile=disabled \
 -Dsndio=enabled \
 -Dsolaris_output=enabled \
 -Dsoundcloud=disabled \
 -Dsoxr=enabled \
 -Dsqlite=enabled \
 -Dsyslog=enabled \
 -Dsystemd=auto \
 -Dsystemd_system_unit_dir= \
 -Dsystemd_user_unit_dir= \
 -Dtcp=true \
 -Dtest=false \
 -Dtremor=auto \
 -Dtwolame=auto \
 -Dudisks=enabled \
 -Dupnp=auto \
 -Dvorbis=auto \
 -Dvorbisenc=auto \
 -Dwave_encoder=false \
 -Dwavpack=enabled \
 -Dwebdav=disabled \
 -Dwildmidi=disabled \
 -Dyajl=disabled \
 -Dzeroconf=avahi \
 -Dzlib=enabled \
 -Dzzip=auto

#BUILD
ninja -C output/release

#INSTALL
ninja -C output/release install



Save and change flags:
~#chmod 755 buildmpd.sh

Launch the script:
~#./buildmpd

... normaly, everything well done, you've got a good MPD including libavfilter (futur use...)

DAC Detection

~# lsusb -t
/:  Bus 07.Port 1: Dev 1, Class=root_hub, Driver=musb-hdrc/1p, 480M
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
    |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 1: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 1: Dev 2, If 1, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 1: Dev 2, If 2, Class=Human Interface Device, Driver=usbhid, 480M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M

DAC has been detected 👌

List Alsa devices

~#aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: allwinnerac200c [allwinner,ac200-codec], device 0: 508f000.i2s-acx00-dai acx00-codec-0 [508f000.i2s-acx00-dai acx00-codec-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Audio [USB2.0 High-Speed True HD Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: sun9ihdmi [sun9i-hdmi], device 0: SUN9I-HDMI PCM i2s-hifi-0 [SUN9I-HDMI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

DAC is listed has Alsa device ðŸ‘Œ

An other way to list sound cards

~# cat /proc/asound/cards
 0 [allwinnerac200c]: simple-card - allwinner,ac200-codec
                      allwinner,ac200-codec
 1 [Audio          ]: USB-Audio - USB2.0 High-Speed True HD Audio
                      C-Media Electronics Inc. USB2.0 High-Speed True HD Audio at usb-5311000.usb-1,
 2 [sun9ihdmi      ]: sun9i-hdmi - sun9i-hdmi
                      sun9i-hdmi

Play some sound

card 1: Audio [USB2.0 High-Speed True HD Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Mean that your DAC is linked to :
  • "card 1" mean hw 1
  • "Subdevices: 1/1" mean only one device
  • "Subdevice #0: subdevice #0" mean that this only device is the device 0

Trying the DAC

~#aplay -D hw:1,0 test.wav

If you have well-connected the DAC to an amplifier, you should hear the test.wav sound file.

Trying all devices ...

  1. On board sound chip [allwinner,ac200-codec] :
    • ~#aplay -D hw:0,0 test.wav
    • Or by using the name:
    • ~#aplay -D CARD=allwinnerac200c,DEV=0 test.wav
  2. The DAC [USB2.0 High-Speed True HD Audio]
    • ~#aplay -D hw:1,0 test.wav
    • Or by using the name:
    • ~#aplay -D CARD=Audio,DEV=0 test.wav
  3. HDMI screen speakers [sun9i-hdmi]
    • ~#aplay -D hw:2,0 test.wav
    • Or by using the name:
    • ~#aplay -D CARD=sun9ihdmi,DEV=0 test.wav


Adding alsa equalizer in conf files 

Setting up asound.conf

~#nano /etc/asound.conf
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "usbdac"
}
capture.pcm {
type plug
slave.pcm "hw:allwinnerac200c,0"
}
}

ctl.!default {
type hw
card Audio
device 0
}

ctl.equal {
type equal
}

pcm.equaldac {
type equal
slave.pcm "plughw:Audio,0"
}

pcm.daqual {
type plug
slave.pcm equaldac
}

pcm.usbdac {
type softvol
slave.pcm "plughw:Audio,0"
control.name "Master"
control.card 0
}

Setting up audio output section in mpd.conf

#################################
######### AUDIO OUTPUTS #########
#################################

# Use resampling for smoother sound but heavy CPU load
resampler {
plugin "libsamplerate"
type "1"
}

# First prefered output
audio_output {
name "DAC Equ Resamp"
type "alsa"
device "plug:daqual"
format "176400:32:2"
auto_resample         "no"
auto_format "yes"
enabled "yes"
mixer_type "software"
}

#
# Equalized DAC, no resamp
audio_output {
type "alsa"
name "DAC Equalized"
device "plug:daqual"
enabled "yes"
mixer_type "software"
}

# Only resampled no equalizer DAC (forced format)
audio_output {
type "alsa"
name "DAC"
device "hw:CARD=Audio,DEV=0"
format                  "176400:32:2"
auto_resample         "no"
auto_format "no"
enabled "yes"
mixer_type "software"
}

# HDMI output for test
audio_output {
type "alsa"
name "HDMI"
device "hw:CARD=sun9ihdmi,DEV=0"
mixer_type "software"
}



mercredi 10 mai 2023

Howto delete file or folder with dot at the end of the name ...

Open command prompt and use rd :

 rd /s "\\?\C:\Documents and Settings\User\Desktop\Annoying Folder..."