There is FUNDAMENTAL flaw in the OP's design. The AD returns the number relating to the volume envelope of the sound. The volume value peak consists of many different frequency peaks, both positive and negative occurring at the identical time. You are seeing the the arithmetic sum of those peaks. If you were dealing with a single note played on a single violin string, then the results of the AD would be the absolute value for that note. Playing two strings and two notes will be summed by AD conversion.
Paul
As it was pointed out in reply #2... however it remains unclear what purpose the peak measurements are for, so it's unclear whether peak or average envelope detection is appropriate.
Hi
This is my main voice with this formula real time
/* (ADC-Value /ADC_Rang) -1 */
double data = (Sample / 4095) -1;

But I need something like this
I don't know what algorithm to use
First off it is not an algorithm but a simple equation. Just subtract the reading from the DC bias reading, and then divide the result by the DC bias reading.
Second, you need to put a DC bias of the mid point of your A/D range by a pull up and pull down resistor between the analogue input and each powered rail. Also you need to AC couple your audio into this. That is connect it to the A/D through a series capacitor.
Anything else is a total waste of time. You seem to be ignoring this fact.
Excuse me can you give me sample example for this " Just subtract the reading from the DC bias reading, and then divide the result by the DC bias reading. "
Results = (ADC_Value - average(ADC_Value )) /4095 ;
Do you mean that?
No.
Results = (ADC_Value - 2048) / 2048 ;
Now that you have the audio in floating point format, what are you doing with it? Most Arduino don't have the processing power to use those efficiently.
I need it for audio processing
Have you noticed the negative side is a mirror image of the positive side of the sound signal? Are you getting the sound from an electret microphone? If so, you will notice the microphone circuit always has a bias voltage. This is so you will get your positive and negative signal and they are mirror images of each other.
If you are going to want a microphone that will give you an original signal that is + and - you will need a dynamic or perhaps a crystal microphone.
Paul
Hi
I use this microphone and preamplifier "MAX4466" and connect it to the ADC analog input
and I use 10K pull up and pull down resistors
I told you,
The limited signal processing that you can do, is most certainly done using integer math.
Also, I think you have ignored the important hardware issues mentioned in reply #47.
can you give me an example for integer ?
int foo;
Excuse me ?
do you mean integer sample rate?
Let's get your feedback on reply #47 first...
That has an electret microphone.
Paul
Yes, we need to see a wiring diagram that includes the module and the Due, all the wires and components. Show us how your "10k pull up and down resistors" are wired.



