DeLub
Active Member
- Thread Starter
- #41
Introduction
I would like to connect my dac and amp to my iPad to be able to listen to Apple Music on my HD600. However, I want to eq the sound and this is not possible on iOS. That's where the pi comes in: I want to put it in between my dac and the iPad, take the sound from the iPad, eq it, and output it to my dac. This is possible on a Raspberry Pi 4, as it support OTG mode for the usb power input port.
Required hardware
Obviously you need to have a Raspberry Pi 4 (it might also work on a Pi Zero). Earlier Pis don't support OTG, so won't work.
I also bought this thingie:
This allows to plug in the Pi's power source and a data cable that will be connected to the iPad on one side, and a single cable with data and power combined to the Pi. This way the Pi stays powered on when no sound source is connected and doesn't draw any power from the iPad when it is connected. (You can buy one here or on other Pi shops.)
Finally, you need a bunch of cables .
Setup the Pi
In the rest of this description I'm using DietPi as Linux distribution, but it should work quite similar on other distributions.
So, first install DietPi as per the instructions on their site. Make sure audio is enabled in the configuration program that is automatically run the first time you boot into DietPi.
Compile kernel
Until DietPi or you distro contains version 5.18 of the kernel you'll need to compile the kernel
After reboot the Pi functions as an USB audio gadget that accepts audio with a sample rate in the list
CamillaDSP
Install dependencies:
Until a new version 1.1 is released, you'll need to compile CamillaDSP yourself:
Create a set of config files for each samplerate you want to use. Here's one for 44100Hz,
What needs to be changed is between the files is the
Now we need to compile a utility that starts CamillaDSP when the sample rate changes:
Start with
Optional: Udev rule
To make your DAC go into standby mode, you can create a file /etc/udev/rules.d/usb-power.rules. You'll have to lookup the required idVendor and idProduct for your DAC. For the Topping E30, I have:
I would like to connect my dac and amp to my iPad to be able to listen to Apple Music on my HD600. However, I want to eq the sound and this is not possible on iOS. That's where the pi comes in: I want to put it in between my dac and the iPad, take the sound from the iPad, eq it, and output it to my dac. This is possible on a Raspberry Pi 4, as it support OTG mode for the usb power input port.
Required hardware
Obviously you need to have a Raspberry Pi 4 (it might also work on a Pi Zero). Earlier Pis don't support OTG, so won't work.
I also bought this thingie:
This allows to plug in the Pi's power source and a data cable that will be connected to the iPad on one side, and a single cable with data and power combined to the Pi. This way the Pi stays powered on when no sound source is connected and doesn't draw any power from the iPad when it is connected. (You can buy one here or on other Pi shops.)
Finally, you need a bunch of cables .
Setup the Pi
In the rest of this description I'm using DietPi as Linux distribution, but it should work quite similar on other distributions.
So, first install DietPi as per the instructions on their site. Make sure audio is enabled in the configuration program that is automatically run the first time you boot into DietPi.
Compile kernel
Until DietPi or you distro contains version 5.18 of the kernel you'll need to compile the kernel
- Install software to compile kernel:
apt install git bc bison flex libssl-dev make
- Download kernel source:
git clone --branch rpi-5.18.y https://github.com/raspberrypi/linux
cd linux
- Configure the kernel:
Code:KERNEL=kernel8 make bcm2711_defconfig
- Compile the kernel:
make -j4 Image.gz modules dtbs
- Install the kernel:
Code:sudo make modules_installsudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/ sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/overlays/ sudo cp arch/arm64/boot/dts/overlays/README /boot/overlays/ sudo cp arch/arm64/boot/Image.gz /boot/$KERNEL.img
- Add the line
dtoverlay=dwc2
to/boot/config.txt
. - Add two lines to
/etc/modules
:
Code:dwc2 g_audio
- Create file
/etc/modprobe.d/usb_g_audio.conf
:
Code:#load the USB audio gadget module with the following options options g_audio c_srate=44100,48000,88200,96000,176400,192000,352800,384000,705600,768000 c_ssize=4 p_chmask=0
- Reboot.
After reboot the Pi functions as an USB audio gadget that accepts audio with a sample rate in the list
c_srate
(I made it match the rates my Topping E30 accepts), and a sample size of 32 bits (c_ssize=4
means 4 bytes, equals 32 bits). For this, a new alsa device has been created, hw:UAC2Gadget
. My dac is hw:E30
, but you can find out by running arecord -l
(and aplay -l
to find your dac). p_chmask=0
is there to indicate this is a playback device to the host, not a capture device.CamillaDSP
Install dependencies:
Code:
apt install python3 python3-websocket python3-aiohttp python3-jsonschema
Until a new version 1.1 is released, you'll need to compile CamillaDSP yourself:
sudo apt-get install pkg-config libasound2-dev openssl libssl-dev
git clone --branch next11 https://github.com/HEnquist/camilladsp.git
RUSTFLAGS='-C target-feature=+neon -C target-cpu=native' cargo build --release
/usr/local/bin/
.Create a set of config files for each samplerate you want to use. Here's one for 44100Hz,
/usr/local/etc/camilladsp-44100.yml
:
Code:
devices:
samplerate: 44100
chunksize: 1024
silence_threshold: -60
silence_timeout: 3.0
enable_rate_adjust: true
stop_on_rate_change: true
capture:
type: Alsa
channels: 2
device: "hw:UAC2Gadget"
format: S32LE
playback:
type: Alsa
channels: 2
device: "hw:E30"
format: S32LE
filters:
...
samplerate
and maybe the chuncksize
(see the CamillaDSP documentation).Now we need to compile a utility that starts CamillaDSP when the sample rate changes:
git clone https://github.com/pavhofman/gaudio_ctl.git
cd gaudio_ctl
cargo build --release
- Move the executable to
/usr/local/bin/
.
/etc/systemd/system/camilladsp.service
:
Code:
[Unit]
Description=CamillaDSP Daemon
After=syslog.target
StartLimitIntervalSec=10
StartLimitBurst=10
[Service]
Type=simple
ExecStart=gaudio_ctl -y "/usr/local/bin/camilladsp --loglevel error --port 1234 /usr/local/etc/camilladsp-{R}.yml"
Restart=always
RestartSec=1
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=camilladsp
User=root
Group=root
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=10
[Install]
WantedBy=graphical.target
Start with
systemctl start camilladsp
. To have this service start at reboot, type systemctl enable camilladsp
.Optional: Udev rule
To make your DAC go into standby mode, you can create a file /etc/udev/rules.d/usb-power.rules. You'll have to lookup the required idVendor and idProduct for your DAC. For the Topping E30, I have:
Code:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="152a", ATTR{idProduct}=="8750", TEST=="power/control", ATTR{power/control}="auto"
Last edited: