I have been using PatchBox OS since 2020 to capture audio using a Scarlett 2i2 USB audio interface. At 96kHz, there is no dropout or noise in the captured data.
Using PD, I can produce a test tone at 100db and mesure a 93db input sinusoidal wave as shown here:
This is a simple setup where a patch cable is simply connected between the output and input jacks of the audio interface. The results are the same if the patch cables are cross connected (channel 1 to 2 and vice-versa).
When using the 64bit Patchbox version on the exact same setup, I get all kinds of noise instead of a pure sine wave : see companion topic due to restrictions imposed on new users like me.
I get these results using either of tho RPi4 Model B boards. These results are the same whether the board is powered using a RPi4 PoE HAT ((c)2018) or the RPi4 “Official RPi4 USB-C Power Supply”.
Note that there is a 7 db difference on measured input between the 32 bit and 64 bit version.
Is there a reason for this behavior?
Thanks in advance to anyone who can provide some insight 
Here is the missing screen capture showing input noise on 64 bit version:
Check your audio levels in alsamixer
.
Hello Giedrius,
In 32 bit version, alsamixer v1.1.8 reports “This sound device does not have any controls” for “Scarlett 2i2 USB”
In 64 bit version, alsamixer v1.2.8 reports exactly the same thing.
Regardless of anything else, Focusrite does not provide any software control to manipulate the gain on input for this Scarlett 2i2 USB device. Only physical dials are provided.
This is the reason I captured the PD data. Given a 100db output level, the loss should be the same regardless of the OS bit depth.
Regards,
Serge Caron
It’s difficult to say what’s going on, I would suspect some differences in the kernel and its modules between the versions.
You should be comparing direct builds of the same source code version of all the same configuration parameters, except one built for armhf and the other built for aarch64.
This would be a generic Linux question, Patchbox OS does not have a direct effect on what you observe.
Hello Giedrius,
I am not in a position to compare the exact same kernel version.
Here is a screen capture from Linux RPi4 6.6.74-rpt-rpi-v8 #1 SMP PREEMPT aarch64 
This is a bit newer than Patchbox 6.6.20 and it is not real-time. However, this is the same hardware setup in which only the SD cards are swapped.
Any other idea ?
Regards,
Try reaching out to Focusrite support or community if there is any.
To control the Scarlett and other Focusrite interfaces in Linux, there’s alsa-scarlett-gui.
Thank you. The page alsa-scarlett-gui/docs/iface-small.md at master · geoffreybennett/alsa-scarlett-gui · GitHub shows that there is no sofrtware control for gain in this device.
There are a number of comments such as Scarlett 2i2 (3rd gen) audio randomly distorts until device is reset : r/Focusrite and elsewhere regarding erratic behavior of the device.
In the sample below, with the output channels muted, PD measures minimal input levels while Audacity simply marks the frequency (24 samples at 48kHz is 0,0005 seconds). Unmuting the output channels, PD reports 93dB on both input channels and Audacity records a perfect sine wave.
Note: the 7dB loss between output and input is not significant here. The input gain is manually controlled on the device. When this gain is set to zero, the total loss is shown as 21dB. If the gain is progressively increased such that a perfect sinusoidal wave is maintained, the minimum loss is approximately 3dB.
Your mileage may vary. Now, I am looking for a way to “reset” this device on boot ;-).
Ah! The joys of Linux.
Documentation for kernel 6.6 Guide to using M-Audio Audiophile USB with ALSA and Jack — The Linux Kernel documentation.
As noted on that page, “the device initialization made by the Alsa driver in default mode may result in a corrupted state of the device”.
The following configuration was added to /etc/modprobe.d/
# USB devices
# This configuration defines as the first USB audio card a fake device that is never enabled.
# In theory, the index of the first USB device is replaced by a value of -2 to prevent other
# drivers from grabbing index 0.This behavior is not clearly documented and is avoided here.
options snd_usb_audio vid=0x0000,0x1235 pid=0x0000,0x8210 device_setup=0x00,0x1D index=0,7 enable=0,1
device_setup 0x1D defines an active digital source, 24 bits long samples, and 48.1-96kHz rate-range.
So far, this seems to hold.
1 Like
So the solution is to create a file in /etc/modprobe.d/
with the contents shown?
This device_setup parameter seems to have been created for the Fast Track Ultra (FUT) around 2010/2011. You can find various such conf files to configure the FUT capabilites on boot.
In my case, this conf solves the issue. You can avoid the latency of writing to the SD card by using a ramdisk to capture the input signals. I am including a simple script below. In Audacity, for example, you would point the temporary files location to /mnt/ramdisk.
You can push the enveloppe without distorsion, as shown below.
Regards,
#!/bin/sh -e
#
# patchmonitor
#
# This script is normally executed at startup.
#
# In order to enable or disable this script just change the execution
# bits.
#
# Add RAM disk for Audacity (default to 2 GB, approximately 90 minutes of audio capture at 44.1 KHz)
echo
AvailableMemory=$(cat /proc/meminfo | grep -i Available | grep -o '[[:digit:]]*')
AvailableMemory=$(( AvailableMemory / 1024 ))
RamdiskSize=$1
[ "$RamdiskSize" = "" ] && RamdiskSize=2048
[ $RamdiskSize -gt $AvailableMemory ] && RamdiskSize=$(( AvailableMemory - 256 ))
echo "Available memory $AvailableMemory MB, Ramdisk Size $RamdiskSize MB"
! test -e /mnt/ramdisk && sudo mkdir /mnt/ramdisk
sudo chmod 777 /mnt/ramdisk
if mount | grep -q /mnt/ramdisk; then
echo "Ramdisk filesystem already initialized!"
else
sudo mount -t tmpfs -o size=$RamdiskSize"m" speedy /mnt/ramdisk;
sudo systemctl daemon-reload
fi
df | head -n 1
df | grep /mnt/ramdisk