Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:53 19 Jul 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite: can we explain/fix "ticking" when using PLAY SOUND

     Page 1 of 5    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3919
Posted: 09:43pm 16 Mar 2023
Copy link to clipboard 
Print this post

Hi folks,

I've noticed this before and I think I and/or @Volhout(?) may have mentioned it when I posted my music engine code, but this definitely has a morse-code like "ticking" in the background and it's not just on the note changes, or at least not on every note change - increasing the PAUSE duration does increase the delay between ticks.

Do
 play sound 1,b,s,523,20
 Pause 400
 play sound 1,b,s,423,20
 Pause 400
Loop


This is particularly noticeable with a crappy 20mm speaker driven by a PAM8403 even with Volhout's hi-fi filter - making me think I'm not going to be able to use PLAY SOUND on my portable device.

It is also noticeable on my PicoGAME VGA 1.4 with the original PicoMite audio filter with the sound going through a TV amp/speaker - so I think this is an issue with (this use of) PLAY SOUND rather than something specific to any particular hardware arrangement.

Any thoughts,

Tom
Edited 2023-03-17 08:07 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3780
Posted: 10:13pm 16 Mar 2023
Copy link to clipboard 
Print this post

Cpuspeed depending. At 252Mhz less prone. Maybe the calculation of the new waveform causes this.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 395
Posted: 10:39pm 16 Mar 2023
Copy link to clipboard 
Print this post

Hello!

This ticking is pretty normal (if we are speaking about the same phenomenon). I've noticed this often on cheap PAM8403, too. Does it really come from the Pico? Are you supply the voltage via USB? Often USB is bleeding some harmonics into the audible range, thats why I ALWAYS use ferrite beads and form a lowpass in the Mhz range to avoid this.

Also some points about audio in general:

If I hear via headphones (no amplifier) on the normal picMite audio the audio is fine, but if I go into a PAM8403 there is A LOT of digital noise audible, including some harmonics of the carrier frequency. This has also something to do with the signal before it hits the (power)amplifier input. I would avoid those cheap chineese modules.

I don't even use Volhout filter design but the "original" one and have no problems with the mentioned lowpass filter in the Mhz range (usb noise) and feeding the signal into the LM4871M (datasheet example) circuit driving an 8 ohm load / speaker. This chip can output 3W and is really loud, even with this tiny speaker you can see:





Greetings
Daniel
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8673
Posted: 10:57pm 16 Mar 2023
Copy link to clipboard 
Print this post

You might find using a filter on the power to the SDcard solves it - as per Daniel's board and all of mine
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1900
Posted: 11:11pm 16 Mar 2023
Copy link to clipboard 
Print this post

For anyone wanting to see if they need Peters solution, Remove the SD card while listening to the tick. If it vanishes you have found the culprit.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3919
Posted: 10:16am 17 Mar 2023
Copy link to clipboard 
Print this post

Thank you for the replies, I'll play some more this evening.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5982
Posted: 10:31am 17 Mar 2023
Copy link to clipboard 
Print this post

Make sure that any PAM8403 modules (or any digital amplifiers for that matter) that you are using have output inductors on them. Some of them omit these to keep the costs down, but the penalty is that they are quite capable of spitting out anything up to RF frequencies. You can't hear these, obviously, but they do radiate and can get back into the circuit feeding them for further amplification. The result can be a big spike, heard as a clicking noise. I'm not saying that this is the case here, but it's something to bear in mind.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3780
Posted: 10:46am 17 Mar 2023
Copy link to clipboard 
Print this post

AFAIK this ticking is only heard when

PLAY SOUND

with multiple voices

Not with PLAY WAV or PLAY TONE


Volhout
Edited 2023-03-17 20:53 by Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3919
Posted: 10:56am 17 Mar 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  Make sure that any PAM8403 modules (or any digital amplifiers for that matter) that you are using have output inductors on them.


Can you point me at a picture of a "good" module, because either I'm rolling a 1 on my "recognise surface mount inductor" check, or none of them have one .

  Quote  I'm not saying that this is the case here, but it's something to bear in mind.


Given that the PicoGAME VGA 1.4 has the same click (though not "amplified" to the same extent) I don't think we can entirely blame PAM. Does the PicoGAME VGA have the power filter on the SD card that Peter mentioned above ?

I haven't had a chance to give the hardware another poke yet (i.e. try without the LCD/SD module attached) but I am still suspicious that this is specifically a PLAY SOUND issue, my lo-fi ears can't hear the same problem with PLAY WAV.

Peter, I've only executed it in my head but looking at the implementation of PLAY SOUND (Audio.c#1271-1296) it appears you always set sound_mode_{left|right}[channel] to nulltable first even if it was, for example, SineTable before and will be SineTable after the call. Is this code run in parallel with the actual playing ? in which case could their be a race-condition where you end up briefly "playing from the nulltable" and hence a click ? Or am I making s**t up; this is too close to the hardware for me to have any expertise.

Best wishes,

Tom
Edited 2023-03-17 21:09 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3919
Posted: 10:57am 17 Mar 2023
Copy link to clipboard 
Print this post

  Volhout said  AFAIK this ticking is only heard when

PLAY SOUND

with multiple voices

Not with PLAY WAV or PLAY TONE


"Snap!", except I think it also happens with a single voice too.

Best wishes,

Tom
Edited 2023-03-17 21:20 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5982
Posted: 11:36am 17 Mar 2023
Copy link to clipboard 
Print this post

I've just checked the PAM8403 and they claim that it's filterless. They then go on to say that for most applications (to reduce EMI above 1MHz) you should include a ferrite bead followed by a 220pF capacitor to ground on each output. So, "filterless" or not?

The latest PicoGAME VGA mini 6 has the SD card supply filter, as do the PicoGAME 1.4 and the PicoGAME  2.0.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8673
Posted: 12:29pm 17 Mar 2023
Copy link to clipboard 
Print this post

Play tone takes the duration you specify and  modifies it to an exact number of waves starting and ending at VCC/2 (approx) which is the resting level of the "DAC". Play sound can't do this because there can be up to 4 different waveforms with different frequencies all happening at once. This means that whenever you change one of the sounds there will be a discontinuity as the new waveform always starts again at VCC/2. This can create clicks. You can program round this by reducing the volume of the specific sound incrementally before you make a change. That will bring it back to VCC/2 ready for the new sound.

The SDcard is a different issue. Because we don't have a card detect the firmware polls the card every so often to determine if it has been removed. This is needed to reset ready for a new insertion. The polling only starts after the first use of the SD.

Regular clicking will be the Sdcard. A click on change of sound will be as above

Depending on the quality of the filter on the audio any clicks will be more or less apparent.
Edited 2023-03-17 22:30 by matherp
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1601
Posted: 12:06am 18 Mar 2023
Copy link to clipboard 
Print this post

I just tried the CMM2 playing the game and I can hear no clicks. That may be down to my Lo Fi ears though. I am presuming that the sound is done in the same way. Do you hear the clicks on the PicoMite VGA?

Terminate the input of the spare amplifier to 0v via a 10k resistor and connect it's  speaker output terminals together via a 100 ohm resistor. This should reduce the possibility of the spare amplifier becoming unstable, oscillating or motor boating, which could affect the other amplifier and maybe cause clicking. Add a volume control you may be over-driving the amplifier.

Can you connect the output of the filter to a computer speaker (with amplifier) or a pair of high impedance headphones to see if you can hear the clicks. If not, they may be getting into the amplifier via the power supply.

Connect the amplifier to an external power supply, say 3 AA cells, with the 0v connected together and see if you can hear the clicks. If not, you could try filtering the supply in the same way the SD card is done. Double the electrolytic. I would definitely put an electrolytic across the supply close to the amplifier anyway. There may not much you can do about filtering the SD card on the display board but you may be able to filter the supply to the whole display.

A quote from the link I put in the other post:
  Quote  I WILL DEFINITELY NOT RECOMMEND YOU TO BUILD THIS ON A BREADBOARD, THE DISTORTION RATES ARE HORRIBLE !!!

The amplifier does get good reviews, I think it's worth persevering with.

Bill
Keep safe. Live long and prosper.
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 708
Posted: 01:41am 18 Mar 2023
Copy link to clipboard 
Print this post

  matherp said  
This can create clicks. You can program round this by reducing the volume of the specific sound incrementally before you make a change.

IIRC ? ..... The volume of the specific sound can be reduced to 0 instantly ,
just so it is reduced to 0 between commands ( for less clicks ) .
my site
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3780
Posted: 06:47am 18 Mar 2023
Copy link to clipboard 
Print this post

Anything  that happens instantly on 4 non-synchronous signals will cause a disruption.
Even the lowering of volume, but definitly the start of new tones.
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3780
Posted: 06:50am 18 Mar 2023
Copy link to clipboard 
Print this post

The only solution would be more indepenent tone generators, in stead of a sound command that combines 4.

Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3919
Posted: 09:21am 18 Mar 2023
Copy link to clipboard 
Print this post

Hi folks,

Thanks for the input. Busy weekend of family stuff so not going to get a chance to try anything out until Sunday evening at the earliest.

Until then some quick comments/answers:

1. The same sound engine/technique on the CMM2 does not (as far as I can hear) click.

2. The PAM is not the problem (issue also occurs on the PicoMiteVGA for both me and @Volhout), though it and/or the sh**ty speaker do appear to make the issue worse - I have noted however that I am missing an electrolytic on my breadboard. I also need to rebuild the circuit with more soldered links and fewer iffy jumper leads and solderless breadboard connections.

3. Currently, if for example my engine is playing the same note for 4 beats it actually calls PLAY SOUND for that frequency 8 times, these "transitions/restarts" can be eliminated for little cost and may(?) improve the situation.

4. I am starting to look more kindly on the original two "buzzer" configuration, it certainly takes up less real-estate than the forest of resistors and capacitors that is growing otherwise.

Best wishes,

Tom
Edited 2023-03-18 19:42 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1900
Posted: 07:33am 19 Mar 2023
Copy link to clipboard 
Print this post

Play Sound entry in PicoMite 5.07.06 manual not quit right, VGA manual is correct.
'soundno' and 'channelno' duplicated and 'Type' missing.


PLAY SOUND soundno,
channelno, type [,frequency]
[,volume]

Play a series of sounds simultaneously on the audio output.
'soundno' is the sound number and can be from 1 to 4 allowing for four
simultaneous sounds on each channel. 'channelno' specifies the output
channel. It can be L (left speaker), R (right speaker) or B (both speakers)
'soundno' is the sound number and can be from 1 to 4 allowing for four
simultaneous sounds on each channel. 'channelno' specifies the output
channel. It can be L (left speaker), R (right speaker) or B (both speakers)
'frequency' is the frequency from 1 to 20000 (Hz) and it must be specified
except when type is O.
'volume' is optional and must be between 1 and 25. It defaults to 25
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1601
Posted: 01:48am 20 Mar 2023
Copy link to clipboard 
Print this post

  thwill said  I am missing an electrolytic on my breadboard

An electrolytic after the power switch with a 0.1uF as well would also be a good idea.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3919
Posted: 10:41am 20 Mar 2023
Copy link to clipboard 
Print this post

Hi folks,

I'm still struggling with this, both with ticking and hissing when using PLAY SOUND:

   https://www.youtube.com/watch?v=4fvh2d3T42U

1. It's not the SD card, it sounds the same with and without the LCD/SD module attached.
2. There is more hissing when running from the battery than from the Pico/USB.
3. I can "hear" the heartbeat LED flashing as a hiss.
4. The output from PLAY WAV is acceptable, no ticking and not significant hissing.

I'm looking to remove/reduce the tick and the hiss, I realise the former may be something that if completely fixable will require me to improve the software, but I'm guessing the latter is a matter of scattering capacitors/resistors/ferrite beads like confetti .

And no I haven't done, or understood everything that has been suggested, I'm even more out of my depth with analog than I am with digital electronics.

Here is my current schematic:



The low-pass filter is the original PicoMite one, I've also tried the one in the more recent PicoMite manuals (4.7mH/2.7nF/33nF/68nF) on solderless breadboard and it didn't seem any better .

What I'm planning to try next:

1. Try a soldered version of the improved filter.
2. Put both a 100uF electrolytic and a 0.1uF between power and ground on the main PicoGAME LCD after the battery switch - which I think is what @Turbo46 is saying ?
3. Update my music engine to remove redundant calls to PLAY SOUND when two consecutive "notes" are the same.

Any other specific suggestions are welcome,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 1 of 5    
Print this page
© JAQ Software 2024