Ask / Submit
9

Audio control in sailfish: Setting volume via cmd-line

asked 2015-02-23 14:32:54 +0300

MikErk gravatar image

updated 2015-05-19 11:36:05 +0300

chemist gravatar image

Hello everyone,

based on the request https://together.jolla.com/question/27201/request-system-wide-equalizer/ I was playing around with pulseaudio and wondering how simple/complicate building a native equalizer might be.

At first I tried "pacmd list-sinks": Jolla shows 4 available sinks, with all on 100%, even when I change the volume on my phone there is no change in this number. So I suppose the volume is controlled on a higher lever. I tried to use amixer to set a different balance between left/right speaker but I only get that the command is unknown. Interestingly if I try the same on the sailfish emulator on the SDK, setting volume over pulseaudio and the use of amixer is possible, altough there is only one sink available.

[nemo@SailfishEmul ~]$ amixer sset Master 80%,20%
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 52429 [80%] [on]
  Front Right: Playback 13108 [20%] [on]
[nemo@SailfishEmul ~]$ pacmd set-sink-volume 0 32768
[nemo@SailfishEmul ~]$ pacmd list-sinks
1 sink(s) available.
  * index: 0
    name: <alsa_output.pci-0000_00_05.0.analog-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY FLAT_VOLUME 
    state: SUSPENDED
    suspend cause: IDLE 
    priority: 9959
    volume: front-left: 32768 /  50% / -18.06 dB,   front-right: 8192 /  13% / -54.19 dB
            balance -0.75
    base volume: 41350 /  63% / -12.00 dB
    volume steps: 65537
[...]

Eventually I found this https://wiki.merproject.org/wiki/Nemo/Audio, where is decribed that at least for Mer/Nemo there is a gateway between the user and pulseaudio. Is there any documentation on this? Basically with alsa on pulseaudio getting a simple equalizer to work should be possible, I suppose.

What are your thoughts to this.

Cheers Mika

edit retag flag offensive close delete

4 Answers

Sort by » oldest newest most voted
5

answered 2015-02-23 19:37:52 +0300

dthierbach gravatar image

Maybe the SailfishDevel mailing list is a better place to ask? Anyway, I don't know any details about the audio architecture, but to my limited understanding there's a bunch of pulseaudio modules which do audio routing (incoming calls, speaker vs. headset) and volume control. So it's not really a "gateway". Alsa is only used as backend for pulseaudio. Access to everything is via DBus.

So if you follow the instructions on the MainVolume page on the wiki you linked, you first see that you need to connect to the pulseaudio server, because it's neither on the system nor the session bus (whoever had this bright idea). It turns out the address is unix:path=/run/user/100000/pulse/dbus-socket on my Jolla. Then you can access the volume properties with e.g.

dbus-send --print-reply --type=method_call --address='unix:path=/run/user/100000/pulse/dbus-socket' --dest=org.Meego.MainVolume2 /com/meego/mainvolume2 org.freedesktop.DBus.Properties.GetAll string:com.Meego.MainVolume2

etc. from the commandline.

As to where an equalizer should go, I don't really know. Another pulseaudio module accessible via DBus, together with an App (or several) to control it? You will probably need to understand the Nemo audio routing, and insert the equalizer's sink(s) and source(s). So the Nemo documentation, source code and developer's mailing lists are where I would start looking.

edit flag offensive delete publish link more

Comments

Is there a way to change the values from command line? Your command seems to only show current values.

naytsyrhc ( 2019-02-20 17:50:21 +0300 )edit
2

answered 2015-03-27 20:15:24 +0300

MikErk gravatar image

updated 2015-03-27 20:51:31 +0300

Ok I figured something out, but this is really a hack... In fact you go below the volume settings set by the Dbus-socketz (so what you would do by the volume buttons on the side of the phone)

One can install alsa-mixer via:

pkcon install alsa-utils

Then you can use amixer to set the main volume, also for different balances between left/right. It works but you don't get any notification from your Jolla that this is happening. Your Jolla still thinks it is on the set volume. So if you mute your phone via amixer it stays mute :) In Debian f.e. the alsamixer is directly controlled by the volume settings GUI/commands, so there are some differences...

Here a screenshot from the terminal (via ssh on Jolla): image description

There is a cli-based equalizer for alsa, so this could work on jolla too...

see here: http://www.thedigitalmachine.net/alsaequal.html

edit flag offensive delete publish link more

Comments

1

Just to mention: Here I only show the master channel but one is able to see all channels via pressing F6 and switching to the sound card. There are plenty of channels but as I didn't know what is what I didn't have a closer look...

MikErk ( 2015-03-27 20:44:41 +0300 )edit

Thanks MikErk, this reminds me of N9 days.

Edz ( 2015-03-28 00:53:19 +0300 )edit

This helped me for sure. I was trying to find a way to use alsa libs with another command line tool. Having aplay available to play sounds is helpful to me as well. Still... actually producing sound is not working for me yet.

escogido ( 2017-10-28 05:54:10 +0300 )edit
2

answered 2015-05-19 11:25:02 +0300

lakutalo gravatar image

Here comes another approach: https://together.jolla.com/question/68113/louder-than-100-volume/?answer=74840#post-id-74840

All credits to @lispy

edit flag offensive delete publish link more
0

answered 2019-06-09 15:35:01 +0300

marsch gravatar image

updated 2019-06-09 15:43:13 +0300

Don't use alsa directly (as it won't work properly), use pulseaudio.

On the Xperia, source 2 is the microphone in question, the default volume is 100%, which compares to 65536. To increase it, set the volume to a multiple of 65536:

pactl set-source-volume 2 262144

or more general

pactl set-source-volume @DEFAULT_SOURCE@ 400%

For my usage, 300% or 400% are sufficient, everything above has too much noise in it.

edit flag offensive delete publish link more

Comments

Thanks, in my Xperia XA2 with SFOS 3.1.0.11 this settings, set value to 300% solve the low microphone problem. Greetings from Mexico.

raffles496 ( 2019-08-15 08:24:55 +0300 )edit
Login/Signup to Answer

Question tools

Follow
5 followers

Stats

Asked: 2015-02-23 14:32:54 +0300

Seen: 3,264 times

Last updated: Jun 09