How can i get audio samples from Analog Input

Conceptually it's pretty simple. The Audacity website has a little introduction to digital audio.

I've made a few audio activated lighting effects. My World's Simplest Audio Effect might give you some ideas, It reads the audio data in a fast-loop* and saves the peaks (ignoring most of the readings).

There is also a schematic for the bias circuit.

Of course you have to record and play-back at the same sample rate and bit depth (or you have to convert & scale).

I've never used the STM32 but it's probably a better choice. The 10-bit Arduino ADC is not a standard audio bit depth so that would normally be scaled up to 16-bits or down to 8-bits. Plus, the Uno doesn't have a DAC and it doesn't have enough built-in memory for an audio recorder (44,100 samples per second, etc.).

Normally the bias should be subtracted-out, but if your DAC doesn't go negative it will have to be biased again, and then the DC can be filtered-out with a capacitor. (8-bit WAV files use unsigned data so they are "biased", but that's only important if you're using WAV files.)

  • With the Uno looping "as fast as possible", it's not fast enough for digital audio. I believe it can loop faster if you write assembly code but according to the datasheet, the ADC will loose accuracy if you sample fast-enough for high-quality audio. (It's only 10-bits to begin with.)