alsa and snd_usb_audio configuration Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
phier
Posts: 12
Joined: Mon May 17, 2021 7:08 am

alsa and snd_usb_audio configuration

Post by phier »

hello
is there anything special set in alsa system ... especially on modules as

/sbin/modinfo -p snd_usb_audio

i meant, did u apply some special patches to alsa/snd that are not in mainline or didnt go to mainline kernel?


thanks
User avatar
MichaIng
Site Admin
Posts: 3088
Joined: Sat Nov 18, 2017 6:21 pm

Re: alsa and snd_usb_audio configuration

Post by MichaIng »

We use the regular ALSA packages (alsa-utils, libasound2) from Debian, nothing special. But we apply a custom config: /etc/asound.conf

The kernel-side driver depends on the hardware, are you asking for Raspberry Pi?
christak
Posts: 6
Joined: Sat Jun 26, 2021 7:34 pm

Re: alsa and snd_usb_audio configuration

Post by christak »

Hi there
I am trying to set the default period size of the snd_usb_audio for ALSA but without success. Also tried to edit the asound.conf without any luck. Anyone has done it successfully?

P.s. It is always locked to 2048 period size but after sometime change to 4096. Is there anyway to override the auto config of the card?

I want it to have it permanent to 2048.
User avatar
MichaIng
Site Admin
Posts: 3088
Joined: Sat Nov 18, 2017 6:21 pm

Re: alsa and snd_usb_audio configuration

Post by MichaIng »

Can you show how you tried it via /etc/asound.conf?
christak
Posts: 6
Joined: Sat Jun 26, 2021 7:34 pm

Re: alsa and snd_usb_audio configuration

Post by christak »

Yes here it is maybe I have done something wrong:

Code: Select all

pcm.!default {
        type hw
        card 1
        device 0
}

ctl.!default {
        type hw
        card 1
}



pcm "snd_usb_audio_hw"
            format S32_LE
            period_size 2048
            buffer_size 12288
            rate 192000
User avatar
MichaIng
Site Admin
Posts: 3088
Joined: Sat Nov 18, 2017 6:21 pm

Re: alsa and snd_usb_audio configuration

Post by MichaIng »

Please try this:

Code: Select all

pcm.!default {
        type hw
        card 1
        device 0
        format S32_LE
        period_size 2048
        buffer_size 12288
        rate 192000
}

ctl.!default {
        type hw
        card 1
}
christak
Posts: 6
Joined: Sat Jun 26, 2021 7:34 pm

Re: alsa and snd_usb_audio configuration

Post by christak »

The same thing it still shows period_size 4096. I am checking it on /proc/asound/card1/pcm0p/sub0/hw_params. Still no luck.
User avatar
MichaIng
Site Admin
Posts: 3088
Joined: Sat Nov 18, 2017 6:21 pm

Re: alsa and snd_usb_audio configuration

Post by MichaIng »

What I wonder about is that I find the "period_size" setting only set as part of a child/slave PCM definition but never directive as part of a hw PCM definition :?.

Another test: speaker-test
It should also show you a period_size range.
christak
Posts: 6
Joined: Sat Jun 26, 2021 7:34 pm

Re: alsa and snd_usb_audio configuration

Post by christak »

With the speaker_test if I override the settings it is seems to be working with this command speaker-test -F S32_LE -c 2 -r 192000 -p 2048
:

Playback device is default
Stream parameters are 192000Hz, S32_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 192000Hz (requested 192000Hz)
Buffer size range from 48 to 131072
Period size range from 24 to 65536
Requested period time 2048 us
Periods = 4
was set period_size = 393
was set buffer_size = 1572
0 - Front Left
1 - Front Right

Without override the period it give me this:

Playback device is default
Stream parameters are 192000Hz, S32_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 192000Hz (requested 192000Hz)
Buffer size range from 48 to 131072
Period size range from 24 to 65536
Using max buffer size 131072
Periods = 4
was set period_size = 32768
was set buffer_size = 131072
0 - Front Left
1 - Front Right
User avatar
MichaIng
Site Admin
Posts: 3088
Joined: Sat Nov 18, 2017 6:21 pm

Re: alsa and snd_usb_audio configuration

Post by MichaIng »

Okay, with "Period size range from 24 to 65536" it should work. You did set the period time (in microseconds) now instead of the period size (in frames). If you want a period size of 2048 frames, it would be:

Code: Select all

2048 frames/(192000 frames/second) = 0,010666... seconds = 10667 microseconds period time

Code: Select all

speaker-test -F S32_LE -c 2 -r 192000 -p 10667
Just to verify that this period time really works. Then you could also try to replace the period_size setting in asound.conf with this calculated period_time and the buffer_size setting with the buffer_time of buffer_time 64002 (10667 microseconds/period * 6 periods) accordingly, and see if that works. Probably also skip the buffer time/size, which should result in default 4 periods.

Check out the plugin docs: https://www.alsa-project.org/alsa-doc/a ... ugins.html
As you can see, setting period/buffer time/size is somehow only documented for slave definitions. But this means you need a master plugin type for the default PCM. If we want no kind of conversion, but only test to use a no-op master to assign buffer settings to the hw slave, then probably the "copy" plugin can be used for that, as it doesn't seem to do anything else than copying the stream from master to slave. If you need help, I can show you the syntax to try that, but whether this is the intended way, will work or not, is also above my ALSA/audio knowledge ;).
Post Reply