Page 4 of 8

Re: PWM Audio Guide

Posted: Sat Jun 25, 2016 7:05 pm
by joe7dust
A kind redditor noticed the mistake right away. It is supposed to be func =2 not 4 if you are using the right channel for a mono speaker.
Popcorn wrote:
joe7dust wrote: Wow grats on making this looking somewhat user-friendly. I took one look at the adafruit guide and was like NOPE not worth the effort, but this actually looks quite doable now.

Would someone mind telling me what I would need to change on this if I only wanted mono sound? I don't plan to have a headphone jack at all, just a single speaker that was pulled from an old laptop. I'm not exactly a connoisseur of gameboy beeps and bloops at 8-bit or whatever it was encoded at, and mono will be just perfect for that. Also I don't think the original had stereo speaker output at all, it only affects the headphone jack I think.

edit: Also, I don't need a potentiometer. I plan to keep the volume at a fixed level!
You can follow my circuit above, that is mono.

Just add this to your /boot/config.txt

Code: Select all

dtoverlay=pwm,pin=13,func=4
NOPE! Banged my head against this for a couple hours before giving up and throwing a support request up on reddit.com woke up this morning to an answer. Func=2 not 4 if you are using the right channel for a mono speaker and pin18. Seems strange that the func=# would differ between 13 vs 18...

Re: PWM Audio Guide

Posted: Sun Jun 26, 2016 11:53 am
by Popcorn
^^ It's not really a mistake. You have to pick which side you want outputted as the mono channel. Either the left or the right side sent to the GPIO driver which is either 2 or 4. Both will work.

Re: PWM Audio Guide

Posted: Tue Jun 28, 2016 12:08 pm
by alien0matic
Please don't kill me if this is a stupid question... does it have to be a 0.033uF capacitor? Only thing I could get was a 0.047uF.

Re: PWM Audio Guide

Posted: Tue Jun 28, 2016 12:49 pm
by SP33
alien0matic wrote:Please don't kill me if this is a stupid question... does it have to be a 0.033uF capacitor? Only thing I could get was a 0.047uF.
I believe it would be fine but I am not quite sure. I do know adafruit used a 0.01uF and claimed they would just have a higher cutoff frequency with nearly no audible change. So you may have a lower cutoff frequency? If someone else knows for sure this is safe to do please help him out. I don't have enough knowledge on this to say if you are good with a 0.047 or not.

Re: PWM Audio Guide

Posted: Tue Jun 28, 2016 7:06 pm
by Popcorn
SP33 wrote:
Ganreizu wrote:So say i'm doing mono sound, is this the code i would use?

Code: Select all

dtoverlay=pwm-1chan,pin=18,func=2
(for left channel?)

vs

Code: Select all

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
I have not tried mono sound myself yet but from my own tests, pin 18 was outputting in the right channel so I believe pin2 and func2 would be for left channel (pin 13)
so either try

Code: Select all

dtoverlay=pwm-1chan,pin2=13,func2=4
or

Code: Select all

dtoverlay=pwm-2chan,pin2=13,func2=4
(I'm unsure if pwm-1chan is valid)
or you could just use the original code and not use pin 18, only hook up pin 13 (left channel) just to be sure.
This is the problem. There is no dtoverlay called pwm-1chan.

It's either "pwm" for mono or "pwm-2chan" for stereo. There is no "pwm-1chan".

Re: PWM Audio Guide

Posted: Thu Jun 30, 2016 11:11 pm
by poxbox3030
I have mono audio working but.....

As an example, playing Sonic the sound of the ring collection alternates between the left and right channel. As its set up now I only get every second ring sound. I thought as mono sound it would mix both left and right and output both mixed to one speaker.

I have it wired up exactly as per Wermys guide with the mono low pass filter.

I have also constructed a stereo low pass filter to install if required.

Could someone help me with either what I am doing wrong with the mono audio, or how to wire up stereo audio to the amp (and the headphone jack)

Thanks in advance

Re: PWM Audio Guide

Posted: Fri Jul 01, 2016 6:37 am
by dantheflipman
Will someone please let me know what GPIO pins we're actually using? e.g. Are we using BOARD numbering? or BCM numbering?

I cannot seem to find this info for the life of me :lol:

Re: PWM Audio Guide

Posted: Sat Jul 02, 2016 12:39 am
by joe7dust
dantheflipman wrote:Will someone please let me know what GPIO pins we're actually using? e.g. Are we using BOARD numbering? or BCM numbering?

I cannot seem to find this info for the life of me :lol:
13 & 18 for stereo. I use 18 on mono in my guide

Re: PWM Audio Guide

Posted: Thu Jul 28, 2016 6:18 am
by Treguard
Sorry to sound thick, but just to check that this connects to two GPIO pins at one end (not sure where the ground goes) and then can the other end be straight connected to a 3.5mm stereo jack block?

I'm not sure yet how I'd control volume. Any suggestions would be most appreciated :) Thanks

Also, do you need that blue amplifier board as well that's used in the video?

Edit:- As I'm not using an original gameboy, I don't have anywhere to fix the potentiometer to, so it looks like I might just have to go the usb audio route sadly :(

Re: PWM Audio Guide

Posted: Sun Aug 28, 2016 1:35 pm
by RxBrad
So, I built the stereo circuit. I've been scouring the forum, and for life of me, I can't figure out how I'd wire up the circuit, pot, and headphone jack so I get stereo output through headphones, and the left/right channels are COMBINED through the speaker. While MOST games are mono, as previously mentioned, some are stereo (e.g. Sonic ring collection sound effects). If I only wired one channel to the speaker, some sounds wouldn't play.

Can anyone point me in the right direction.

EDIT 3: I believe that all of the stuff below applies to pre-amped signals, and those resistor values would make the audio from the speaker unusably low. I'm also guessing that the higher resistance across the active signal and ground are already accomplished through the pot. The actual answer appears to be in the diagrams here.

EDIT: Figure 2 on this page looks promising. The input would be coming from the headphone jack, and the output going into the speaker. Looking around, I've seen other similar diagrams that recommend 1k resistors in place of the 475ohm resistors. I'm just not 100% sure how to interpret the diagram. Is the bottom line the ground? (EDIT 2: yes it is .. S = shield/ground)

Image