01-21-2023, 08:49 PM
I have been working on implementing volume control using the rotary-encoder dtoverlay. Visually, everything is working. The volume slider at the bottom increases and decreases smoothly with some occasional stuttering/buffering of volume up/down events.
The problem I am having is the volume control doesn't actually control the volume. I can only increase/decrease the volume from my phone. I am using a Rpi 4B 4GB with a Hifiberry DAC2 pro.
Here is a code snippet from my python script that handles the volume control:
Thanks,
Andrew
The problem I am having is the volume control doesn't actually control the volume. I can only increase/decrease the volume from my phone. I am using a Rpi 4B 4GB with a Hifiberry DAC2 pro.
Here is a code snippet from my python script that handles the volume control:
def volume_handler(self, client):
while self.alive:
time.sleep(0.010)
for ev in self.encoder.async_read_loop():
if ev.type == 2:
key_type = None
if ev.value == 1:
key_type = oap_api.KeyEvent.KEY_TYPE_VOLUME_UP
print("Volume Up")
elif ev.value == -1:
key_type = oap_api.KeyEvent.KEY_TYPE_VOLUME_DOWN
print("Volume Down")
else:
print('something went wrong!')
return
if key_type is not None:
key_event = oap_api.KeyEvent()
key_event.key_type = key_type
key_event.event_type = oap_api.KeyEvent.EVENT_TYPE_PRESS
client.send(oap_api.MESSAGE_KEY_EVENT, 0,
key_event.SerializeToString())
key_event.event_type = oap_api.KeyEvent.EVENT_TYPE_RELEASE
client.send(oap_api.MESSAGE_KEY_EVENT, 0,
key_event.SerializeToString())
If I open alsamixer I can see the mixer volume increase/decrease with my encoder volume script (but no actual volume change). For volume control, is this the only commands that I need to send? Is it just a configuration problem of where the audio is being sent?Thanks,
Andrew