For my jukebox I'm using an old(ish) NAD C 320BEE amplifier, which works fine except for one thing: when it is powered on, it starts up in "sleep mode", with no input selected and buzzing speakers.
Quite annoying, because I would like the Raspberry Pi to turn on the amplifier and (active) speakers when the jukebox is unpaused and turn them off when the sound is paused, using one of those nifty usb relays.
I noticed that the amplifier has an "IR in"-socket, so I started wondering if that could be used to control it.
And it can!
After looking at Pete Shadbolt's configuration (thanks!), I did this:
- Installed lirc on the Raspberry Pi:
sudo apt install lirc.
/boot/config.txtadding the line
dtoverlay=gpio-ir-tx,gpio_pin=22to enable the gpio-ir-tx module and select the relevant pin
driver = default
/etc/lirc/lircd.conf.d/nad_sr712.conffrom lirc's list
I found an old audio cable with a 3.5 mm jack in one end, and soldered two jumper wires to it, and connected the center of the jack to pin 22 on the Raspberry Pi and the top of the jack to a GND pin.
After rebooting the Raspberry Pi, I can now run commands like this:
jukebox:~$ irsend SEND_ONCE NAD_SR712 Input-Aux jukebox:~$ irsend SEND_ONCE NAD_SR712 KEY_VOLUMEDOWN jukebox:~$ irsend SEND_ONCE NAD_SR712 KEY_VOLUMEUP jukebox:~$ irsend SEND_ONCE NAD_SR712 KEY_MUTE jukebox:~$ irsend SEND_ONCE NAD_SR712 KEY_SLEEP
and the amplifier reacts. At least it does if I don't send them in too close succession.
To wake up the amplifier when I turn on the power, I have added a file
/etc/systemd/system/amplifier.service with this in it:
[Unit] Description=Set up amplifier After=lircd.service [Service] Type=oneshot RemainAfterExit=true ExecStart=/home/asjo/bin/setup_amp ExecStop=/usr/bin/irsend SEND_ONCE NAD_SR712 Input-Phono [Install] WantedBy=multi-user.target
And in the setup_amp script, I have:
#!/bin/sh sleep 4s irsend SEND_ONCE NAD_SR712 KEY_SLEEP sleep 4s irsend SEND_ONCE NAD_SR712 Input-Aux sleep 4s irsend SEND_ONCE NAD_SR712 Input-Aux sleep 8s irsend SEND_ONCE NAD_SR712 Input-Aux
As you can see, some fiddling with timing (and retrying) is prudent. And it works!