2

I am developing a project on a Raspberry Pi 3 B+. I am using the PWM0 channel to send a custom-made IR signal using PiGPIO waves. I gather it might then be possible to use PWM1 for mono audio; is that a correct assessment? How might that work with the onboard audio jack when it's presumably wired up to both channels?

If my project required 2 channel (or better) audio, would the best choice be a USB audio board? Or is there a way to use audio from HDMI without binding up there HDMI port? Or another option I haven't thought of or found yet?

I've been largely unsuccessful finding pi 3 B+ examples and I'm guessing that is because hardware PWM is relatively new in the pi world.

If you have used or know about pi-specific audio boards that might satisfy my need, would you mind adding a link to it?

Beez
  • 115
  • 10
  • 1
    The pi's existing audio uses both by default apparently btw https://raspberrypi.stackexchange.com/a/49601/10590 - from where did you gather it might be possible to use just one please (I don't know if it would mind one channel being overridden!)? Hardware PWM I think has been in use since the first Pi's, just for audio. Audio over HDMI would be easiest got through an adapter, which shouldn't be too bad size wise if you are intending on using it anyway. Examples used on previous Pi's may be somewhat forward compatible. Otherwise there are a whole lot of HATs and USB dongles available... – Wilf Aug 16 '18 at 05:04
  • Even in the link you provided, somebody mentions stereo and mono. I have seen this mentioned elsewhere, but no links for that, sorry. I honestly don't know what it looks like to use one channel versus two. I also wonder if a DAC pi hat could function or be altered to use a single gpio for mono audio. – Beez Aug 16 '18 at 05:12
  • Also, if using HDMI audio and running from a Python script, how would it look to write that audio data to the appropriate channel? I have not come across any documentation on sending audio through HDMI using Python. – Beez Aug 16 '18 at 05:15
  • in a desktop environment atleast (and usually also on command line) you can use the sound servers (ALSA or Pulseaudio) which will automatically have interfaces for HDMI and added sound devices - the output is set via configuration (can be overrided in boot config with regards to HDMI). – Wilf Aug 16 '18 at 23:09
  • Any ideas using a Python script? – Beez Aug 17 '18 at 02:19

1 Answers1

1

As far as pigpio is concerned what you are trying to do is not possible.

http://abyz.me.uk/rpi/pigpio/faq.html#Sound_isnt_working

pigpio always uses either the hardware PWM peripheral or the hardware PCM peripheral to time GPIO sampling. The default is to use the hardware PCM peripheral to sample GPIO every 5µs.

If waves are being used then pigpio will also use the other hardware peripheral to time the waves.

This means neither hardware peripheral is available for use in your case.

joan
  • 71,024
  • 5
  • 73
  • 106
  • 1
    Thank you for your response! I read a lot of Pi SE questions and your name shows up often. It's an honor :) Does this impact USB sound cards or using HDMI? – Beez Aug 16 '18 at 08:47
  • 2
    @Beez pigpio should not affect or be affected by USB or HDMI. That should be fine. – joan Aug 16 '18 at 09:42
  • I read about using an USB Audio adapter. Can someone verify this? https://www.raspberrypi-spy.co.uk/2019/06/using-a-usb-audio-device-with-the-raspberry-pi/ – NicklasF Jan 26 '22 at 21:19