![]() |
[PROBLEM] I2C volume control of max9744 - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7) +--- Thread: [PROBLEM] I2C volume control of max9744 (/showthread.php?tid=7142) |
I2C volume control of max9744 - Mechoption - 11-28-2024 I have a Pi Zero 2W with a USB DAC sending an analogue audio signal to a Max9744 amplifier which then amplifiers the audio signal to power some 20W speakers; the max9744 is connected to the Pi via I2C and can provide digital volume control. I have found from trial and error that my best sound quality comes when the Pi is outputting 100% volume and then I adjust volume through I2C to adjust the amplifier. Below is my python code (thanks AI for writing it!) that lets me adjust volume by: "python SetAmpVolume.py vol" where "vol" is the volume. Is there some means for me to have moode use this command to execute volume changes and keep mpc volume 100? I tried editing vol.sh but it didn't work (thanks again for AI helping me find that file and trying this) - is there some master call to setting volume somewhere? Is this shenanigans possible? On the plus side, I'm loving the built in rotary encoder feature for volume - worked first time! Alas it changes mpc volume and not via i2c to a max9744 ![]() Code: import smbus RE: I2C volume control of max9744 - Mechoption - 12-03-2024 So, I don't really know what I'm doing, but I seem to have kludged something together that works ![]() Maybe someone can let me know if there's an error or something with this? Will it bite me later? Also, what on earth does vol.sh do?? Same with rotvol.sh as I tried changing those and nothing happened! It seems mpc volume is now pegged at 100, and changing the volume on the web interface now sets my max9744 amp gain to the "volume" shown on the Moode webpage. I started by running this Code: grep -rnw '/var/' -e 'setvol' from here to find playback.php having a "setvol" command (AI gave me the idea to try this) I then added the sysCmd('python3... as shown below, and changed the sendMpdCmd to set volume to 100 every time. The "SetAmpVolume.py" was written by AI and is posted below Code: if ($_SESSION['mpdmixer'] == 'hardware') { Code: import smbus RE: I2C volume control of max9744 - Mechoption - 12-03-2024 I discovered the hard way that rotenc.py (when using built in rotary encoder option) has it's own separate call for volume - I made the changes below: mpd_cli.connect() #mpd_cli.setvol(new_volume) os.system("python3 /home/pi/SetAmpVolume.py " +str(new_volume)) mpd_cli.setvol(100) mpd_cli.disconnect() |