It work just fine with leds as outputs, doing simple things, like turning the led on when sound is detected but i am trying to complicate things a little bit.
For example i am trying to capture only loud sounds and make the output reactive after a ceratin loudness threshold is reached.
If you're getting an LED to come-on at some threshold, it seems like you're already there. Are you using a if-statement to turn on the LED at some sound threshold?
You are going to "capture" all sounds, but you can ignore quiet sounds.
How do i set the threshold in dB?
Of course, you'll have to disable the automatic gain control feature in that preamp chip. ;) I assume you can do that.
Practically speaking, you'll need to get an SPL meter, make some measurements, and calibrate it yourself. There's nothing tricky about the "measurements". Just send the ADC count to your serial monitor at a known SPL level and make note of it.
In theory you can do it with calculations if you have sensitivity specs for the microphone. For example, if you get 10mV @ 80 dB out of the mic, that's 1V@ 80dB with a preamp gain of 40dB (a gain of 100). If the signal goes to 2 Volts, that's 86dB. Half a volt would be 74dB. Usually the specs are not exact, so anything that measures SPL usually has to be calibrated with an already-calibrated SPL meter.
If you calibrate with an SPL meter you don't need to know the voltage, you just need an ADC count at a known dB SPL level to find a dB reference.
I assume you know how to calculate dB from a reference and an unknown level? (20Log(X/Ref) That's the dB difference... A ratio of 2:1 is a 6dB difference... You add (or subtract) that from the dB level that relates to your reference voltage or reference ADC count.
What Vref should i use?
5V... Since you can't feed the negative half of an AC signal into the Arduino, the input needs to be biased. Typically, you use a bias of 2.5V (half of the 5V range). I see the MAX chip has a 1.23V bias. Obviously, the reference has to be greater than the bias.
If you use a circuit that eliminates the negative half of the waveform (I use a peak detector circuit) then you can us a lower ADC reference.
How cand i find what are microphone's limitations?
Check the datasheet for the mic. The for information for a cheap mic (or an electret "module") will be limited. You can get detailed specs for good mics used for stage or studio. (But you still might need to calibrate with an SPL meter if you need accuracy.)