Re: [music-dsp] Clock drift and compensation

2018-03-09 Thread Benny Alexandar
Hi GM,

My application is to capture an analog sine tone  through PC sound card and 
check for discontinuity, glitch, audio gap, attenuation etc.

Please suggest any other reliable methods for this analysis.

-ben

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


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<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: Monday, January 29, 2018 1:29 AM
To: music-dsp@music.columbia.edu<mailto: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

Re: [music-dsp] Clock drift and compensation

2018-03-09 Thread Ethan Duni
Hi ben

You don't need to evaluate the asin() - it's piecewise monotonic and
symmetrical, so you can get the same comparison directly in the signal
domain.

Specifically, notice that x(n) = sin(2*pi*(1/4)*n) = [...0,1,0,-1,...]. So
you get the same result just by checking ( abs( x[n] - x[n-1] ) == 1 )

Ethan

On Fri, Mar 9, 2018 at 10:58 AM, Benny Alexandar <ben.a...@outlook.com>
wrote:

> 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-bounces@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 <music-dsp-bounces@music.
> columbia.edu> <music-dsp-boun...@music.columbia.edu> on behalf of gm
> <g...@voxangelica.net> <g...@voxangelica.net>
> *Sent:* Saturday, January 27, 2018 5:20 PM
> *To:* 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
> 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
>
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Clock drift and compensation

2018-03-09 Thread gm
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

Re: [music-dsp] Clock drift and compensation

2018-03-09 Thread 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

Re: [music-dsp] Clock drift and compensation

2018-02-05 Thread STEFFAN DIEDRICHSEN


> On 05.02.2018|KW6, at 18:20, Benny Alexandar <ben.a...@outlook.com> wrote:
> 
> Hi Robert,
> 
> Yes, I need to do ASRC, and the challenge is how to estimate the drift 
> and correct it. 
> 
> As I mentioned in the earlier attached figure, DSP is slave and tuner chip 
> feeds the baseband samples and is the master.
> Now the question is where to do the timestamping for correctly estimate the 
> drift.
> The system is an embedded platform having a tuner chip and DSP chip, both 
> have independent oscillators ( Xtal)  for providing the clock. 

Not a very clever design. 



> So my question is how to timestamp the audio data.

You don’t. 


> After channel decoder the compressed audio will have variable decoding times 
> based on audio content. So this is not a good place to timestamp as it is 
> very jittery. 

The most basic implementation would be using a buffering of the decoded audio 
(input tank) and a double buffer for the audio output (output tank). At every 
output request, you see how much input samples have been generated so far.
If you average this over many output request, you have the sample rate ratio 
and you can compute a sample rate conversion. The  SRC4193 form TI does it in 
hardware, the data sheet describes it a bit. 

Best,

Steffan 



> 
> Suppose every digital radio transmission frame duration T seconds  
> corresponds to T seconds of audio, can I timestamp the 
> baseband RF IQ samples when it arrives at the DSP ?   After demodulation and 
> audio decoder calculate the max delay it can 
> have for worst case scenarios, and add that as target delay before playing 
> out. Then while playing out each audio period 
> read the current time, the difference of current time - ( RF packet arrival 
> time + Target Delay) should be ideally zero,
> if audio plays out at the same rate as transmission of audio,. 
> 
> -ben
> 
> 
> From: music-dsp-boun...@music.columbia.edu 
> <music-dsp-boun...@music.columbia.edu> on behalf of robert bristow-johnson 
> <r...@audioimagination.com>
> Sent: Monday, February 5, 2018 1:01 PM
> To: music-dsp@music.columbia.edu
> Subject: Re: [music-dsp] Clock drift and compensation
>  
> 
> Ben, can you confirm that what you want to do is Asynchronous Sample 
> Rate Conversion (ASRC)?  this is what Steffan is talking about and what 
> it looked like you were looking for in your first post.
> 
> If ASRC is what you wanna do, that is a combination of the SRC task 
> (like what is done to a sound file when you change the sample rate of 
> it) and servo systems like you get in control theory, like what is done 
> in a phase-lock loop (like hurrying up or slowing down based on the 
> delay).  If you wanna write your own code to do this, it's about those 
> two general DSP and digital control problems.  you will need to be able 
> to read a fast system clock (like what profilers read) to do this really 
> well.
> 
> r b-j
> 
> On 1/28/18 1:16 PM, STEFFAN DIEDRICHSEN wrote:
> > Actually, there are SRC chips available from Texas Instruments, just 
> > take look at their website. They don’t cost too much and are found in 
> > countless digital mixing consoles.
> >
> > Best,
> >
> > Steffan
> >
> > Von meinem iPhone gesendet
> >
> >
> >
> > Von meinem iPhone gesendet
> > Am 28.01.2018 um 17:19 schrieb Benny Alexandar <ben.a...@outlook.com 
> > <mailto:ben.a...@outlook.com <mailto:ben.a...@outlook.com>>>:
> >
> >> 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 
> >> <mailto:music-dsp-boun...@music.columbia.edu>> 
> >> <music-dsp-boun...@music.columbia.edu 
> >> <mailto:music-dsp-boun...@music.columbia.edu 
> >> <mailto:music-dsp-boun...@music.columbia.edu>>> on behalf of gm 
> >> <g...@voxangelica.net <mailto: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 
> >> <mailto:music-dsp@music.columbia.edu>>
> >>

Re: [music-dsp] Clock drift and compensation

2018-02-05 Thread Eric Brombaugh
I've done a few different systems similar to what you're describing - a 
radio front-end tuner that generates baseband I & Q at audio rates 
that's then further processed by a DSP to extract true audio.


Normally what I do is slave the DSP rate to the tuner audio rate. That's 
usually possible since the data from the tuner is in I2S format and my 
DSP's I2S port can act as a slave. All subsequent processing happens at 
rates derived from the tuner's sample rate, and the audio output DAC is 
also running at that rate.


If your system architecture doesn't support running everything from the 
tuner's sample rate then you will need an ASRC as discussed earlier. 
Depending on which DSP you're using you may find that there is an ASRC 
co-processor already available. Many TI and ADI DSPs include this as an 
IP core you can access. Otherwise you'll have to code it up yourself. 
These aren't too hard to do - I have built them using a buffer depth 
measurement as the observable. Just maintain a short input buffer and 
servo techniques to keep the read pointer trailing the write pointer by 
a certain amount. Fairly simple polyphase resampling such as described 
by JOS works well and can maintain an SNR of 70dB or better which is 
often sufficient for radio applications where noise is generally pretty 
high anyway.


Eric

On 02/05/2018 10:20 AM, Benny Alexandar wrote:

Hi Robert,

Yes, I need to do ASRC, and the challenge is how to estimate the drift
and correct it.

As I mentioned in the earlier attached figure, DSP is slave and tuner 
chip feeds the baseband samples and is the master.
Now the question is where to do the timestamping for correctly estimate 
the drift.
The system is an embedded platform having a tuner chip and DSP chip, 
both have independent oscillators ( Xtal)  for providing the clock.
So my question is how to timestamp the audio data. After channel decoder 
the compressed audio will have variable decoding times
based on audio content. So this is not a good place to timestamp as it 
is very jittery.


Suppose every digital radio transmission frame duration T seconds  
corresponds to T seconds of audio, can I timestamp the
baseband RF IQ samples when it arrives at the DSP ?   After demodulation 
and audio decoder calculate the max delay it can
have for worst case scenarios, and add that as target delay before 
playing out. Then while playing out each audio period
read the current time, the difference of current time - ( RF packet 
arrival time + Target Delay) should be ideally zero,

if audio plays out at the same rate as transmission of audio,.

-ben

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



Re: [music-dsp] Clock drift and compensation

2018-02-05 Thread Benny Alexandar
Hi Robert,

Yes, I need to do ASRC, and the challenge is how to estimate the drift
and correct it.

As I mentioned in the earlier attached figure, DSP is slave and tuner chip 
feeds the baseband samples and is the master.
Now the question is where to do the timestamping for correctly estimate the 
drift.
The system is an embedded platform having a tuner chip and DSP chip, both have 
independent oscillators ( Xtal)  for providing the clock.
So my question is how to timestamp the audio data. After channel decoder the 
compressed audio will have variable decoding times
based on audio content. So this is not a good place to timestamp as it is very 
jittery.

Suppose every digital radio transmission frame duration T seconds  corresponds 
to T seconds of audio, can I timestamp the
baseband RF IQ samples when it arrives at the DSP ?   After demodulation and 
audio decoder calculate the max delay it can
have for worst case scenarios, and add that as target delay before playing out. 
Then while playing out each audio period
read the current time, the difference of current time - ( RF packet arrival 
time + Target Delay) should be ideally zero,
if audio plays out at the same rate as transmission of audio,.

-ben



From: music-dsp-boun...@music.columbia.edu 
<music-dsp-boun...@music.columbia.edu> on behalf of robert bristow-johnson 
<r...@audioimagination.com>
Sent: Monday, February 5, 2018 1:01 PM
To: music-dsp@music.columbia.edu
Subject: Re: [music-dsp] Clock drift and compensation


Ben, can you confirm that what you want to do is Asynchronous Sample
Rate Conversion (ASRC)?  this is what Steffan is talking about and what
it looked like you were looking for in your first post.

If ASRC is what you wanna do, that is a combination of the SRC task
(like what is done to a sound file when you change the sample rate of
it) and servo systems like you get in control theory, like what is done
in a phase-lock loop (like hurrying up or slowing down based on the
delay).  If you wanna write your own code to do this, it's about those
two general DSP and digital control problems.  you will need to be able
to read a fast system clock (like what profilers read) to do this really
well.

r b-j

On 1/28/18 1:16 PM, STEFFAN DIEDRICHSEN wrote:
> Actually, there are SRC chips available from Texas Instruments, just
> take look at their website. They don’t cost too much and are found in
> countless digital mixing consoles.
>
> Best,
>
> Steffan
>
> Von meinem iPhone gesendet
>
>
>
> Von meinem iPhone gesendet
> Am 28.01.2018 um 17:19 schrieb Benny Alexandar <ben.a...@outlook.com
> <mailto:ben.a...@outlook.com>>:
>
>> 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 <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


--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



___
dupswapdrop: music-dsp mailing list
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

Re: [music-dsp] Clock drift and compensation

2018-02-04 Thread robert bristow-johnson


Ben, can you confirm that what you want to do is Asynchronous Sample 
Rate Conversion (ASRC)?  this is what Steffan is talking about and what 
it looked like you were looking for in your first post.


If ASRC is what you wanna do, that is a combination of the SRC task 
(like what is done to a sound file when you change the sample rate of 
it) and servo systems like you get in control theory, like what is done 
in a phase-lock loop (like hurrying up or slowing down based on the 
delay).  If you wanna write your own code to do this, it's about those 
two general DSP and digital control problems.  you will need to be able 
to read a fast system clock (like what profilers read) to do this really 
well.


r b-j

On 1/28/18 1:16 PM, STEFFAN DIEDRICHSEN wrote:
Actually, there are SRC chips available from Texas Instruments, just 
take look at their website. They don’t cost too much and are found in 
countless digital mixing consoles.


Best,

Steffan

Von meinem iPhone gesendet



Von meinem iPhone gesendet
Am 28.01.2018 um 17:19 schrieb Benny Alexandar <ben.a...@outlook.com 
<mailto:ben.a...@outlook.com>>:



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



--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



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

Re: [music-dsp] Clock drift and compensation

2018-01-29 Thread Vladimir Pantelic
you have two unknowns, the frequency of the sampled signal and the difference in 
sample rate between sender and receiver. with no further information given, you 
can only assume one and determine the other based on it.




On 01/29/2018 06:27 PM, Benny Alexandar wrote:

Hi GM,

Thanks for the suggestion. Yes, it should work for sine tone kind of signals.

I have this doubt on sampling and drift.

  - Suppose transmitter is sampling a sine tone say  (Fin) 1KHz at 8kHZ (Fs) 
sample rate.

This means 8 samples should correspond to one cycle of 1 kHz.

- Receiver is sampling at 7.999 kHz  because of drift in crystal,
but I'm thinking my receiver is having a sample rate of 8kHz and takes 8 samples 
for one cycle.

which gives  999.875 Hz and not 1kHz.

So, how to detect this drift and take only that many samples for the 
corresponding receiver sample rate.

in this case 7.999 samples corresponds to 1 kHz.

-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



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



Re: [music-dsp] Clock drift and compensation

2018-01-29 Thread Benny Alexandar
Hi GM,

Thanks for the suggestion. Yes, it should work for sine tone kind of signals.

I have this doubt on sampling and drift.

 - Suppose transmitter is sampling a sine tone say  (Fin) 1KHz at 8kHZ (Fs) 
sample rate.
This means 8 samples should correspond to one cycle of 1 kHz.

- Receiver is sampling at 7.999 kHz  because of drift in crystal,
but I'm thinking my receiver is having a sample rate of 8kHz and takes 8 
samples for one cycle.
which gives  999.875 Hz and not 1kHz.

So, how to detect this drift and take only that many samples for the 
corresponding receiver sample rate.
in this case 7.999 samples corresponds to 1 kHz.

-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

Re: [music-dsp] Clock drift and compensation

2018-01-28 Thread gm

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 
<music-dsp-boun...@music.columbia.edu> on behalf of gm 
<g...@voxangelica.net>

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

Re: [music-dsp] Clock drift and compensation

2018-01-28 Thread STEFFAN DIEDRICHSEN
Actually, there are SRC chips available from Texas Instruments, just take look 
at their website. They don’t cost too much and are found in countless digital 
mixing consoles. 

Best,

Steffan

Von meinem iPhone gesendet



Von meinem iPhone gesendet
> Am 28.01.2018 um 17:19 schrieb Benny Alexandar <ben.a...@outlook.com>:
> 
> 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 
> <music-dsp-boun...@music.columbia.edu> on behalf of gm <g...@voxangelica.net>
> Sent: Saturday, January 27, 2018 5:20 PM
> To: 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
> 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
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Clock drift and compensation

2018-01-28 Thread 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 
<music-dsp-boun...@music.columbia.edu> on behalf of gm <g...@voxangelica.net>
Sent: Saturday, January 27, 2018 5:20 PM
To: 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
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

Re: [music-dsp] Clock drift and compensation

2018-01-27 Thread gm


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
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] Clock drift and compensation

2018-01-25 Thread Benny Alexandar
Hi,

Apparently there are no timing information being broadcast and no meta data 
fields available for getting these like in mpeg TS.

The only way is to find the symbol boundary and time stamp it, since the tuner 
is feeding the base band samples  to
DSP, if any tuner variations will be reflected in the timing of symbols in DSP. 
Monitor this difference and adjust audio clock
in DSP, which is possible in hardware of DSP.

This is what I'm planning to implement, please find the attached figure,

Now the timing of input side is after detecting the start of symbol. Every 
symbol will be timestamped and  measure the time deviation between two symbols.

d = t1 -  t0,
where t0 - time of arrival of symbol (n)
 t1 - time of arrival of symbol (n+1)
  d - time deviation between two symbols.

D - time duration between two symbols according to digital radio standards, 
then  error =  ( D / d )  -  1

Please send your suggestions feedback regarding this approach.

-ben

From: music-dsp-boun...@music.columbia.edu 
<music-dsp-boun...@music.columbia.edu> on behalf of Andy Farnell 
<padawa...@obiwannabe.co.uk>
Sent: Wednesday, January 24, 2018 2:17 AM
To: music-dsp@music.columbia.edu
Subject: Re: [music-dsp] Clock drift and compensation

On Tue, Jan 23, 2018 at 04:17:40PM +, Benny Alexandar wrote:

> How to design a control system such that a digital baseband frame of duration
> 'T' ms is mapped to audio and adjust the drift ?

A classic asynchronous resampling problem. Look at something like
SMPTE drop frame resampling using div/modulo to calculate the
number of frames of m samples over which to interpolate to get
some new number of n samples.

Real problem is that you need to know the difference/drift
in the clocks. Is there some feature in your signal that helps
with this?



> ___
> dupswapdrop: music-dsp mailing list
> 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

Re: [music-dsp] Clock drift and compensation

2018-01-23 Thread Bogac Topaktas
On Tue, January 23, 2018 7:17 pm, Benny Alexandar wrote:
> Now if the tuner xtal is drifting then the dsp audio streaming needs to
> adjust to that drift, else buffer overflow or underrun happens as the
> sample rates doesn't match.

Assuming you do not have the option of modifying the hardware,
you may use sample length modification techniques similar to these:

https://www.google.com/patents/WO2008006080A2?cl=en

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



Re: [music-dsp] Clock drift and compensation

2018-01-23 Thread Andy Farnell
On Tue, Jan 23, 2018 at 04:17:40PM +, Benny Alexandar wrote:

> How to design a control system such that a digital baseband frame of duration
> 'T' ms is mapped to audio and adjust the drift ?

A classic asynchronous resampling problem. Look at something like 
SMPTE drop frame resampling using div/modulo to calculate the 
number of frames of m samples over which to interpolate to get
some new number of n samples.  

Real problem is that you need to know the difference/drift 
in the clocks. Is there some feature in your signal that helps
with this? 



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



signature.asc
Description: Digital signature
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp