hitsware
Posts: 167
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 6:39 am

Can I use rpi.gpio to send audio ( normally sent to headphone jack )
to the gpio ? All the info I have found refers to a single controllable PWM
pin , but I want the 2 ( stereo ( PWM ) ) audio channels .....

DirkS
Posts: 10018
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 6:54 am

No

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 7:25 am

It depends on what you mean. Audio may be routed to GPIO 12/13 or GPIO 18/19. I guess if you route audio to GPIO 12/13 it won't be available on the audio jack (which I think uses GPIO 18/19).

You probably need to clarify your intentions.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 7:40 am

Joan has answered the main point.
It might be useful to look at infor for adding audio out to Pi Zero as that routes PWM audio to pins on the gpio header and filters the signal to gate a usable line level analogue signal from it. It is stereo.

Also be aware that you can send audio out on i2s on gpio pins. The various audio DAC add-ons use that. It's not PWM and won't give you audio directly like the PWM does, but it will get high quality audio out of the Pi on the gpio header.

hitsware
Posts: 167
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 12:33 pm

@ DirkS
In view of the other responses, would you please elaborate ?

@Joan
> Audio may be routed to GPIO 12/13 or GPIO 18/19.
Using RPI.gpio ?
> I guess if you route audio to GPIO 12/13
> it won't be available on the audio jack
That would be O.K.
> (which I think uses GPIO 18/19).
The signal should be on GPIO 18/19
' out of the box ' ? ..... I looked and couldn't
find it , but will try again .
What I want to do is experiment with
an alternate filter/driver for the output.

@PiGraham
> It might be useful to look at info for adding audio out to Pi Zero
> as that routes PWM audio to pins on the gpio header and filters
> the signal to gate a usable line level analogue signal from it.
Anything applying to Pi Zero would work with 3 B + ........ ?
Same gpio ?
They talk of using alternate ' gpio ' modes ' ' , but I would
be more comfortable with Python , if possible.

hitsware
Posts: 167
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 9:50 pm

Got it ! ....... Though not with Python .

Code: Select all

gpio -g mode 12 alt0
gpio -g mode 13 alt0
Puts audio on gpio pins 12 and 13 .
Does not turn off headphone jack .
Attachments
2018-08-24-144044.jpg
2018-08-24-144044.jpg (79.16 KiB) Viewed 1290 times
2018-08-24-143615.jpg
2018-08-24-143615.jpg (89.57 KiB) Viewed 1290 times

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 10:08 pm


hitsware
Posts: 167
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: RPi.gpio to send audio to gpio ?

Fri Aug 24, 2018 10:42 pm

I looked at that. Must not have scrolled down far enough :(

hitsware
Posts: 167
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: RPi.gpio to send audio to gpio ?

Sat Aug 25, 2018 12:41 am

Code: Select all

import os
os.system("gpio -g mode 12 alt0")
os.system("gpio -g mode 13 alt0")

Return to “Python”