Solved Per program volume control / mocp volume level

unInstance

New Member

Reaction score: 5
Messages: 19

I have read sound(4) and mixer(8) but I wonder how I can control volume for programs individually. In OpenBSD, for instance, programs appear along with other mixer faders like master, so I can use sndioctl to adjust programs just like I can use it to control the master level. How do I have to control the volume level per program?

One more issue that I encounter is volume level in moc (music on console): every time stop/resume playback or it starts playing the next song, the volume level turn back to 45%. How do I avoid this?
 

Mjölnir

Daemon

Reaction score: 1,505
Messages: 2,114

This is documented to be enabled by default, however the RTFM sound(4) says:
  • hw.snd.vpc_mixer_bypass
    The recommended way to use the VPC feature is to teach applications to use the correct ioctl(2)'s: SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL, SNDCTL_DSP_SETRECVOL, SNDCTL_DSP_SETRECVOL. This is however not always possible. Enable this to allow applications to use their own existing mixer logic to control their own channel volume.
I read: many applications do not get it right... so you may have to look into the source code of your favourite sound application & fix it.
 
OP
unInstance

unInstance

New Member

Reaction score: 5
Messages: 19

This is documented to be enabled by default, however the RTFM sound(4) says:
  • hw.snd.vpc_mixer_bypass
    The recommended way to use the VPC feature is to teach applications to use the correct ioctl(2)'s: SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL, SNDCTL_DSP_SETRECVOL, SNDCTL_DSP_SETRECVOL. This is however not always possible. Enable this to allow applications to use their own existing mixer logic to control their own channel volume.
I read: many applications do not get it right... so you may have to look into the source code of your favourite sound application & fix it.
I do not understand what question you are replying to.
Let us suppose that I run a program that perfectly supports OSS including VPC, then how would I control its volume without touching the master?

By the way I figured out hw.snd.vpc_autoreset=0 fixes the issue with MOC and makes sure that MOC supports VPC.
 

Mjölnir

Daemon

Reaction score: 1,505
Messages: 2,114

I do not understand what question you are replying to.
Let us suppose that I run a program that perfectly supports OSS including VPC, then how would I control its volume without touching the master?
Well, right now I'm listening to a music video in another tab of this browser, while at the same time starting e.g. vlc(1) and play another song from my local collection. Then two new channels appear in the mixer control (chromium & VLC media player), I hear the two audio sources mixed (ouch), and I can adjust their volume, pause/resume/mute them independently and without affecting the master volume. It just works. Of course, all the programs involved have to do their part right under the hood.
By the way I figured out hw.snd.vpc_autoreset=0 fixes the issue with MOC and makes sure that MOC supports VPC.
I do occasionally overlook some topics every now & then, too. You may install a DE that gets it right. I don't know if there's a working CLI (console) mixer in the ports(7) that offers that.
 
OP
unInstance

unInstance

New Member

Reaction score: 5
Messages: 19

Well, right now I'm listening to a music video in another tab of this browser, while at the same time starting e.g. vlc(1) and play another song from my local collection. Then two new channels appear in the mixer control (chromium & VLC media player), I hear the two audio sources mixed (ouch), and I can adjust their volume, pause/resume/mute them independently and without affecting the master volume. It just works. Of course, all the programs involved have to do their part right under the hood.

I do occasionally overlook some topics every now & then, too. You may install a DE that gets it right. I don't know if there's a working CLI (console) mixer in the ports(7) that offers that.
So you control individual programs in the mixer via a DE?
 

Mjölnir

Daemon

Reaction score: 1,505
Messages: 2,114

Yes, shure, why not? In Unix-like OS's, the device files are under /dev. All devices, either real physical ones or virtual/logical ones, are represented by a special file; usually under /dev. Under FreeBSD, this is a special filesystem only to manage device file handling, governed/implemented by the devfs(5). devd(8) is also very handy. E.g. if I want to restrict access to audio devices, I could add a group audio (with a low number like other basic system groups), and use that in devfs.conf(5). ls -l /dev/mix shows the mixer device file. If that mixer has multiple channels, there will be special device files for them somewhere. Maybe these are created on demand?
 

Mjölnir

Daemon

Reaction score: 1,505
Messages: 2,114

sysctl -d dev.pcm.1.{play,rec} shows the description of some sysctl(8) knobs
sysctl -e dev.pcm.{0,1,2}.{%desc,play,rec} ...and their values
 

oops

Member

Reaction score: 35
Messages: 69

how I can control volume for programs individually
Code:
$ sysctl hw.snd.verbose=2
$ mkdir -p ~/bin
$ fetch -o ~/bin/ https://people.freebsd.org/~ariff/utils/appsmixer
$ chmod +x ~/bin/appsmixer
$ appsmixer
wine (dsp0.vp0):
        Mixer pcm      is currently set to  45:45
mpv (dsp0.vp1):
        Mixer pcm      is currently set to  45:45
firefox (dsp0.vp2):
        Mixer pcm      is currently set to  45:45
$ appsmixer firefox 100
firefox (dsp0.vp0):
        Setting the mixer pcm from 45:45 to 100:100.
 
OP
unInstance

unInstance

New Member

Reaction score: 5
Messages: 19

Code:
$ sysctl hw.snd.verbose=2
$ mkdir -p ~/bin
$ fetch -o ~/bin/ https://people.freebsd.org/~ariff/utils/appsmixer
$ chmod +x ~/bin/appsmixer
$ appsmixer
wine (dsp0.vp0):
        Mixer pcm      is currently set to  45:45
mpv (dsp0.vp1):
        Mixer pcm      is currently set to  45:45
firefox (dsp0.vp2):
        Mixer pcm      is currently set to  45:45
$ appsmixer firefox 100
firefox (dsp0.vp0):
        Setting the mixer pcm from 45:45 to 100:100.
THANK YOU
 
Top