Hi John, good to see you over here.
I've implemented volume control in CamillaDSP and at the suggestion of
@Daverz have used a FLIRC USB IR receiver to allow for remote control. I've pasted my python code below which is based on this link ->
http://moodeaudio.org/forum/printthread.php?tid=1529. The only thing weird with it is that on Ubuntu Server
/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd is owned by root so it does not work without using chown to change ownership. I do this by adding the following line to
sudo crontab -e so it gets changed on boot,
@reboot chown username /dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd.
Code:
import evdev
from camilladsp import CamillaConnection
import sys
try:
port = int(sys.argv[1])
except:
print("Usage: Start CamillaDSP with the websocket server enabled:")
print("> camilladsp -p4321 yourconfig.yml")
print("Then run this script to print some parameters from the active config.")
print("> python get_config.py 4321")
sys.exit()
cdsp = CamillaConnection("127.0.0.1", port)
cdsp.connect()
def main():
flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd')
flirc.grab()
cdspvolume = cdsp.get_volume()
for event in flirc.read_loop():
if event.type == evdev.ecodes.EV_KEY:
attrib = evdev.categorize(event)
if attrib.keystate == 1:
if attrib.keycode == 'KEY_DOWN':
if cdspvolume -1 >= -100:
cdsp.set_volume(cdspvolume - 1)
cdspvolume = cdsp.get_volume()
elif cdspvolume -1 <= -100:
cdsp.set_volume(-100)
cdspvolume = cdsp.get_volume()
elif attrib.keycode == 'KEY_UP':
if cdspvolume + 1 < 0:
cdsp.set_volume(cdspvolume + 1)
cdspvolume = cdsp.get_volume()
elif cdspvolume + 1 >= 0:
cdsp.set_volume(0)
cdspvolume = cdsp.get_volume()
elif attrib.keystate == 2:
if attrib.keycode == 'KEY_DOWN':
if cdspvolume -1 >= -100:
cdsp.set_volume(cdspvolume - 1)
cdspvolume = cdsp.get_volume()
elif cdspvolume -1 <= -100:
cdsp.set_volume(-100)
cdspvolume = cdsp.get_volume()
elif attrib.keycode == 'KEY_UP':
if cdspvolume + 1 < 0:
cdsp.set_volume(cdspvolume + 1)
cdspvolume = cdsp.get_volume()
elif cdspvolume + 1 >= 0:
cdsp.set_volume(0)
cdspvolume = cdsp.get_volume()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
For the sample rate switching I would look at
https://github.com/scripple/alsa_cdsp. This should allow you to change the CamillaDSP sample based on the file you are playing, when CamillaDSP opens the loopback it will automatically set the sample rate on the Ultralite so no need to mess with the MOTU API. I also think it is possible to use this to setup different configurations for different channel formats (i.e. 2 channel vs 7.1).
Michael