Thank you for your donation!


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


Solved: trying to control AVR volume from within Moode UI
#1
Hi,

Over here: https://moodeaudio.org/forum/showthread.php?tid=4679 I talk about how I set up Moode to turn my AVR off and on.

For extra credit I'm trying to enable the Moode UI to control the AVR's volume via eiscp commands - while leaving MPD fixed at 0db output (since I am sending audio over HDMI).

I've looked through the code a bit, but I'm not sure that I've found the right place to "bolt this on."

- I've found 'vol.sh' but I think that script is only intended for remote / command line controls? 

If someone could point me at the lines in code where changing the volume in the UI affects the volume output, that'd be a good start!

thanks!
Reply
#2
I'm not sure that what you are trying to achieve can be done as a "bolt-on".

The function setVolume() in /var/www/js/playerlib.js plus the use of vol.sh in various sections in the codebase are what provides volume control.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
Hey Tim,
Thanks - I'll have a look at that. I think that you're right though, it might take more than a little bit to make that possible.
Reply
#4
I forgot to mention a special MPD volume type named "Null". It basically causes MPD to simply not act on volume commands it receives. The moOde knob operates as normal and goes through setVolume() function so if you can change setVolume() to send eiscp commands you might be able to control AVR volume.

Volume type "Null (External control)" can be selected in MPD Config screen.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
sounds good, I'll give that a try!

I do notice that in the version I have there are only 3 files in /var/ww/js:
config.min.js lib.min.js main.min.js

What's the best/right way to get back to the non-minified source, and does that need to happen in any other part of the code tree? (I could see where there might be a couple steps beyond just checking the right commit out of git...)

thanks!
Reply
#6
We use Gulp for generating the js and php front-end runtimes. Due to time constraints though I can't offer much in terms of helping to setup a Gulp development environment.


.zip   moOde development with gulp.odt.zip (Size: 492.65 KB / Downloads: 2)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
I’m tempted to say, “it’s so easy a caveman can do it” but not everybody saw the Geico commercials of a decade ago!

Even someone as clueless about front-end development as I am was able to get Gulp running within an hour of first learning about it.

Regards,
Kent
Reply
#8
That document looks like all I need to get going. Thanks!

(Is that document someplace online and I just managed to not notice it?!)

(01-25-2022, 10:57 PM)Tim Curtis Wrote: We use Gulp for generating the js and php front-end runtimes. Due to time constraints though I can't offer much in terms of helping to setup a Gulp development environment.
Reply
#9
@swinokur, Its been a while since I've been around the volume handling code in moOde so I gave it a brief look and you may not need to modify any of the JS code.

There is a code block in /var/www/command/moode.php that sends the actual setvol command to MPD. This is where the modifications prolly need to be made. It's a plain source file and so can be edited directly.

Code:
    switch ($_GET['cmd']) {
        case 'updvolume':
            $session_volknob = $_SESSION['volknob'];

            // Update local MPD volume
            playerSession('write', 'volknob', $_POST['volknob']);
            sendMpdCmd($sock, 'setvol ' . $_POST['volknob']);
            $resp = readMpdResp($sock);

            // Update Receiver MPD volumes
            if ($_SESSION['multiroom_tx'] == 'On') {
                $voldiff = $session_volknob - $_POST['volknob'];

                if ($_POST['event'] == 'unmute') {
                    $tx_volcmd = '-mute'; // Toggle mute off
                }
                elseif ($voldiff == 0) {
                    $tx_volcmd = $_POST['volknob'];
                }
                else {
                    $tx_volcmd = $voldiff < 0 ? '-up ' . abs($voldiff) : '-dn ' . $voldiff;
                }

                updReceiverVol($tx_volcmd);
            }

            echo json_encode('OK');
            break;
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#10
Hey Tim,
I just had a look at this; when I tried to change the mixer to "null" and click "save" I see the toast that MPD has been restarted, but the UI stays at "Fixed (0db output)".

I do see an entry in the log:
20220126 173811 worker: Job mpdcfg
20220126 173812 worker: Job mpdcfg: devchg|mixchg (0|null), alsavol (96%), playstate (paused)

although, perhaps there's no change in the database though (i assume mpdmixer should be'null' instead of 'none'?)

Code:
# moodeutl -d |grep -i mpd
mpdver|0.23.4_p0x3
mpdmixer|none
mpdcrossfade|0
mpdmixer_local|none
mpd_httpd|0
mpd_httpd_port|8000
mpd_httpd_encoder|lame
volknob_mpd|0
volume_mpd_max|100

Just to double check, I also used moodeutil to dump my settings to an ini file:
[MPD]
mixer_type = "none"

---

It looks like no changes I make on the mpd-config page are being saved; I tried changing the mpd loglevel to "verbose" and that didn't save either.

-----------

Many hours later :-) There's something that got fundamentally broken when I migrated from a running setup on a RPI3b+ board to a Rpi4 board -- something must not have cloned over completely properly.

(in addition to the pages not updating the database, the volume control knob in the UI doesnt work properly.)

So - clearly time to reload from scratch!
Reply


Forum Jump: