#include <Arduino.h>
#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
TMRpcm tmrpcm;
void setup()
{
tmrpcm.speakerPin = 9;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin))
{
Serial.println('SD fail');
return;
}
tmrpcm.setVolume(5);
tmrpcm.play("audio.wav");
}
void loop()
{
// put your main code here, to run repeatedly:
}
The problem is that if I increase the volume of the potentiometer to more than a quarter, a very strong background noise appears and the music is no longer heard well. Audio files are in .wav format. I think that I should use an input filter in the amplifier, which will eliminate the background noise. For the amplifier I use a 12V, 2A source. Does anyone have an idea how I could solve the background noise problem?
I've never used TMRpcm but since the regular Arduino doesn't have a DAC (no true-analog output) it's actually PWM and it's putting-out a 5V PWM signal even with "silence".
You probably need a low-pass filter. Do you know the PWM frequency? "Full power" PWM can potentially do "bad things" to an audio amplifier.
And, I believe it's only 8-bits at up-to 32kHz so it's not exactly "high fidelity".
...Class D amplifiers are basically PWM too but it's usually very high frequency, way above the audio range and better filtered-out, usually with an LC filter.
Thanks for the reply. Unfortunately I don't know the pwm frequency. yes, is it a high-pitch whine. I will try to use a low pass filter to see if it has any results.