# No Sound In FreeBSD   :(



## RedPhoenix (Mar 5, 2019)

So the title is pretty self-explanatory.   First, let me say this: FreeBSD DEFINITELY sees my Sound Card, but I'm unsure as to how to make it work.   Here's the output of dmesg | grep pcm:


```
pcm0: <Realtek ALC282 (Analog)> at nid 20 and 25 on hdaa0
pcm1: <Realtek ALC282 (Analog)> at nid 33 and 18 on hdaa0
pcm2: <Intel (0x280d) (HDMI/DP 8ch)> at nid 3 on hdaa1
pcm0: chn_write(): pcm0:virtual:dsp0.vp0: play interrupt timeout, channel dead
```

Why is this?   Well, I have high hopes to get this to work.      It's working in OpenBSD, so...


----------



## SirDice (Mar 5, 2019)

RedPhoenix said:


> but I'm unsure as to how to make it work.


Start here: 7.2. Setting Up the Sound Card


----------



## RedPhoenix (Mar 5, 2019)

SirDice said:


> Start here: 7.2. Setting Up the Sound Card


Yeah, I already tried that.   No Dice.


----------



## SirDice (Mar 5, 2019)

Post the output of `cat /dev/sndstat`. And where are your speakers connected? To an audio output? Or using the speakers of the monitor (HDMI)?


----------



## RedPhoenix (Mar 5, 2019)

SirDice said:


> Post the output of `cat /dev/sndstat`. And where are your speakers connected? To an audio output? Or using the speakers of the monitor (HDMI)?




```
Installed devices:
pcm0: <Realtek ALC282 (Analog)> (play/rec) default
pcm1: <Realtek ALC282 (Analog)> (play/rec)
pcm2: <Intel (0x280d) (HDMI/DP 8ch)> (play)
No devices installed from userspace.
```

It's all internal.


----------



## SirDice (Mar 5, 2019)

Well, it's detected and as long as you have your speakers connected to the correct output I see no reason why it doesn't work. What are you using to test it?


----------



## RedPhoenix (Mar 5, 2019)

SirDice said:


> Well, it's detected and as long as you have your speakers connected to the correct output I see no reason why it doesn't work. What are you using to test it?


I'm using sox, play, and cat, as well as VLC.      I have Pulseaudio installed too.


----------



## shepper (Mar 5, 2019)

Section 7.2 has a long standing error for currently supported FreeBSD versions 12.0 and 11.2.  After version 9.x, the default kernel has the most common sound drivers statically complied into the kernel.  Specifically, there is no need to kldload snd_hda.


RedPhoenix said:


> pcm0: <Realtek ALC282 (Analog)> at nid 20 and 25 on hdaa0 pcm1: <Realtek ALC282 (Analog)> at nid 33 and 18 on hdaa0


By default, FreeBSD only uses one pcm device.  The handbook section SirDice provided tells you how to change the default from pcm0 to pcm1.
Have you done that?
If you have and it still does not work, you will need to post a pindump of your audio devices.  snd_hda(4) provides the highly technical details.  There are also multiple posts, you can find using the forums' search function, about how to generate a pindump.


----------



## roper (Mar 5, 2019)

With a Realtek ALC887, in addition to setting the default unit, enabling polling worked for me. 
`sysctl dev.hdac.0.polling=1`


----------



## RedPhoenix (Mar 5, 2019)

roper said:


> With a Realtek ALC887, in addition to setting the default unit, enabling polling worked for me.
> `sysctl dev.hdac.0.polling=1`


Yays, it works!!      Thank you!


----------



## RedPhoenix (Mar 5, 2019)

shepper said:


> Section 7.2 has a long standing error for currently supported FreeBSD versions 12.0 and 11.2.  After version 9.x, the default kernel has the most common sound drivers statically complied into the kernel.  Specifically, there is no need to kldload snd_hda.
> 
> By default, FreeBSD only uses one pcm device.  The handbook section SirDice provided tells you how to change the default from pcm0 to pcm1.
> Have you done that?
> If you have and it still does not work, you will need to post a pindump of your audio devices.  snd_hda(4) provides the highly technical details.  There are also multiple posts, you can find using the forums' search function, about how to generate a pindump.


Roper fixed it for me.      Thank you for your response!


----------



## inf3rno (Jan 4, 2021)

shepper said:


> Section 7.2 has a long standing error for currently supported FreeBSD versions 12.0 and 11.2.  After version 9.x, the default kernel has the most common sound drivers statically complied into the kernel.  Specifically, there is no need to kldload snd_hda.
> 
> By default, FreeBSD only uses one pcm device.  The handbook section SirDice provided tells you how to change the default from pcm0 to pcm1.
> Have you done that?
> If you have and it still does not work, you will need to post a pindump of your audio devices.  snd_hda(4) provides the highly technical details.  There are also multiple posts, you can find using the forums' search function, about how to generate a pindump.


Isn't there a way to support multiple devices? For example I have a DAC, a monitor with audio output and rear and front audio ports. I guess this means 3 sound cards. I have 2 audio devices atm. It would be nice to send the sounds from one application to the DAC and the other to the speakers through the monitor.


----------



## SirDice (Jan 4, 2021)

inf3rno said:


> It would be nice to send the sounds from one application to the DAC and the other to the speakers through the monitor.


It depends on the application, if you can set the exact soundcard device then you could do this. The `hw.snd.default_unit` sets a _default_, and there can only be one (that's the definition of default).


----------



## inf3rno (Jan 5, 2021)

SirDice said:


> It depends on the application, if you can set the exact soundcard device then you could do this. The `hw.snd.default_unit` sets a _default_, and there can only be one (that's the definition of default).


Thanks! I am not sure though I fully understand the concept here. I mean on other OS-es I have a default too, but I can use the other jacks without changing the default. Here only the default gives me sound and the other jacks nothing even if they use the same Realtek driver, so in theory they should work. For example currently the Realtek rear jack works but not the front jack and they are both connected to the motherboards sound card. I am sure the front jack is functional on the case because it works with a different OS. So do I really need to change manually which output I use, or is there an automatic solution I can enable?


----------



## a6h (Jan 5, 2021)

inf3rno said:


> Thanks! I am not sure though I fully understand the concept here. I mean on other OS-es I have a default too, but I can use the other jacks without changing the default. Here only the default gives me sound and the other jacks nothing even if they use the same Realtek driver, so in theory they should work. For example currently the Realtek rear jack works but not the front jack and they are both connected to the motherboards sound card. I am sure the front jack is functional on the case because it works with a different OS. So do I really need to change manually which output I use, or is there an automatic solution I can enable?


Example 4 of snd_hda(4) gives you an example for a two device setup with seperate jacks
1. rear connectors: 5.1 playback
2. front connectors: headset (headphones and mic)

The example is based on a HP Compaq DX2300, but you can adapt the procedure to your specific card. Read the snd_hda(4) and check different examples, esp. "Example 4 ".
If still there's problem, write back to the forums. Sound on FreeBSD is very straightforward, just read that man page thoroughly. Good luck.

[EDIT] Personal story: one of the reason I was stating to use FreeBSD, many years ago: my sound card didn't work on windows, but it worked on FreeBSD, just by adding few line of configuration.


----------



## inf3rno (Jan 5, 2021)

vigole said:


> Example 4 of snd_hda(4) gives you an example for a two device setup with seperate jacks
> 1. rear connectors: 5.1 playback
> 2. front connectors: headset (headphones and mic)
> 
> ...


Thanks!


----------



## a6h (Jan 5, 2021)

inf3rno You're welcome. Please take a look at these resource too. They may seem rather technical, but they provide some clarifications:
1. Sound | FreeBSD Wiki
2. Chapter 15. Sound Subsystem | FreeBSD Architecture Handbook


----------

