# alsa  and  snd\_usb\_audio configuration

**URL:** <https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433>\
**Category:** Troubleshooting\
**Created:** [14 June 2021 22:00 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433 "2021-06-14T22:00:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![phier](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/p/71c47a/32.png) [@phier](https://dietpi.com/forum/u/phier)\
**Post date:** [14 June 2021 22:00 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/1 "2021-06-14T22:00:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)\
**Post date:** [15 June 2021 15:03 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/2 "2021-06-15T15:03:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jnk19](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jnk19](https://dietpi.com/forum/u/jnk19)\
**Post date:** [26 June 2021 17:39 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/3 "2021-06-26T17:39:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)\
**Post date:** [26 June 2021 22:06 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/4 "2021-06-26T22:06:48Z")

</div>

Can you show how you tried it via /etc/asound.conf?

---

<div class="post-metadata">

**Author:** ![jnk19](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jnk19](https://dietpi.com/forum/u/jnk19)\
**Post date:** [28 June 2021 01:41 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/5 "2021-06-28T01:41:42Z")

</div>

Yes here it is maybe I have done something wrong:

```nohighlight
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

```

---

<div class="post-metadata">

**Author:** ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)\
**Post date:** [29 June 2021 14:10 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/6 "2021-06-29T14:10:41Z")

</div>

Please try this:

```nohighlight
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
}

```

---

<div class="post-metadata">

**Author:** ![jnk19](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jnk19](https://dietpi.com/forum/u/jnk19)\
**Post date:** [30 June 2021 00:22 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/7 "2021-06-30T00:22:02Z")

</div>

The same thing it still shows period\_size 4096. I am checking it on /proc/asound/card1/pcm0p/sub0/hw\_params. Still no luck.

---

<div class="post-metadata">

**Author:** ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)\
**Post date:** [30 June 2021 15:00 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/8 "2021-06-30T15:00:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jnk19](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jnk19](https://dietpi.com/forum/u/jnk19)\
**Post date:** [30 June 2021 16:53 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/9 "2021-06-30T16:53:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)\
**Post date:** [30 June 2021 20:08 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/10 "2021-06-30T20:08:53Z")

</div>

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:

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

```

```nohighlight
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/alsa-lib/pcm\_plugins.html](https://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.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 😉.

---

<div class="post-metadata">

**Author:** ![jnk19](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jnk19](https://dietpi.com/forum/u/jnk19)\
**Post date:** [4 July 2021 03:41 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/11 "2021-07-04T03:41:52Z")

</div>

Yes it is accepted it with the speaker set, but when i put the new settings on asound.conf it rollback to the defaults one. Maybe it can be a driver limitation? The weird thing thing is that on after reboot the driver starts at 2048 period\_size and the then goes to 4096. Weird.

I have to edit here. It is fixed by putting only the buffer size and not the period size. It is now stable at 2048 period\_size. Thank you very much for the help.

---

<div class="post-metadata">

**Author:** ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)\
**Post date:** [8 July 2021 09:04 UTC](https://dietpi.com/forum/t/alsa-and-snd-usb-audio-configuration/5433/12 "2021-07-08T09:04:27Z")

</div>

Great that it works like that and thanks for providing the solution. Good to keep in mind when this question arises again or someone wants to add an option to our scripts 🙂.
