Access headphone jack output directly (via GPIO, not audio)?

I am working on a program that creates “clicks” that can be used to synchronize external devices (Korg Volcas or the SQ-1 sequencer). My goal is to use the otherwise unused headphone jack as click output. Currently I am using mididings for the MIDI part and pyalsaaudio to output the click. It works so far but there is a delay caused by the audio buffers (I did experiments using pyserial and a USB serial interface as click interface and had no delays).
So is it possible to directly access the two PWM outputs that are used for the headphone jack like generic GPIO pins ? I am aware of the cap and the low pass between the pins and the jack, but that does not bother me here. I just want to avoid any delays caused by any type of audio system buffer.
I am using a Pi 4.

Regarding your question, I could not help you, sorry. But, can’t you do that through the regular midi din output or through USB ?

Alternatively:

If you enable headphones in the Admin menu you can choose to send audio output to the headphone jack in the bold menu of the layer and then in audio routing. I’d create a layer using one of the metronome lv2 plugins that can sync to the clock to generate your click and send the audio out that way. I’m not sure how it would be for latency though.

This unfortunately does not work on my system. The alsa_out service that provides headphone out for Zynthian is crashing every few seconds. See the bug I filed: https://github.com/zynthian/zynthian-issue-tracking/issues/284

can you paste the output of aplay -l At some point the name of the audio interface was changed and I wonder if you’ve been caught by this.

The problem with MIDI clock is that it locks the devices I use (Korg Volca beats / SQ-1 sequencer) to only one speed that cannot be changed on the fly. A MIDI clock divider could(!) work but would not allow setting speeds faster than the master clock. With sync clicks I do have the option to clock the device at a synced and variable speed that can both be slower or faster than the master.

Here it comes. “CODEC” is the Behringer UCA202 I use as main audio device.
**** List of PLAYBACK Hardware Devices ****
card 1: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 2: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 3/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 3: CODEC [USB Audio CODEC], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0

1 Like

Just to add: The systemd unit file configures for the right output:
ExecStart=/usr/local/bin/alsa_out -q 0 -j Headphones -d hw:Headphones

try running raspi-config and navigating to 7 Advanced Options > A4 Audio and forcing the setting to Headphones. it should be set to 0

Is already 0

1 Like