Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Idea: Customizing Volume Control Buttons
#1
Hi everyone,
I’m using Moode Audio on my Raspberry Pi, and I’d like to customize the behavior of the volume control buttons. Specifically, I want them to stop controlling Moode’s internal audio settings and instead trigger two custom scripts I’ve created.
These scripts send infrared signals to an external audio device, adjusting its volume. So, my goal is to completely redirect the functionality of the volume buttons to execute these scripts without affecting Moode’s volume or audio output.
Is this kind of customization possible in Moode? If so, could someone point me in the right direction on how to implement it?
Thanks in advance for your help!
[*]Speakers: Chario Constellation Delphinus
[*]Amplifier: Modified Fosi Audio V3
[*]Source: Raspberry Pi Zero 2W + HiFiBerry DAC+ Zero
Reply
#2
Volume handling in moode is not really "customizable". In general volume needs to be tightly integrated with the underlying player (MPD) and audio mixer (ALSA) for maximum reliability.

Options when using an audio device with its own volume control include:

1. Set moode volume type to Fixed (0dB) and then use the audio devices remote to adjust volume

2. Calibrate overall system volume for least attenuation and then use moode volume knob to control volume
- Set audio device volume to low level
- Set moode volume to 100
- Play a track that represents what you typically listen to
- Gradually raise audio device volume to the highest you would ever listen at
- Reduce moode volume from 100 to whatever your typical listening level is
- This usually results in very little attenuation using moode volume knob
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(01-08-2025, 08:06 PM)Tim Curtis Wrote: Volume handling in moode is not really "customizable". In general volume needs to be tightly integrated with the underlying player (MPD) and audio mixer (ALSA) for maximum reliability.

Options when using an audio device with its own volume control include:

1. Set moode volume type to Fixed (0dB) and then use the audio devices remote to adjust volume

2. Calibrate overall system volume for least attenuation and then use moode volume knob to control volume
- Set audio device volume to low level
- Set moode volume to 100
- Play a track that represents what you typically listen to
- Gradually raise audio device volume to the highest you would ever listen at
- Reduce moode volume from 100 to whatever your typical listening level is
- This usually results in very little attenuation using moode volume knob

my question has certainly not been interpreted well. What I would like to do is to intervene at a low level on moode to make the volume + and - buttons do a certain action (in my case run a bash script on the raspberry). Obviously I am not asking for a release but only for an explanation of how to proceed to do this. I think that those buttons call commands on the system that modify the volume via ALSA. I would only like to modify those commands. I hope I have explained myself.
Of course ALSA will be manually set fixed to 0db following this modification
Thanks for your availability. You will soon have a new tip.
[*]Speakers: Chario Constellation Delphinus
[*]Amplifier: Modified Fosi Audio V3
[*]Source: Raspberry Pi Zero 2W + HiFiBerry DAC+ Zero
Reply
#4
I understood your request. There have been a few similar requests over the years. Here's some info that may help you out.

Changes to volume via the knob slider, +/- buttons or the mute toggle result in changes to:

1. MPD volume
2. ALSA volume if the audio device has a hardware volume controller
3. CamillaDSP volume if thats configured

Couple other things that happen when volume is changed:

1. The MPD idle timeout is triggered which returns a block of status and currentsong data to the WebUI including the dB mapped volume from ALSA if the audio device has a hardware volume controller or from CamillaDSP if thats configured.
2. Some internal SQL and session variables store the volume state for use in other parts of the application.

The code for volume handling is in the source files below. The flow is:
Knob -> setVolume() -> sendVolCmd() -> case: 'upd_volume' -> MPD or ALSA volume, optionally Receiver volume

/var/www/js/playerlib.js
- function setVolume()
- function sendVolCmd()

/var/www/command/playback.php
- case: 'upd_volume'

/var/www/js/scrips-panels.js
- three jQuery events that call setVolume()

/var/www/util/vol.sh

NOTE when when CamillaDSP volume is configured there is a separate daemon "mpd2cdspvolume" that catches the MPD idle timeout event and then proxies the volume chan ge to CamillaDSP.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
(01-08-2025, 09:33 PM)Tim Curtis Wrote: I understood your request. There have been a few similar requests over the years. Here's some info that may help you out.

Changes to volume via the knob slider, +/- buttons or the mute toggle result in changes to:

1. MPD volume
2. ALSA volume if the audio device has a hardware volume controller
3. CamillaDSP volume if thats configured

Couple other things that happen when volume is changed:

1. The MPD idle timeout is triggered which returns a block of status and currentsong data to the WebUI including the dB mapped volume from ALSA if the audio device has a hardware volume controller or from CamillaDSP if thats configured.
2. Some internal SQL and session variables store the volume state for use in other parts of the application.

The code for volume handling is in the source files below. The flow is:
Knob -> setVolume() -> sendVolCmd() -> case: 'upd_volume' -> MPD or ALSA volume, optionally Receiver volume

/var/www/js/playerlib.js
- function setVolume()
- function sendVolCmd()

/var/www/command/playback.php
- case: 'upd_volume'

/var/www/js/scrips-panels.js
- three jQuery events that call setVolume()

/var/www/util/vol.sh

NOTE when when CamillaDSP volume is configured there is a separate daemon "mpd2cdspvolume" that catches the MPD idle timeout event and then proxies the volume chan ge to CamillaDSP.
Thanks for your clarification. I'll try to do that. Best regards
[*]Speakers: Chario Constellation Delphinus
[*]Amplifier: Modified Fosi Audio V3
[*]Source: Raspberry Pi Zero 2W + HiFiBerry DAC+ Zero
Reply
#6
(01-08-2025, 09:33 PM)Tim Curtis Wrote: I understood your request. There have been a few similar requests over the years. Here's some info that may help you out.

Changes to volume via the knob slider, +/- buttons or the mute toggle result in changes to:

1. MPD volume
2. ALSA volume if the audio device has a hardware volume controller
3. CamillaDSP volume if thats configured

Couple other things that happen when volume is changed:

1. The MPD idle timeout is triggered which returns a block of status and currentsong data to the WebUI including the dB mapped volume from ALSA if the audio device has a hardware volume controller or from CamillaDSP if thats configured.
2. Some internal SQL and session variables store the volume state for use in other parts of the application.

The code for volume handling is in the source files below. The flow is:
Knob -> setVolume() -> sendVolCmd() -> case: 'upd_volume' -> MPD or ALSA volume, optionally Receiver volume

/var/www/js/playerlib.js
- function setVolume()
- function sendVolCmd()

/var/www/command/playback.php
- case: 'upd_volume'

/var/www/js/scrips-panels.js
- three jQuery events that call setVolume()

/var/www/util/vol.sh

NOTE when when CamillaDSP volume is configured there is a separate daemon "mpd2cdspvolume" that catches the MPD idle timeout event and then proxies the volume chan ge to CamillaDSP.

thanks to your advice i managed to call two scripts through the + and - buttons but now i have to delete the volume slider and the numeric indicator since i get this information from somewhere else. could you help me?
[*]Speakers: Chario Constellation Delphinus
[*]Amplifier: Modified Fosi Audio V3
[*]Source: Raspberry Pi Zero 2W + HiFiBerry DAC+ Zero
Reply
#7
(01-09-2025, 07:08 PM)Nikolovich Wrote: but now i have to delete the volume slider and the numeric indicator since i get this information from somewhere else.

Aren't they showing 0dB? They do not change...
Anyway, you can always search for the CSS classname of (one of) the DIV into which they are contained, and add

visibility: none;

to it; this preserves the room they take up (hence do not risk disrupting the UI...), but will be invisible.

HTH
Reply


Forum Jump: