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);

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

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

% check for discontinuity
for i = 1:20
if (diff(i) != 90)

Please verify this logic is correct for discontinuity check.


*From:* <> on behalf of gm <>
*Sent:* Monday, January 29, 2018 1:29 AM
*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 ?


*From:* <> <> <> on behalf of gm <> <>
*Sent:* Saturday, January 27, 2018 5:20 PM
*To:* <>
*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 <>

dupswapdrop: music-dsp mailing list

Reply via email to