You are not logged in.
Pages: 1
It is not difficult to remove PulseAudio and PipeWire.
The problem is how to configure a software mixer for ALSA.
Such mixer might be needed, if one wants to use ALSA just like MacOS users are using the sound system on MacBooks: for video conferencing with Discord or similar app, or playing HiRes audio files without distortions produced by crappy resamplers. This implies that the desired software mixer should have a high quality real-time codec (resampler and format converter).
These problems can be solved through the help of the fftrate plugin
https://github.com/PetrovSE/fftrate
Debian packages:
libasound2-plugin-fftrate_1.6.3_amd64.deb
alsa-config-utils_1.6.3_amd64.deb
pcm-utils_1.6.3_amd64.deb
They provide:
libasound_module_rate_fftrate.so — ALSA plugin (FFT resampler/converter)
arateconf — utility to generate ~/.asoundrc
pcm_conv — standalone FFT resampler/converter
How to compile fftrate plugin
Install "build-essential", etc.
sudo apt update
sudo apt-get install build-essential git debhelper
sudo apt install libasound2-dev libasound2-plugins swh-plugins
Install gcc-10 and g++-10 from Devuan's oldstable repositories.
$ cat /etc/apt/sources.list | grep oldstable
# oldstable repositories
deb http://deb.devuan.org/merged oldstable main contrib non-free
deb-src http://deb.devuan.org/merged oldstable main contrib non-free
Enable the oldstable repositories and update
sudo apt update
$ apt search g* | grep "gcc-10/\|g++-10/"
g++-10/oldstable,now 10.2.1-6 amd64
gcc-10/oldstable,now 10.2.1-6 amd64
sudo apt install gcc-10 g++-10
$ whereis gcc-10 g++-10
gcc-10: /usr/bin/gcc-10
g++-10: /usr/bin/g++-10
To compile the code you should configure "make" to use gcc-10 and g++-10, instead of the default gcc-12 and g++-12.
To build the deb packages, you have to specify "compatibility level 13" in debian/compat
$ man debhelper-compat-upgrade-checklist | grep "recommended mode"
v13 This is the recommended mode of operation.
Compilation
mkdir petrov-fftrate
cd petrov-fftrate
git clone https://github.com/PetrovSE/fftrate.git
Now you have to edit two files inside the package "fftrate":
./fftrate/src/lib/makedef.mk
./fftrate/packets/debian/compat
Enable gcc-10 and g++-10:
$ cat ./fftrate/src/lib/makedef.mk | grep gcc -A1
CC = gcc-10
CPP = g++-10
Change compat to "13":
$ cat ./fftrate/packets/debian/compat
13
Now you can compile:
cd ./fftrate/packets
$ ls -1
Makefile
debian
etc
mk_dpkg
Compilte the code:
make
Make debian packages:
./mk_dpkg
$ ls ../ | grep .deb
alsa-config-utils_1.6.3_amd64.deb
libasound2-plugin-fftrate_1.6.3_amd64.deb
pcm-utils_1.6.3_amd64.deb
How to install fftrate
Install dependencies (if they are not already installed):
sudo apt install libasound2 libasound2-plugins swh-plugins
Install fftrate:
sudo dpkg -i libasound2-plugin-fftrate_1.6.3_amd64.deb alsa-config-utils_1.6.3_amd64.deb pcm-utils_1.6.3_amd64.deb
Open /etc/fftrate.conf with a text editor:
sudo nano /etc/fftrate.conf
Enable fft resampler:
$ cat /etc/fftrate.conf | grep "Transform type" -A3
# Transform type
# Available: dct, fft (default: dct)
#transform = dct
transform = fft
Run arateconf (interactive mode) to generate ~/.asoundrc
arateconf
Press 0 to select the first sound card.
Press 1 to select the second sound card.
Press F to change format
For Intel HDA codec on motherboard, try 32bit 192000Hz
For USB headsets, try 16bit 48Hz
Run TEST (press T).
If all tests have been passed successfully, save the setting (press S) and exit (ESC).
EXAMPLE: Intel HDA
===============
| Main menu |
---------------
Curr. | Used | Play (def) | Rec (def) | Available cards
----------|------|------------|-----------|-----------------------------------
0 - >>>>> | * | * * | * * | HDA-Intel - HDA Intel PCH
1 - | * | * | * | USB-Audio - iMic USB audio system
U - Toggle used flag
P - Set this device as default player
R - Set this device as default recorder
O - Output device: PCH,0
I - Input device : PCH,0
F - Format: 192000 Hz, 2 ch, 'S32_LE'
C - Converter: fftrate
A - Show all plugins [ ]
M - Plug-ins:
[X] Convert, [ ] Expand, [X] Asym
[ ] Play Vol, [X] Dmix
[ ] Rec. Vol, [X] Dsnoop
[ ] Phonon, [ ] Normalizator
T - Test
S - Save to '/home/devuan/.asoundrc'
X - Delete '/home/devuan/.asoundrc'
ESC - Exit
EXAMPLE: iMic USB
===============
| Main menu |
---------------
Curr. | Used | Play (def) | Rec (def) | Available cards
----------|------|------------|-----------|-----------------------------------
0 - | * | * * | * * | HDA-Intel - HDA Intel PCH
1 - >>>>> | * | * | * | USB-Audio - iMic USB audio system
U - Toggle used flag
P - Set this device as default player
R - Set this device as default recorder
O - Output device: system,0
I - Input device : system,0
F - Format: 48000 Hz, 2 ch, 'S16_LE'
C - Converter: fftrate
A - Show all plugins [ ]
M - Plug-ins:
[X] Convert, [ ] Expand, [X] Asym
[ ] Play Vol, [X] Dmix
[ ] Rec. Vol, [X] Dsnoop
[ ] Phonon, [ ] Normalizator
T - Test
S - Save to '/home/devuan/.asoundrc'
X - Delete '/home/devuan/.asoundrc'
ESC - Exit
TEST
> t
Testing H/W compatibility ...
Device: PCH
Output:
Open device "hw:PCH,0" ... Ok.
Set rate 192000 Hz ... Ok.
Set channels 2 ... Ok.
Set format 'S32_LE' ... Ok.
Set buffer size 30720 -> 30720
Set period size 7680 -> 7680
Input:
Open device "hw:PCH,0" ... Ok.
Set rate 192000 Hz ... Ok.
Set format 'S32_LE' ... Ok.
Set buffer size 30720 -> 30720
Set period size 7680 -> 7680
Device: system
Output:
Open device "hw:system,0" ... Ok.
Set rate 48000 Hz ... Ok.
Set channels 2 ... Ok.
Set format 'S16_LE' ... Ok.
Set buffer size 7680 -> 7680
Set period size 1920 -> 1920
Input:
Open device "hw:system,0" ... Ok.
Set rate 48000 Hz ... Ok.
Set format 'S16_LE' ... Ok.
Set buffer size 7680 -> 7680
Set period size 1920 -> 1920
Press any key ...
S - Save to '/home/devuan/.asoundrc'
> s
Saving config file...
Test: 'default' ... Ok.
Test: 'default' ... Ok.
Ok.
Testing playback/recording
$ aplay *.wav
Playing WAVE 'audio_test_48kHz_16bit.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Input: 48000 Hz, 2 ch, 's16_le' (0x2): dummy = 0, period = 1920
Output: 192000 Hz, 2 ch, 's32_le' (0xa): dummy = 0, period = 7680
Rates: 48000 --> 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.
$ arecord -V stereo -f S16_LE -r 48000 -c 2 1-fft-exp_rec_alsa.wav
Recording WAVE '1-fft-exp_rec_alsa.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Input: 192000 Hz, 2 ch, 's32_le' (0xa): dummy = 0, period = 7680
Output: 48000 Hz, 2 ch, 's16_le' (0x2): dummy = 0, period = 1920
Rates: 192000 --> 48000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.
$ aplay 1-fft-exp_rec_alsa.wav
Playing WAVE '1-fft-exp_rec_alsa.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Input: 48000 Hz, 2 ch, 's16_le' (0x2): dummy = 0, period = 1920
Output: 192000 Hz, 2 ch, 's32_le' (0xa): dummy = 0, period = 7680
Rates: 48000 --> 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.
Now you can install apulse and run discord
apulse discord
You may also need ALSA mixer
alsamixer
man alsamixer
Last edited by igorzwx (2024-05-31 00:40:14)
Offline
Thank you! Looks very interesting.
Offline
EDITED
BEFORE running "arateconf", you should close all audio applications.
The "TEST" function of "arateconf" will fail, if your "audio device" is already in use.
When pulseaudio and pipewire are removed, you can easily free your "audio devices" with "fuser".
For example:
$ fuser -av $(find /dev/snd -type c 2>/dev/null)
USER PID ACCESS COMMAND
/dev/snd/controlC0: igor 2261 F.... mate-settings-d
igor 2310 F.... mate-volume-con
/dev/snd/pcmC0D0c:
/dev/snd/pcmC0D0p: igor 8248 F...m firefox-esr
/dev/snd/seq:
/dev/snd/timer: igor 8248 f.... firefox-esr
"mate-settings-daemon" and "mate-volume-control-status-icon" need not to be killed.
But "firefox-esr" should be killed to free the "audio device":
$ fuser -ikv $(find /dev/snd -type c 2>/dev/null)
USER PID ACCESS COMMAND
/dev/snd/controlC0: igor 2261 F.... mate-settings-d
igor 2310 F.... mate-volume-con
Kill process 2261 ? (y/N) n
Kill process 2310 ? (y/N) n
/dev/snd/pcmC0D0p: igor 8248 F...m firefox-esr
Kill process 8248 ? (y/N) y
/dev/snd/timer: igor 8248 f.... firefox-esr
Kill process 8248 ? (y/N) y
Could not kill process 8248: No such process
$ fuser -av $(find /dev/snd -type c 2>/dev/null)
USER PID ACCESS COMMAND
/dev/snd/controlC0: igor 2261 F.... mate-settings-d
igor 2310 F.... mate-volume-con
/dev/snd/pcmC0D0c:
/dev/snd/pcmC0D0p:
/dev/snd/seq:
/dev/snd/timer:
Now, when audio devices are free, you can run "arateconf".
if i press "T", there is "failed".
Input: Open device "hw:C1,0" ... Failed!
It failed to open "Input", because you configured your "Cambridge USB DAC" for recording.
"DAC" means "digital-to-analog converter",
see _https://en.wikipedia.org/wiki/Digital-to-analog_converter.
As the name suggests, it is not supposed to be used to record "analog sound".
For "Output", you also got an error message:
Set format 'S32_LE' ... Unsupported!
It means that your Cambridge DAC does not support 'S32_LE' (it is now default for playback),
or ALSA driver (snd_usb_audio) for your USB DAC does not support 32bit.
Try 'S16_LE', or else.
Read the manual again and change 'S32_LE' to 'S16_LE'.
Press "F" to change "format".
======================
| Sound parameters |
----------------------
S - Sample rate = 48000 Hz
C - Channels = 2
F - Format: 'S32_LE'
A - Alignment buffer and period [X]
B - Set buffer multiplier = 1
M - Set period multiplier = 1
P - Play ampl. = 0 dB
R - Rec. ampl. = 0 dB
ESC - Return to main menu
> f
==============================
| Available sample formats |
------------------------------
0 - U8
1 - S16_LE
2 - S24_3LE
3 - S24_LE
4 - S32_LE
5 - FLOAT_LE
6 - FLOAT64_LE
ESC - Return to main menu
>
Your Intel HDA codec (Generic_1) does support 48kHz 32bit.
It should also support 192kHz 32bit.
This may provide much better sound quality than your "Cambridge DAC" (it is likely to be 48kHz 16bit and nothing more with ALSA).
You can test different "sample rates" and "formats" with "arateconf".
You can also check your "proc" (cards, hw_params), for example:
$ cat /proc/asound/cards
0 [system ]: USB-Audio - iMic USB audio system
Griffin Technology, Inc iMic USB audio system at usb-0000:00:1a.0-1.3.4, full s
$ cat /proc/asound/card*/pcm*p/sub*/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1920
buffer_size: 7680
$ cat /proc/asound/card0/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1920
buffer_size: 7680
NOTE: "arateconf" is simply a tool to configure ALSA,
that is, a tool to generate an ALSA config file "~/.asoundrc".
It takes data from ALSA and from Linux (proc, etc.).
Notable Realtek products include ... audio codecs (AC'97 and Intel HD Audio ).
_https://en.wikipedia.org/wiki/Realtek#Notable_products
ALSA detected an Intel HDA codec on your motherboard. It has a "generic driver" for it.
It should work without problems.
You may select Intel HDA codec as default for recording.
If you connect new USB audio devices, you have to create a new ALSA config with "arateconf".
Last edited by igorzwx (2025-02-16 21:38:24)
Offline
Pages: 1