How to get standard positive and negative peak

Thank you very much for your time :smiley:
I recorded 3 seconds of audio at a sample speed of 48 kHz This means that there are 144,000 samples I'm confused about what to do :sob: :sob:

I use standard op-amp and Audacity can do this I want to know what is the Audacity formula?

You should get rid of the DC offset in the preamp. It is probably reducing your available dynamic range. A standard preamplifier has no significant DC offset, even if it is direct coupled.

However, as mentioned early in the thread, for an MCU analog input, the signal has to be biased at Vref/2. Do you have circuits to do that?

A link was provided, reply #9

No , i don't know about it

Then how is your preamp connected to the Arduino? You gave us a brief one sentence explanation before, it's not enough. A diagram is 1000000 times better.

There is no such thing as a "standard" preamp. So you have to give details if you need help.

You need something like described in reply #3.

In cases like this where the signal is intentionally biased (because the ADC can't read negative) you should simply subtract the bias (presumably 2047 or 2048).

Most WAV files are unbiased and use signed integers or signed floating point. The exception is 8-bit WAV files which are unsigned and biased. The software/drivers "knows" this so it gets played-back correctly through the audio DAC.

Audacity's averaging algorithm can work but it's intended to remove a defect. And since some real world waveforms are asymmetrical, offset removal can sometimes introduce an offset (where silence is not zero). High-pass filtering (usually at 20Hz or less) will also take-out the DC bias since DC is "zero Hz", but that can leave a "click" at the beginning.

My point, if the offset is not 1/2 of the reference, performance suffers. Information about the input circuit is crucial, and not forthcoming at this point.

Problems would probably be easier to solve there, than in software.

Hi
I tried different methods but it did not work only i could hear my voice
Is there a code or resource for this?

can you give me an example ?

Here's an example:
https://www.theorycircuit.com/wp-content/uploads/2016/07/mic-schematic.jpg
This circuit is inherently biased to VCC/2 which is exactly mid range for an ADC if 0-VCC is its input range.

And that is getting you values from 0 to -1. That means that, before you subtracted 1, your values were 0 to 1. You got those by dividing by 2047.5. That means your original values were roughly between 0 and 2047.5. That's not the range 0 to 4095.

When there is no sound input, what values are you getting from the ADC? If it isn't around 2048 then something is wrong with the input electronics.

I misinterpreted it the first time. I looked at the formula and the chart, and noticed the -1. The input DC offset before subtracting one, is 1/2, the output you would expect from a properly working ADC.
The graph has a range of -1 to 1, so the data fits nicely in the range of 0 to 1, which as the other person pointed out, is normal and expected.

The question of whether the scale is correct could be tested by using
ADC Value - 2047
and increasing the amplitude of the test signal remains. That is if MatLab expects a signed number with an offset of zero. But I would bet on "ok".

The desired format depends on the application for example a DAC is also a linear device and so in order to drive something in both polarities, depends on support circuits that interpret negative values by subtracting a mid range offset. Sometimes, that is just an AC coupling capacitor.

1 Like

This is my adc value in the text file
record3.zip (13.1 KB)

I recorded my voice short. Using this algorithm, you can convert Adc value to audio file in MatLab.

data = (ADC_value/2047.5) - 1;

file_name = 'data.wav';
audiowrite(file_name,data,48000);

The audio file I made with it
myvoice.zip (11.8 KB)

In Matlab with "ADC_value" as a vector of samples, just subtract the mean of the vector to center it about zero and scale by dividing by the ADC range:

data = (ADC_value-mean(ADC_value))/2047.5;

file_name = 'data.wav';
audiowrite(file_name,data,48000);

1 Like

it works thank you soooo much

Is there a way to convert adc values to regular instances, I mean normalization but real time?

Other post/duplicate LOCKED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

What kind of normalization? If you want to remove the DC offset to produce a bipolar (signed) representation, just subtract the ADC mid range value. That is easy to do in real time.

Outside of MatLab, it doesn't make sense to use a mean value because you already know what it is, because the hardware fixes it to 1/2 the input range. That is, unless you have some variant hardware but I asked you in reply #29 about that and you didn't respond.