I have a Python script that plays audio loops out to an external HDMI DAC using the Pyo library. The loops are sent to 4 different physical mono outputs in various different mixes. The problem I have is that over time the outputs seem to reorder themselves. For example, after about an hour a given output in pyo will switch from the physical output 8 to output 1. It will then switch around again to another order after a while.
I've tried everything I could think of to stop this happening. I've removed all unrequired systemd services, including all audio services, wifi and bluetooth, have scoured journalctl and dmesg for any events relating to this happening. I've disabled screen blanking in raspi-config. I've tried various permutations and simplifications of the code I'm running (one of the most basic is shown below). System is running headless with read only with overlay file system, and not connected to network.
I've tried various permutations of /etc/asound.conf with no sucess. Output port order also seems to vary depending on how the script is started (e.g. order is different if run as a service vs run from shell). Also tried plugging HDMI into other output connector (nearest ethernet port) but this didn't work either, it also seems to happen with different HDMI cables.
I'd love any advice as to anything else to try, or any troubleshooting steps I could do (for example, is there a way to log debug HDMI events to tell what's happening when the outputs switch)?
I haven't tested exhaustively but as far as I could see the speaker-test tool seems to stick to the correct outputs quite consistently.
I'd love to get it working in this set up, but if not further things I would end up trying:
- Use 2x Stereo USB audio DAC
- Downgrade to Bullseye
- Try different python audio playback library
Raspberry Pi 5 4 GB
OS is Raspberry Pi OS Bookworm 64bit Linux 6.6.31+rpt-rpi-2712 aarch64
Python 3.11.2
Pyo 1.0.5
HDMI Audio Dac: https://www.amazon.co.uk/Digital-Extrac ... B094HLH1TJ
Here is an example of one of the scripts I've been testing with (I've tried various different output devices for setOutputDevices):
One strange thing that seems to happen is the alsa state dumps seem to change sometimes, from this at bootup:To this a while after bootup (i.e. control.2 values have all gone to zero):
I've tried everything I could think of to stop this happening. I've removed all unrequired systemd services, including all audio services, wifi and bluetooth, have scoured journalctl and dmesg for any events relating to this happening. I've disabled screen blanking in raspi-config. I've tried various permutations and simplifications of the code I'm running (one of the most basic is shown below). System is running headless with read only with overlay file system, and not connected to network.
I've tried various permutations of /etc/asound.conf with no sucess. Output port order also seems to vary depending on how the script is started (e.g. order is different if run as a service vs run from shell). Also tried plugging HDMI into other output connector (nearest ethernet port) but this didn't work either, it also seems to happen with different HDMI cables.
I'd love any advice as to anything else to try, or any troubleshooting steps I could do (for example, is there a way to log debug HDMI events to tell what's happening when the outputs switch)?
I haven't tested exhaustively but as far as I could see the speaker-test tool seems to stick to the correct outputs quite consistently.
I'd love to get it working in this set up, but if not further things I would end up trying:
- Use 2x Stereo USB audio DAC
- Downgrade to Bullseye
- Try different python audio playback library
Raspberry Pi 5 4 GB
OS is Raspberry Pi OS Bookworm 64bit Linux 6.6.31+rpt-rpi-2712 aarch64
Python 3.11.2
Pyo 1.0.5
HDMI Audio Dac: https://www.amazon.co.uk/Digital-Extrac ... B094HLH1TJ
Here is an example of one of the scripts I've been testing with (I've tried various different output devices for setOutputDevices):
Code:
from pyo import *import timeimport platformif platform.node() == "raspberrypi": audio_dev = pa_get_output_devices() matching_strings = True if len([s for s in audio_dev[0] if "PCM i2s-hifi" in s]) > 0 else False s = Server(nchnls=8, duplex=0) s.setOutputDevice(audio_dev[0].index("hdmi")) s.boot()#time.sleep(1)s.start()stem_mixes = [None, None, None]speaker_mixes = {}stem_mixes = [SfPlayer('/home/test1/Bass_1.wav', loop=True, mul=.5), SfPlayer('/home/test1/Bass_1.wav', loop=True, mul=.5), SfPlayer('/home/test1/Bass_1.wav', loop=True, mul=.5)]speaker_mixes["full_mix"] = Mix([stem_mixes[0], stem_mixes[1], stem_mixes[2]], voices=1).out(3) speaker_mixes["bass"] = stem_mixes[0].out(6) #Mix([stem_mixes[0], stem_mixes[1] * Sig(0.2), stem_mixes[2] * Sig(0.2)], voices=1) * Sig(0.1)speaker_mixes["drums"] = stem_mixes[1].out(1) #Mix([stem_mixes[0] * Sig(0.2), stem_mixes[1], stem_mixes[2] * Sig(0.2)], voices=1) * Sig(0.1)speaker_mixes["melody"] = stem_mixes[2].out(5) #Mix([stem_mixes[0] * Sig(0.2), stem_mixes[1] * Sig(0.2), stem_mixes[2]], voices=1) * Sig(0.1)while True: time.sleep(100)
Code:
state.vc4hdmi0 {control.1 {iface CARDname 'HDMI Jack'value truecomment {access readtype BOOLEANcount 1}}control.2 {iface PCMname 'Playback Channel Map'value.0 3value.1 4value.2 8value.3 7value.4 5value.5 6value.6 14value.7 15comment {access readtype INTEGERcount 8range '0 - 36'}}control.3 {iface PCMname 'IEC958 Playback Mask'value ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000comment {access readtype IEC958count 1}}control.4 {iface PCMname 'IEC958 Playback Default'value '0482000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read write locked'type IEC958count 1}}control.5 {iface PCMname ELDvalue '100008006a12004f00000000000000001710010945502d48444d492d52580f7f070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read volatile'type BYTEScount 128}}control.6 {iface MIXERname 'PCM Playback Volume'value.0 255value.1 255comment {access 'read write user'type INTEGERcount 2range '0 - 255'tlv '0000000100000008ffffec1400000014'dbmin -5100dbmax 0dbvalue.0 0dbvalue.1 0}}}state.vc4hdmi1 {control.1 {iface CARDname 'HDMI Jack'value falsecomment {access readtype BOOLEANcount 1}}control.2 {iface PCMname 'Playback Channel Map'value.0 0value.1 0value.2 0value.3 0value.4 0value.5 0value.6 0value.7 0comment {access readtype INTEGERcount 8range '0 - 36'}}control.3 {iface PCMname 'IEC958 Playback Mask'value ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000comment {access readtype IEC958count 1}}control.4 {iface PCMname 'IEC958 Playback Default'value '0400000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read write'type IEC958count 1}}control.5 {iface PCMname ELDvalue '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read volatile'type BYTEScount 128}}}
Code:
state.vc4hdmi0 {control.1 {iface CARDname 'HDMI Jack'value truecomment {access readtype BOOLEANcount 1}}control.2 {iface PCMname 'Playback Channel Map'value.0 0value.1 0value.2 0value.3 0value.4 0value.5 0value.6 0value.7 0comment {access readtype INTEGERcount 8range '0 - 36'}}control.3 {iface PCMname 'IEC958 Playback Mask'value ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000comment {access readtype IEC958count 1}}control.4 {iface PCMname 'IEC958 Playback Default'value '0482000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read write'type IEC958count 1}}control.5 {iface PCMname ELDvalue '100008006a12004f00000000000000001710010945502d48444d492d52580f7f070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read volatile'type BYTEScount 128}}control.6 {iface MIXERname 'PCM Playback Volume'value.0 255value.1 255comment {access 'read write user'type INTEGERcount 2range '0 - 255'tlv '0000000100000008ffffec1400000014'dbmin -5100dbmax 0dbvalue.0 0dbvalue.1 0}}}state.vc4hdmi1 {control.1 {iface CARDname 'HDMI Jack'value falsecomment {access readtype BOOLEANcount 1}}control.2 {iface PCMname 'Playback Channel Map'value.0 0value.1 0value.2 0value.3 0value.4 0value.5 0value.6 0value.7 0comment {access readtype INTEGERcount 8range '0 - 36'}}control.3 {iface PCMname 'IEC958 Playback Mask'value ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000comment {access readtype IEC958count 1}}control.4 {iface PCMname 'IEC958 Playback Default'value '0400000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read write'type IEC958count 1}}control.5 {iface PCMname ELDvalue '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'comment {access 'read volatile'type BYTEScount 128}}}
Statistics: Posted by silentlywhat — Wed Jan 08, 2025 4:09 pm