Playing wav file from microSD through an amplifier

Hi,
I have a few wav files loaded onto a microsd card and am trying to play these files through a speaker but have ALOT of fundamental questions.

The microSD breakout board im using is : MicroSD card breakout board+ : ID 254 : $7.50 : Adafruit Industries, Unique & fun DIY electronics and kits
It comunicates with the arduino through SPI and I have connected GND to ground, 5V to 5V, CLK to pin 13, DO to pin 12, DI to pin 11, and CS to pin 10.

Im using the tmrpcm library and code from How to play WAV audio files with Arduino Uno and MicroSD card - Maks Surguy's blog on Technology Innovation, IoT, Design and Code to play my audio files.

When I connect the speaker to pin 9, i hear some sounds but its very noisy. Now I'm trying to use a class d amplifier: https://www.sparkfun.com/products/11044 but I'm not sure how to hook up the differential signals. Do i put the IN+ to pin 9 or the MOSI pin(11?)

Does the tmrpcm library take care of the PWM? From pin 9 my signal is still digital right? Do i need a SPI DAC and then communicate with the mono amp?

Any help will be greatly appreciated! I'm very confused about this!!!

If your amplifier has a differential input then ground the -Ve one and feed the positive one to pin 9.

Never connect a speaker directly to an output pin, it will draw too much current and potentially damage the pin.

You might need to add a 1K seriese resistor between the pin 9 and the amplifier input and then put a 10nF capacitor from the input to ground. Yes the signal is digital at pin9 and the resistor and capacitor act as a low pass filter or restoration filter as a digital signal like this might upset the amplifier.

Grumpy_Mike:
You might need to add a 1K seriese resistor between the pin 9 and the amplifier input and then put a 10nF capacitor from the input to ground.

How do you come up with the numbers for resistor and cap? Do I need to keep the sampling f of audio file in consideration for designing the RC filter? What determines the cutoff frequency?

What determines the cutoff frequency?

The value of the R and C.

How do you come up with the numbers for resistor and cap?

Calculation.

Do I need to keep the sampling f of audio file in consideration for designing the RC filter?

Yes. But more important is the PWM frequency, you are trying to remove this. This should be at least twice as high as your sample frequency and preferably higher.

This link talks about an RC filter:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Note that a simple RC filter is not very good. The cut off frequency is perhaps better named as the roll off frequency. You still get plenty of signal through at signals higher than the cut off frequency. Filters is a vast and complex subject. It would fit over several books, it is not amenable to a full discourse in a forum answer.