The problem I see is that your sine wave needs to have a precise amplitude for the arcsine.
I don't understand your application so I don't know if this is the case.


Am 09.03.2018 um 19:58 schrieb Benny Alexandar:
Hi GM,
Instead of finding Hilbert transform, I tried with just finding the angle between samples
of a fixed frequency sine wave.
I tried to create a sine wave of  frequency x[n] = sin ( 2 * pi * 1/4 * n), and tried calculating the angle between samples, it should be 90 degree. This also can be used to detect any discontinuity in the signal.
Below is the octave code which I tried.

One cycle of sine wave consists of 4 samples, two +ve and two -ve.

% generate the sine wave of frequency 1/4
for i = 1 : 20
   x(i) = sin( 2 * pi * ( 1 / 4) * i);
end

% find the angle between samples in degrees.
 for i = 1:20
    ang(i)  =  asin( x(i) ) * (180 / pi);
 end

% find the absolute difference between angles
for i = 1:20
 diff(i) =  abs( ang( i + 1 ) - ang( i ));
end

% check for discontinuity
for i = 1:20
if (diff(i) != 90)
  disp("discontinuity")
endif
end


Please verify this logic is correct for discontinuity check.

-ben



------------------------------------------------------------------------
*From:* music-dsp-boun...@music.columbia.edu <music-dsp-boun...@music.columbia.edu> on behalf of gm <g...@voxangelica.net>
*Sent:* Monday, January 29, 2018 1:29 AM
*To:* music-dsp@music.columbia.edu
*Subject:* Re: [music-dsp] Clock drift and compensation

diff gives you the phase step per sample,
basically the frequency.

However the phase will jump back to zero periodically when the phase exceeds 360°
(when it wraps around) in this case diff will get you a wrong result.

So you need to "unwrap" the phase or the phase difference, for example:


diff = phase_new - phase_old
if phase_old > Pi and phase_new < Pi then diff += 2Pi

or similar.


Am 28.01.2018 um 17:19 schrieb Benny Alexandar:
Hi GM,

>> HT -> Atan2 -> differenciate -> unwrap
Could you please explain how to find the drift using HT,

HT -> gives real(I) & imaginary (Q) components of real signal
Atan2 -> the phase of an I Q signal
diff-> gives what ?
unwrap ?

-ben


------------------------------------------------------------------------
*From:* music-dsp-boun...@music.columbia.edu <mailto:music-dsp-boun...@music.columbia.edu> <music-dsp-boun...@music.columbia.edu> <mailto:music-dsp-boun...@music.columbia.edu> on behalf of gm <g...@voxangelica.net> <mailto:g...@voxangelica.net>
*Sent:* Saturday, January 27, 2018 5:20 PM
*To:* music-dsp@music.columbia.edu <mailto:music-dsp@music.columbia.edu>
*Subject:* Re: [music-dsp] Clock drift and compensation

I don't understand your project at all so not sure if this is helpful,
probably not,
but you can calculate the drift or instantanous frequency of a sine wave
on a per sample basis
using a Hilbert transform
HT -> Atan2 -> differenciate -> unwrap
_______________________________________________
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu <mailto:music-dsp@music.columbia.edu>
https://lists.columbia.edu/mailman/listinfo/music-dsp



_______________________________________________
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Reply via email to