SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-02-23 04:49:54

user 18
Member
Registered: 2015-02-21
Posts: 13

[SOLVED] Volume Mixer for Jessie

This seems to be the current place for Jessie questions, hopefully I'm right about that. If not, feel free to move me.

For the past couple of days, I've been picking away at a Jessie minimal netinstall, building it up from nothing using openbox and tint2. I've got it mostly working on my testing machine -- it's functional, but I need to add the last few touches to make it a feasible daily driver.

One of the things I'm looking for is a volume mixer with the ability to easily switch between different outputs on the fly. My current main machine is running Linux Mint 16 (cinnamon), and the sound applet there has this functionality, allowing me to switch outputs between HDMI audio from my GPU, 3.5mm audio from onboard sound, and my USB headset by left-clicking on the applet to pop up a context menu, then selecting the output I want from a list.

Is there a lightweight mixer that I can add to a tint2 panel that has similar functionality? I don't use the feature often, so needing a few additional clicks is okay.

Last edited by user 18 (2015-05-07 18:24:06)

Offline

Help fund CrunchBang, donate to the project!

#2 2015-02-23 05:21:32

tknomanzr
#! Die Hard
From: Heavener, OK
Registered: 2014-12-09
Posts: 777

Re: [SOLVED] Volume Mixer for Jessie

I've been using volumeicon-alsa with alsamixer.

Offline

#3 2015-02-23 05:22:18

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 4,148
Website

Re: [SOLVED] Volume Mixer for Jessie

You're using pulse audio? I think pavucontrol has the functionality you're talking about. You could call it up from whatever volume control you have in your system tray, as long as you can configure a custom command.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
#! forum moderator    BunsenLabs

Offline

#4 2015-02-23 05:32:09

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 13,970

Re: [SOLVED] Volume Mixer for Jessie

Have you tried Volti?  (I don't use multiple sound outputs, so I'm basically just shouting out my favorite ALSA mixer and hoping it helps. roll )  As johnraff mentioned, pulseaudio with pavucontrol is supposed to be able to handle this where alsa fails, and from my brief experience with Pulse in Jessie a couple weeks ago, the developers seem to have worked out most of the glitches.

Offline

#5 2015-02-23 05:33:43

user 18
Member
Registered: 2015-02-21
Posts: 13

Re: [SOLVED] Volume Mixer for Jessie

Currently I'm not using anything -- I haven't added any audio-related packages yet, at least not purposefully.

Will take a look at the ones mentioned, and see if they meet my needs. Thanks!

E: yep, pulse is installed by default. This is my first time doing anything other than minor tweaks to a system, sorry!

E2: volti+pavucontrol is doing what I want. Thanks for the help!

E3: Spoke too soon -- when I mute and unmute volti, it doesn't properly unmute audio. Will do more digging on this tomorrow.

Last edited by user 18 (2015-02-23 06:16:23)

Offline

#6 2015-02-23 08:45:15

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: [SOLVED] Volume Mixer for Jessie

user 18 wrote:

E3: Spoke too soon -- when I mute and unmute volti, it doesn't properly unmute audio. Will do more digging on this tomorrow.

Same problem allready noticed by other user of this forum, perhaps its time to submit a bug report for volti.

Offline

#7 2015-02-23 09:42:54

olegabrielz
#! Junkie
From: Norway
Registered: 2014-06-14
Posts: 442

Re: [SOLVED] Volume Mixer for Jessie

I am using pnmixer (the volume applet in #!) pulled from the waldorf repos. Have done this on both jessie and sid with no problems :-)

Last edited by olegabrielz (2015-02-23 11:59:47)

Offline

#8 2015-02-23 14:08:55

user 18
Member
Registered: 2015-02-21
Posts: 13

Re: [SOLVED] Volume Mixer for Jessie

brontosaurusrex wrote:
user 18 wrote:

E3: Spoke too soon -- when I mute and unmute volti, it doesn't properly unmute audio. Will do more digging on this tomorrow.

Same problem allready noticed by other user of this forum, perhaps its time to submit a bug report for volti.

Doesn't appear to be volti causing the problem specifically -- getting this behaviour with volumeicon-alsa as well.

The culprit appears to be that both the master channel and the specific output device are muted, and only the master is unmuted (in both cases).

Last edited by user 18 (2015-02-23 14:09:27)

Offline

#9 2015-02-23 14:25:53

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: [SOLVED] Volume Mixer for Jessie

user 18: good research smile

Offline

#10 2015-02-23 16:38:26

user 18
Member
Registered: 2015-02-21
Posts: 13

Re: [SOLVED] Volume Mixer for Jessie

olegabrielz wrote:

I am using pnmixer (the volume applet in #!) pulled from the waldorf repos. Have done this on both jessie and sid with no problems :-)

Didn't see this earlier -- that's definitely an option, but I'd prefer to pull from jessie repos as much as possible. Will wrestle with it a bit more, then try pulling it in and seeing if it solves the problem. I did test on my #! box, and the mute functionality is working properly there with pnmixer and pavucontrol. Wonder if there's some other package or command I'm missing that controls the way the mute works.

E: Nevermind, it's also not working 100% with pnmixer (won't mute the USB headset, but mutes and unmutes the speakers properly). However, that functionality is good enough for my use case, as I just turn off the headset when I want to mute it.

The difference appears to be that pnmixer is only muting the speaker/headphone output, and volti is muting *everything*. I bet that's a setting somewhere.

Last edited by user 18 (2015-02-23 16:46:16)

Offline

#11 2015-02-23 17:22:40

user 18
Member
Registered: 2015-02-21
Posts: 13

Re: [SOLVED] Volume Mixer for Jessie

Okay. Got it working. Mostly.

Like magic, volumeicon-alsa + pavucontrol does 95% of what I want now. Don't know precisely what settings I changed, but it works and I'm sticking to it tongue

The one remaining issue relates to media keys and volume adjustment. I have a volume control associated with my USB headset, and I want to be able to use this to change the volume of the headset. Currently, volumeicon is intercepting *all* volume adjustment via media keys and adjusting the volume on the speakers.

That's the same behaviour that occurs on waldorf, but it's not what occurs on my mint+cinnamon box. I know it's possible, I just can't determine how.

Last edited by user 18 (2015-02-23 17:24:32)

Offline

#12 2015-03-28 10:55:07

KrunchTime
#! Die Hard
From: not where I belong
Registered: 2012-03-02
Posts: 3,264

Re: [SOLVED] Volume Mixer for Jessie

I followed johnraff's guide on customizing a Jessie NetInstall to look like CrunchBang and I'm using pnmixer without issue.  I downloaded the pkg as a DEB from the CrunchBang repo and then installed it using gdebivolumeicon-alsa was just too UGLY for me to use it.


Linux User #586672
Come and Die -- Kyle Idleman

Offline

#13 2015-03-28 15:00:51

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 13,970

Re: [SOLVED] Volume Mixer for Jessie

^ You want to try Volti.  It's lovely.

Offline

#14 2015-03-29 05:32:49

KrunchTime
#! Die Hard
From: not where I belong
Registered: 2012-03-02
Posts: 3,264

Re: [SOLVED] Volume Mixer for Jessie

^ Sweet.  Thank you for the suggestion. big_smile

  • only ALSA needed

  • scroll wheel on icon changes volume (incremental percentage is configurable)

  • configurable middle click to toggle 'mute' or 'show mixer'

  • support for mutimedia keys

  • it's in the repos

I think one of my audio players still requires PulseAudio though.  hmm

20150329-01 edit:  Not working here.  I get the following errors when I attempt to run volti from terminal:

/usr/share/themes/Loma/gtk-2.0/gtkrc:47: Murrine configuration option "hilight_ratio" will be deprecated in future releases. Please use "highlight_shade" instead.
/usr/share/themes/Loma/gtk-2.0/gtkrc:49: Murrine configuration option "scrollbar_color" is no longer supported and will be ignored.
/usr/share/themes/Loma/gtk-2.0/gtkrc:50: Murrine configuration option "gradients" is no longer supported and will be ignored.
[alsactrl.py:__init__:41] can't open Master control for card HDMI, trying to select first available mixer channel

[alsactrl.py:__init__:49] can't open first available control for card HDMI
error: list index out of range
Traceback (most recent call last):
  File "/usr/bin/volti", line 53, in <module>
    volti = main.VolumeTray()
  File "/usr/lib/volti/volti/main.py", line 124, in __init__
    self.watchid = gobject.io_add_watch(fd, eventmask, self.update)
TypeError: an integer is required

I'm not sure if the errors referencing "Murrine" are a concern, but I thought I'd include them just in case.

I installed volti, added it to the ./config/openbox/autostart file, commented out the lines in autostart for pnmixer and xfce4-volumed, rebooted and no volume icon in the tint2 system tray.

Okay, I've stayed up too late again.  I'm turning out the lights.  This party is over for now.  tongue

Last edited by KrunchTime (2015-03-29 07:56:32)


Linux User #586672
Come and Die -- Kyle Idleman

Offline

#15 2015-03-31 05:02:14

KrunchTime
#! Die Hard
From: not where I belong
Registered: 2012-03-02
Posts: 3,264

Re: [SOLVED] Volume Mixer for Jessie

Figured out the problem; see my tip.  Looks like a keeper and duh...I didn't notice pvsage's first mention of volti a few responses up.  roll


Linux User #586672
Come and Die -- Kyle Idleman

Offline

#16 2015-04-13 18:51:33

KrunchTime
#! Die Hard
From: not where I belong
Registered: 2012-03-02
Posts: 3,264

Re: [SOLVED] Volume Mixer for Jessie

I've decided to go back to using pnmixer.  I didn't try all of my music players, but the volti volume level was different from the volume level in audacious and I couldn't figure out how to correct the issue.  Documentation for volti currently consists of man pages, which I hate using.  I also couldn't glean anything of value regarding my volume issue from the volti man pages.  Besides, pnmixer works with both alsa and pulseaudio.


Linux User #586672
Come and Die -- Kyle Idleman

Offline

#17 2015-04-13 19:13:10

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: [SOLVED] Volume Mixer for Jessie

KrunchTime wrote:

the volti volume level was different from the volume level in audacious

One will be using a linear scale, the other will be (correctly) using a logarithmic scale.

Offline

#18 2015-04-30 21:27:39

user 18
Member
Registered: 2015-02-21
Posts: 13

Re: [SOLVED] Volume Mixer for Jessie

Hey, looks like this topic went on without me tongue

I ended up axing the concept of a volume daemon and GUI mixer entirely, I'm instead using scripts triggered from the tint2 launcher (as well as the openbox root menu and keyboard media keys) to control pulseaudio by a combination of bash scripts and C programs.

I wrote a simple little C program to parse (from the output of 'pactl list short sinks') the id of the sink I want to use, and am using pactl set-sink-volume to deal with up/down/mute by % values.

For switching outputs, I call the C program written by this guy: https://www.tablix.org/~avian/blog/arch … ut_device/

I'm really happy with this outcome, my system's audio is now behaving exactly the way I want it to smile

E: The scripts are a little bit tailored to my system and the names of my audio devices, but I'm willing to post scripts and C source if anyone's interested in seeing it.

Last edited by user 18 (2015-04-30 21:29:14)

Offline

#19 2015-04-30 21:33:39

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: [SOLVED] Volume Mixer for Jessie

user 18 wrote:

E: The scripts are a little bit tailored to my system and the names of my audio devices, but I'm willing to post scripts and C source if anyone's interested in seeing it.

Yes please, very much so.

Offline

#20 2015-04-30 22:05:51

user 18
Member
Registered: 2015-02-21
Posts: 13

Re: [SOLVED] Volume Mixer for Jessie

Okay, here goes a longish post.

Here's the main script I use to control the various audio functions "audio.sh"

#!/bin/bash

pactl list short sinks > $HOME/.volume/sinks.txt

$HOME/.volume/parseSinks

if [[ $? == 0 ]]; then

  if [[ $# == 2 ]]; then

    if [[ $1 = "line" ]]; then    #integrated sound

      while read line
      do
        DEV=$line
      done < "$HOME/.volume/line.txt"

      if [ $DEV -eq -1 ]; then
        notify-send "Line Not Active" -t 500
      else

        case $2 in
          "up")
             while read line
              do
                LEVEL=$line
              done < "$HOME/.volume/linevol.txt"

            if [[ $LEVEL -lt 97 ]]; then
              let "LEVEL += 3"
            else
              LEVEL=100
            fi

            while read line
              do
                STATUS=$line
              done < "$HOME/.volume/linevol.txt"

            if [[ $STATUS == 0 ]]; then
              echo "1" > "$HOME/.volume/linestat.txt"
            fi

            echo $LEVEL > "$HOME/.volume/linevol.txt"

            pactl set-sink-volume $DEV $LEVEL%

            notify-send "Speaker Volume $LEVEL%" -t 200
            ;;

          "down")
            while read line
              do
                LEVEL=$line
              done < "$HOME/.volume/linevol.txt"

            if [[ $LEVEL -gt 58 ]]; then
              let "LEVEL -= 3"
            else
              LEVEL=55
            fi

            while read line
              do
                STATUS=$line
              done < "$HOME/.volume/linestat.txt"

            if [[ $STATUS == 0 ]]; then
              echo "1" > "$HOME/.volume/linestat.txt"
            fi

            echo $LEVEL > "$HOME/.volume/linevol.txt"

            pactl set-sink-volume $DEV $LEVEL%

            notify-send "Speaker Volume $LEVEL%" -t 200
            ;;

          "mute")
            while read line
              do
                STATUS=$line
              done < "$HOME/.volume/linestat.txt"

            if [[ $STATUS == 0 ]]; then
              STATUS=1

              while read line
                do
                  LEVEL=$line
                done < "$HOME/.volume/linevol.txt"

              pactl set-sink-volume $DEV $LEVEL%
            else
              STATUS=0

              pactl set-sink-volume $DEV 0%;
            fi

            echo $STATUS > "$HOME/.volume/linestat.txt"
            ;;

          "set")
            $HOME/.volume/paswitch alsa_output.pci-0000_00_14.2.analog-stereo

            echo "line" > "$HOME/.volume/current.txt"

            notify-send "Speakers Active" -t 400
            ;;
        esac
        
      fi

    elif [[ $1 = "head" ]]; then  #wireless headset

      while read line
        do
          DEV=$line
        done < "$HOME/.volume/head.txt"
        
      if [ $DEV -eq -1 ]; then
        notify-send "Headset Not Active" -t 500
      else

        case $2 in
          "up")
             while read line
              do
                LEVEL=$line
              done < "$HOME/.volume/headvol.txt"

            if [[ $LEVEL -lt 97 ]]; then
              let "LEVEL += 3"
            else
              LEVEL=100
            fi

            while read line
              do
                STATUS=$line
              done < "$HOME/.volume/headstat.txt"

            if [[ $STATUS == 0 ]]; then
              echo "1" > "$HOME/.volume/headstat.txt"
            fi

            echo $LEVEL > "$HOME/.volume/headvol.txt"

            pactl set-sink-volume $DEV $LEVEL%

            notify-send "Headset Volume $LEVEL%" -t 200
            ;;

          "down")
            while read line
              do
                LEVEL=$line
              done < "$HOME/.volume/headvol.txt"

            if [[ $LEVEL -gt 58 ]]; then
              let "LEVEL -= 3"
            else
              LEVEL=55
            fi

            while read line
              do
                STATUS=$line
              done < "$HOME/.volume/headstat.txt"

            if [[ $STATUS == 0 ]]; then
              echo "1" > "$HOME/.volume/headstat.txt"
            fi

            echo $LEVEL > "$HOME/.volume/headvol.txt"

            pactl set-sink-volume $DEV $LEVEL%

            notify-send "Headset Volume $LEVEL%" -t 200
            ;;

          "mute")
            while read line
              do
                STATUS=$line
              done < "$HOME/.volume/headstat.txt"

            if [[ $STATUS -eq 0 ]]; then
              STATUS=1

              while read line
                do
                  LEVEL=$line
                done < "$HOME/.volume/headvol.txt"

              pactl set-sink-volume $DEV $LEVEL%
            else
              STATUS=0

              pactl set-sink-volume $DEV 0%;
            fi

            echo $STATUS > "$HOME/.volume/headstat.txt"

            ;;
          "set")
            $HOME/.volume/paswitch alsa_output.usb-Logitech_Logitech_Wireless_Headset_000D44B9963E-00-Headset.analog-stereo

            echo "head" > "$HOME/.volume/current.txt"

            notify-send "Headset Active" -t 400
            ;;
        esac
      fi
    fi

  fi

else
  notify-send "Parsing Failure" -t 1000 -u critical
fi

It's a bit of a mess because it's my first time writing a bash script, but it seems to work, so there we go.

audio.sh depends on several text files located in ~/.volume:

  • line.txt: The sink number for my speakers

  • linestat.txt: The status of the speakers (muted[0] or unmuted[1])

  • linevol.txt: The volume of the speakers (in %)

  • head.txt: The sink number for my wireless headset

  • headstat.txt: The status of the wireless headset (muted[0] or unmuted[1])

  • headvol.txt: The volume of the wireless headset (in %)

  • current.txt: The currently selected pulseaudio sink -- this is used later

My sinks.txt currently looks like this:

0	alsa_output.pci-0000_01_00.1.hdmi-stereo	module-alsa-card.c	s16le 2ch 44100Hz	SUSPENDED
1	alsa_output.pci-0000_00_14.2.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	RUNNING
3	alsa_output.usb-Logitech_Logitech_Wireless_Headset_000D44B9963E-00-Headset.analog-stereo	module-alsa-card.c	s16le 2ch 48000Hz	SUSPENDED

I use a C program called parseSinks to pull out the numbers. There's probably a way of doing this using grep, but I don't know how to use grep, and I make a point of only implementing one new thing at a time (in this case, it was bash scripting). I may go back later and try to work this out using grep.

Here's the source for parseSinks.c, with some of my debug code still in it.

#include <stdio.h>
#include <string.h>

#define BUFSIZE 400

#define DEBUG 0

int main()
{
	FILE* input;
	FILE* output;

	char buffer[BUFSIZE];

	char val;
	char oldVal;
	char* token;
	
	int lineFlag = 0;
	int headFlag = 0;

	input = fopen("/home/user/.volume/sinks.txt", "r");
	if (input == NULL) return 1;
	
	oldVal = 0;

	while (feof(input) == 0)
	{
		fgets(buffer, BUFSIZE, input);
		
		if (DEBUG == 1) printf("%s\n", buffer);

		val = buffer[0];
		
		if (val == oldVal) break;
		
		if (DEBUG == 1) printf("val: %c\n", val);

		token = strtok(buffer, "\t");
		
		if (DEBUG == 1) printf("%s\n", token);

		token = strtok(NULL, "\t");
		
		if (DEBUG == 1) printf("%s\n", token);

		if (strcmp(token, "alsa_output.pci-0000_00_14.2.analog-stereo") == 0)
		{
			output = fopen("/home/user/.volume/line.txt", "w");
			if (output == NULL) return 1;

			fputc(val, output);
			fputc('\n', output);
			
			lineFlag = 1;

			fclose(output);
		}
		else if (strcmp (token, "alsa_output.usb-Logitech_Logitech_Wireless_Headset_000D44B9963E-00-Headset.analog-stereo") == 0)
		{
			output = fopen("/home/user/.volume/head.txt", "w");
			if (output == NULL) return 1;

			fputc(val, output);
			fputc('\n', output);
			
			headFlag = 1;

			fclose(output);
		}
		
		oldVal = val;
	}
	
	if (lineFlag == 0)
	{
		output = fopen("/home/user/.volume/line.txt", "w");
		if (output == NULL) return 1;

		fputs("-1", output);
		fputc('\n', output);
		
		fclose(output);
	}
	
	if (headFlag == 0)
	{
		output = fopen("/home/user/.volume/head.txt", "w");
		if (output == NULL) return 1;

		fputs("-1", output);
		fputc('\n', output);
		
		fclose(output);
	}

	fclose(input);

	return 0;
}

I'm using the tint2 launcher to control volume up and volume down. I had to create .desktop files for the launchers I needed. Here's the one for volume up, volume down is a very similar file.

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Name=Volume Up
Icon=/home/user/.volume/plus.png
Exec=volume up
Comment=Volume Up

I placed a script called volume in /usr/bin which I can pass arguments 'up' 'down' 'mute' or 'set <device>'. This is where current.txt is used.

#!/bin/bash

if [[ (($# == 1)) && (( ($1 == "up") || ($1 == "down") || ($1 == "mute") )) ]]; then
    while read line
      do
        DEV=$line
      done < "$HOME/.volume/current.txt"

    $HOME/.volume/audio.sh $DEV $1

elif [[ ($# == 2) && ($1 == "set") ]]; then
  $HOME/.volume/audio.sh $2 $1

fi

If I can figure out how to upload images (and in general how to work scrot), I can show what I've done in the launcher and the openbox menu, but it's fairly intuitive from this point. I just call volume with the appropriate argument.

Last edited by user 18 (2015-04-30 22:08:30)

Offline

#21 2015-05-01 06:28:03

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: [SOLVED] Volume Mixer for Jessie

Thank you!
smile

Offline

#22 2015-05-01 07:25:17

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: [SOLVED] Volume Mixer for Jessie

user 18 wrote:

If I can figure out how to upload images (and in general how to work scrot), I can show what I've done in the launcher and the openbox menu

scrot

You can use dmenu to call this (<Alt>+F3 in a stock #! system, I think).

For images, I use http://postimage.org/ and then paste the "Thumbnail for forums (1)" link to generate a thumbnail image. You can also paste the "Direct Link" so people don't have to see the ridiculous click-bait adverts wink

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo