# Re: [music-dsp] Finding discontinuity in a sine wave.

```Not really, that will only work to find the frequency if the signal is a
pure sine wave, maybe with some very quiet noise. If you know roughly the
frequency where the sine wave is, it might still work if you put the signal
through a very narrow bandpass filter first. Or it might not if the sine is
too quiet compared to the rest of the audio.```
```
-Ethan

On Thu, Jan 11, 2018 at 12:16 PM, Benny Alexandar <ben.a...@outlook.com>
wrote:

> Hi Ethan,
>
> This looks interesting. Suppose I have a single tone sound getting mixed
> with audio,
> can we find that tone frequency and have an adaptive notch filter ?
>
> Does your above equation works in identifying a fixed frequency tone ?
> For example by doing (x(t) + x(t-2)) / (2*x(t-1)) can we isolate a
> single tone frequency  ?
>
> -ben
>
> ------------------------------
> *From:* Ethan Fenn <et...@polyspectral.com>
> *Sent:* Thursday, January 11, 2018 12:13 AM
> *To:* Benny Alexandar
> *Cc:* music-dsp@music.columbia.edu
>
> *Subject:* Re: [music-dsp] Finding discontinuity in a sine wave.
>
> Well, starting with the FIR filter I proposed, let's take this equality:
>
> 0 = x(t) - 2*C*x(t-1) + x(t-2)
>
> If we don't know exactly what our frequency is, we can solve for C:
>
> C = (x(t) + x(t-2)) / (2*x(t-1))
>
> Of course we don't want to take just one computation of C, but if we do
> some averaging and are careful about the singularity when x(t-1) is close
> to 0, then we've got a simple adaptive notch. And we can get a running
> estimate of the frequency by computing arccos(C).
>
> -Ethan
>
>
>
> On Wed, Jan 10, 2018 at 12:47 PM, Benny Alexandar <ben.a...@outlook.com>
> wrote:
>
> This all works well in an ideal system. Suppose the sampling clock is
> drifting slowly over period of time,
> then the notch filter will fail to filter it. How to detect and correct
> these clock drifts and have a stable notch filter.
>
> -ben
>
> ------------------------------
> *From:* music-dsp-boun...@music.columbia.edu <
> music-dsp-boun...@music.columbia.edu> on behalf of Ethan Fenn <
> et...@polyspectral.com>
> *Sent:* Wednesday, January 10, 2018 10:33 PM
> *To:* music-dsp@music.columbia.edu
> *Subject:* Re: [music-dsp] Finding discontinuity in a sine wave.
>
> If the sine frequency is f and the sample rate is sr:
>
> Let C = cos(2*pi*f/sr)
>
> For each sample compute:
>
> y(t) = x(t) - 2*C*x(t-1) + x(t-2)
>
> y(t) should be 0 for every t... if not it indicates a discontinuity. This
> is just an FIR filter with a zero at the given frequency.
>
> -Ethan
>
>
>
>
> On Wed, Jan 10, 2018 at 11:58 AM, STEFFAN DIEDRICHSEN <sdiedrich...@me.com
> > wrote:
>
> With any phase discontinuity, a spectral discontinuity is delivered for
> free. So, the notch filter will have an output, a PPL would need to
> re-sync, etc.
>
> Steffan
>
>
> On 10.01.2018|KW2, at 17:51, Benny Alexandar <ben.a...@outlook.com> wrote:
>
>  But if there is a phase discontinuity it will be hard to detect.
>
>
>
> _______________________________________________
> 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```