audible pop when wave shield first turns on

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jbpm
 
Posts: 17
Joined: Thu Jun 05, 2014 3:58 pm

audible pop when wave shield first turns on

Post by jbpm »

I've got the wave shield working great in a project. I modified the 6 button code so it's working with a 4 button box. Everytime a button is pressed, a different .wav file plays.

Everything is working as it should. Only thing that's got me puzzled is the first time the wave shield plays an audio file, there is an audible pop from the speakers. It happens every time I first turn the power on. And it only happens when an audio file is about to be played. But once the first audio file is played, there will be no audible pop.

Any idea what would be causing this? I've tried having an audio file start playing right away (versus having one play when buttons are hit) and the same thing happens. At first I thought it might be because the wave shield is playing the .wav file at the same time it's still reading info from the SD card. But even if I wait a minute or so, the pop still happens.

Any thoughts on what could be causing this behavior?
Last edited by jbpm on Sun Aug 10, 2014 8:45 am, edited 1 time in total.

User avatar
logan42
 
Posts: 84
Joined: Wed Jan 08, 2014 9:58 pm

Re: audible pop when wave sheild first turns on

Post by logan42 »

the only thing i can think of is when the speaker is turning on it gets a little electricity going through it. kinda like when you plug a guitar into a amp you get some popping noises. i cant think of a way to rule this out or fix it. i only know about how speakers work and not the wave shield though.how loud is the noise?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: audible pop when wave sheild first turns on

Post by adafruit_support_bill »

When you first power up, the DAC output is at zero. But the zero point of the music waveform is at 1/2 scale. When you first play a file, the step transition from 0 to 1/2 scale will cause the pop.

User avatar
jbpm
 
Posts: 17
Joined: Thu Jun 05, 2014 3:58 pm

Re: audible pop when wave sheild first turns on

Post by jbpm »

Thanks for the replies. Since the pop is being caused by the DAC going from 0 to 1/2 scale, it would seem that there is nothing that can be done to get rid of it? I was thinking of creating a .wav file that is basically silent and having that automatically play once I turn the power on. The thought was if the .wav file was just silence, there would be no audio information to cause the pop. But it sounds like that wouldn't do it, as to even play a silent .wav file, the DAC would still need to go for 0 to 1/2 and cause a pop. Would there be some clever coding I could implement in my sketch that could have the DAC go smoothly from 0 to 1/2?

The pop is by no means obnoxiously loud, but it is loud enough to be heard.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: audible pop when wave shield first turns on

Post by adafruit_support_bill »

You could write some code to ramp up the DAC output over a period of a 100 ms or so to eliminate the pop.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: audible pop when wave shield first turns on

Post by pburgess »

Following the other #includes at the top of the sketch:

Code: Select all

#include "mcpDac.h"
At the start of setup():

Code: Select all

  for(int i=0; i<=512; i++) {
    mcpDacSend(i);
    delayMicroseconds(200);
  }
Can't say for certain this will fix it; the DAC/amp probably goes straight to 0 at power-up before this code even runs. But worth a try.

User avatar
jbpm
 
Posts: 17
Joined: Thu Jun 05, 2014 3:58 pm

Re: audible pop when wave shield first turns on

Post by jbpm »

When I add the #include "mcpDac.h" I get some errors. I checked and I do have the mcpDac.h in my documents, so not quite sure why I'm getting the errors. Here's what the errors are -

In file included from /Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:213,
from waveplayer4button.ino:10:
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/arduino/variants/standard/pins_arduino.h:40: error: expected unqualified-id before numeric constant
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/arduino/variants/standard/pins_arduino.h:41: error: expected unqualified-id before numeric constant
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/arduino/variants/standard/pins_arduino.h:42: error: expected unqualified-id before numeric constant
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/arduino/variants/standard/pins_arduino.h:43: error: expected unqualified-id before numeric constant

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: audible pop when wave shield first turns on

Post by pburgess »

Make this the -last- #include in the list.

User avatar
jbpm
 
Posts: 17
Joined: Thu Jun 05, 2014 3:58 pm

Re: audible pop when wave shield first turns on

Post by jbpm »

Strange. I have #include "mcpDac.h" as the last include, and I still get the error.

I can't figure out if this is an error with the Arduino sketch (don't think it is) or with the mcpDac.h C++ code.

User avatar
hiduino
 
Posts: 862
Joined: Sat Sep 01, 2012 7:05 pm

Re: audible pop when wave shield first turns on

Post by hiduino »

Try placing the #include "mcpDac.h" below this line.

Code: Select all

SdReader card; 

User avatar
jbpm
 
Posts: 17
Joined: Thu Jun 05, 2014 3:58 pm

Re: audible pop when wave shield first turns on

Post by jbpm »

aha. Placing the #include below SDReader seems to work! The sketch now compiles without getting an error. Will plug into the arduino tomorrow and see if the code actually fixes the audio pop.

Thanks hiduino. I'm curious to know why placing the #Include after the SDReader fixed the problem. Should I have gathered by the error that it was a SD card issue?

User avatar
jbpm
 
Posts: 17
Joined: Thu Jun 05, 2014 3:58 pm

Re: audible pop when wave shield first turns on

Post by jbpm »

Just tried the code on the Arduino, and unfortunately it did not fix the problem. I'm still getting an audio pop every first time I play an audio file.

User avatar
hiduino
 
Posts: 862
Joined: Sat Sep 01, 2012 7:05 pm

Re: audible pop when wave shield first turns on

Post by hiduino »

The DAC ramp up routine is missing the initialization code. So it really wasn't sending anything to the DAC. Also the mid level volume should be 2048 (half way mark for 12-bit sample) not 512 (is for a 10-bit sample).

Try this in your setup();

Code: Select all

  mcpDacInit();
  for(int i=0; i<=2048; i++) {
    mcpDacSend(i);
    delayMicroseconds(200);
  }
This seems to work fine. However, there is still the power up pop. I don't think we can do anything about that. That could be just the OpAmp powering up.

Edit: There is another pop after hitting the reset button. This is because if the DAC is already set to mid level and a reset occurs, then this ramp up will immediately start from zero level causing the pop. There is a way to detect a reset vs. power-on to avoid this reset pop, but that will require a bootloader modification.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: audible pop when wave shield first turns on

Post by pburgess »

missing the initialization code. [...] Also the mid level volume should be 2048
Thank you for spotting those! I just had a "herp-a-derp!" moment and came back to make corrections, glad to see you already took care of it.

User avatar
jbpm
 
Posts: 17
Joined: Thu Jun 05, 2014 3:58 pm

Re: audible pop when wave shield first turns on

Post by jbpm »

Adding the initialization code did the trick! When I power on the wave shield, I no longer get the pop I was getting before. This small bit of code has made my awesome project even better. Thank you very much for all your replies!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”