Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:01 25 Nov 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 : [MicoMite] Sound issue

     Page 1 of 2    
Author Message
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:53am 29 Sep 2023
Copy link to clipboard 
Print this post

Hi!

I added sounds to my 1D-pong-like game, and I have a strange behaviour: there is a bad 'clac' at the end of each sound played.

Any idea what can cause that? Note they are ok when played alone from command line...

The code is visible here.

Thanks,
Frédéric
Frédéric
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1113
Posted: 08:49am 29 Sep 2023
Copy link to clipboard 
Print this post

  fmafma said  Hi!

I added sounds to my 1D-pong-like game, and I have a strange behaviour: there is a bad 'clac' at the end of each sound played.

Any idea what can cause that? Note they are ok when played alone from command line...

The code is visible here.

Thanks,
Frédéric

You use

CONST SND_START = "start.wav"
CONST SND_BUMP  = "bump.wav"
CONST SND_LOOSE = "loose.wav"
CONST SND_WIN   = "win.wav"

and PLAY WAV to play them ..
that is fine, so far but we dont know, how does the wav Files look ...
Maybe you can use an Audio Editor and "fade out" the end of the Waves so that they all end on 0
Edited 2023-09-29 18:52 by Martin H.
'no comment
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 10:25am 29 Sep 2023
Copy link to clipboard 
Print this post

The files are ok, I checked with Audacity. The final 'plop' occurs after the end of the files, but only when played from the game code. The sound fine if I play them from the command line...

Here is the start.wav file: start.zip
Edited 2023-09-29 20:25 by fmafma
Frédéric
 
pwillard
Senior Member

Joined: 07/06/2022
Location: United States
Posts: 292
Posted: 03:22pm 29 Sep 2023
Copy link to clipboard 
Print this post

Abrupt Clicks not part of the source media are often related to DC coupling in the audio signal.

"...any DC present on the connections can potentially cause ... loud clicks or pops when making or breaking connections"
Edited 2023-09-30 01:22 by pwillard
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 03:38pm 29 Sep 2023
Copy link to clipboard 
Print this post

In this case, it should always occur?

And there is a passive filter on the PWM outputs (with 22uF in serie)...
Frédéric
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 03:52pm 29 Sep 2023
Copy link to clipboard 
Print this post

Are you starting a new sound before the old one has finished playing?
Visit Vegipete's *Mite Library for cool programs.
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 04:47pm 29 Sep 2023
Copy link to clipboard 
Print this post

Nope.

Could it be related to the WS2812 bitbanging? I refresh the LED as fast as I can in my main loop...
Frédéric
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9110
Posted: 05:20pm 29 Sep 2023
Copy link to clipboard 
Print this post

  Quote  Could it be related to the WS2812 bitbanging? I refresh the LED as fast as I can in my main loop...


Its a wonder it plays at all. WS2812 has to disable all interrupts while it sends the data to meet the timing constraints which could cause all sorts of issues with audio which relies on a regular interrupt of 44100Hx or greater
 
amigawizard

Regular Member

Joined: 15/08/2023
Location: Australia
Posts: 43
Posted: 05:35pm 29 Sep 2023
Copy link to clipboard 
Print this post

,
       Hi  

   Could it be related to the WS2812 bitbanging? I refresh the LED as fast as I can in my main loop...


 
  Quote       Could it be related to the WS2812 bitbanging?


     " Rem out  the line  with   bitbang!  to see if it  fix`s  "

        Wayne !
,
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 05:35pm 29 Sep 2023
Copy link to clipboard 
Print this post

Ok, I understand!

A solution is to re-implement the WS2812 protocole using PIO and DMA... Has anyone already done it?
Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:09am 30 Sep 2023
Copy link to clipboard 
Print this post

  amigawizard said  Rem out  the line  with   bitbang!  to see if it  fix`s

Same without the BITBANG! So, this is not the problem...

Strangely, the plop only occurs after 3 or 4 sound playing, not right at the begining...
Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:13am 30 Sep 2023
Copy link to clipboard 
Print this post

Mmm, in fact, the plop now also occurs when played from command-line... Even when restarting the board...

I'm puzzled!

I'll try to play the sounds from drive A:, instead of SD card...
Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:17am 30 Sep 2023
Copy link to clipboard 
Print this post

  fmafma said  I'll try to play the sounds from drive A:, instead of SD card...

It's even worse!!! From drive A:, I can ear some small ticks during the sound playing, and the final plop!

The problem occurs on my own board, and on the Maker Pi Pico board.
Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 06:53am 10 Oct 2023
Copy link to clipboard 
Print this post

I still have a lot of troubles with the sound output. I connected my board to a little amplifier module based on a PAM8403, and I get horrible noises. I thought it was an issue with my power supply, but even powered from a PowerBank, I can ear the same noises.

I hooked up my board output to my PC sound card: here too, I can hear noises, but a little bit less. Here is a capture of the analyse from Audacity.

Any idea where the 280Hz noise (and all harmonics) can come from?


Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 11:19am 19 Jun 2024
Copy link to clipboard 
Print this post

Hi!

I rebooted my project, and I still have issues with sound.

I switched to a XPT8871-based amplifier, and I still get the plop at the end of the sounds.

But I noticed something weird: I have 250mV DC on the speakers output! So, my tiny speakers are burning hot (but they are still working, even after a entire day playing with the game for a public event)!

I think there is a problem with the chip used, in combination with the PWM output.

What kind of amplifier do you suggest? I need one which can be powered from 5V...

Thanks,
Edited 2024-06-19 22:13 by fmafma
Frédéric
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 12:55pm 19 Jun 2024
Copy link to clipboard 
Print this post

250mV is certainly an excessive offset. With no input both output pins should be close to half Vcc, measured to Gnd.

Things to try:-
A 0.47µF capacitor in series with the input, in case the onboard one is leaky.
Ensure there is no DC path to ground connected to either of the output pins.
Last resort is a 470µF capacitor in series with the speaker to block the DC. Positive end to whichever of the two output pins is more positive.
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 12:59pm 19 Jun 2024
Copy link to clipboard 
Print this post

There are already capacitors in the low-pass filter outputs, and I don't have any DC offset at the amplifier input.

I will try your suggestion, and add capacitors on the spekaers outputs...

Thanks!
Frédéric
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4223
Posted: 01:48pm 19 Jun 2024
Copy link to clipboard 
Print this post

Hi Frederic,

When you use the PWM outputs, they carry DC. The filter removes the PWM frequency, but not the DC. You need a capacitor between the output and the amplifier input.

Some audio amplifiers look like dual channel, but are in fact mono channel bridge amplifers. The loudspeaker must be connected between the outputs, and there could be DC on the output, but when it is on both outputs, it is not on the loudspeaker. The XP8871 is in fact a mono amplifier.

When there is noise from the PWM outputs, it can be from the power supply ON the pico board itself, and it's frequency and level is changing with the current draw from 3.3V . We solve it by using a linear regulator that bypasses the 3.3V switching regulator (in=Vsys, GND, out=3V3) and put 3V3_enable=low.

Regards,

Volhout
Edited 2024-06-19 23:54 by Volhout
PicomiteVGA PETSCII ROBOTS
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 04:34pm 19 Jun 2024
Copy link to clipboard 
Print this post

Mmm, I think there is something wrong with my design: I don't have any DC at the output of the filter (as I have a capacitor in serie), but I still have the PWM frequency!!!
Edited 2024-06-20 02:35 by fmafma
Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:33am 20 Jun 2024
Copy link to clipboard 
Print this post

What 4.7mH SMD inductor do you suggest?
Frédéric
 
     Page 1 of 2    
Print this page
© JAQ Software 2024