jmac698
30th March 2011, 04:16
Hi,
I'm trying to write some analog video calibration software.
I need to measure the amplitude of a sinewave.
Your first thought might be to measure the peaks. This will never work. The true peak is most likely in between two samples, thus you have to interpolate. Considering I have to deal with noise, even guessing where the peak is is going to be hard. The peak is quite flat around that area, and noise could make it appear anywhere.
There is also the problem of potential clipping.
What I need is a way to measure average amplitude over a whole cycle.
The next idea is to divide the samples by a reference sinewave. This doesn't work too well, anyhow I would normalize the measured wave by finding the average (say, 126 in rec601 levels), then subract the average from each sample to bias it around 0. Now I have the problem of division by 0 or small numbers which will be incredibly inaccurate. I would get fancy by doing a scaled average where the greater the absolute different between the reference and measured, the more weight given to the average. I haven't figured out the right way to scale this. (maybe do it in log space?)
I could add the two sinewaves and measure the new phase, working backwards with an identiy I could get the amplitude. This seems promising to me.
a*sin x+b*cos x=sqrt{a^2+b^2}*sin(x+phi)
phi=sin-1(b/(a^2+b^2)
where a=1 and I'm trying to find b. I have a way to measure phi. (How would I solve something like 1.3=b/(1+b^2) ?)
Another way is to find the MSE between a reference and a measure and use the amplitude of the reference for the answer. Is this valid though, because of the scaling involved? It would give much more emphasis to the larger values.
Any ideas?
thanks
ps maybe I could measure the average of each half cycle and work backwards from the ideal area under the curve formula. Anyone know the area of a half cycle?
I'm trying to write some analog video calibration software.
I need to measure the amplitude of a sinewave.
Your first thought might be to measure the peaks. This will never work. The true peak is most likely in between two samples, thus you have to interpolate. Considering I have to deal with noise, even guessing where the peak is is going to be hard. The peak is quite flat around that area, and noise could make it appear anywhere.
There is also the problem of potential clipping.
What I need is a way to measure average amplitude over a whole cycle.
The next idea is to divide the samples by a reference sinewave. This doesn't work too well, anyhow I would normalize the measured wave by finding the average (say, 126 in rec601 levels), then subract the average from each sample to bias it around 0. Now I have the problem of division by 0 or small numbers which will be incredibly inaccurate. I would get fancy by doing a scaled average where the greater the absolute different between the reference and measured, the more weight given to the average. I haven't figured out the right way to scale this. (maybe do it in log space?)
I could add the two sinewaves and measure the new phase, working backwards with an identiy I could get the amplitude. This seems promising to me.
a*sin x+b*cos x=sqrt{a^2+b^2}*sin(x+phi)
phi=sin-1(b/(a^2+b^2)
where a=1 and I'm trying to find b. I have a way to measure phi. (How would I solve something like 1.3=b/(1+b^2) ?)
Another way is to find the MSE between a reference and a measure and use the amplitude of the reference for the answer. Is this valid though, because of the scaling involved? It would give much more emphasis to the larger values.
Any ideas?
thanks
ps maybe I could measure the average of each half cycle and work backwards from the ideal area under the curve formula. Anyone know the area of a half cycle?