I am trying to play a wav file on an Arduino and control the volume of wav file based on analog inputs.
Specifically, my Arduino is connected to a microphone, wave shield, and speaker. The microphone acquires analog inputs based on the volume of the environment. I am trying to play audio files and adjust the output volume based on the analog measurements obtained from the microphone/ the environment.
So far I have tried to use the tone command (which would work if I didn't need to play audio files), incorporate a transistor, and utilized different configurations to the circuitry but I have not been able to control the volume of the wav file based on the analog inputs.
Any help or ideas would be overly welcomed.