DSPRelated.com
Forums

Calculating instantaneous phase of a simple signal

Started by maxplanck February 29, 2008
>It sounds like you start with a signal S you assume to be composed >of three individual scaled-and-perhaps-phase-shifted pure sine waves >of frequencies f1, f2, and f3: > > S(t) = (k1 + sin(t * (2*%pi)/f1)) > + (k2 + sin(t * (2*%pi)/f2)) > + (k3 + sin(t * (2*%pi)/f3)) > >Since you don't specify any relationship between f1, f2, and f3, >I'll assume there may not be / isn't one. >
>Based on this construction of S(t), S(t) will be periodic over the >perhaps-very-long period 1/(f1*f2*f3).
(f1*f2*f3) is a much higher frequency than the instantaneous frequency of S(t) at any t. I know that because I used numerical methods to approximate the instantaneous frequency of S(t). The period 1/(f1*f2*f3) is far far shorter than one period of S(t). Also, for my signal k1=k2=k3=0. I don't quite understand what you're getting at, could you elaborate please? Thanks for responding
I don't know what f is, I'm trying to solve for f.  I know the frequencies
of the three sine waves that i'm adding together to generate signal, but I
don't know the instantaneous frequency of the output of the three summed
sine waves.

I think you're talking about using the instantaneous frequency of signal
to calculate the instantaneous frequency of signal?  

I think that my question has gotten buried too deep in this topic, i'm
going to post a new topic summarizing what's been figure out so far in
this topic and what remains to be figured out

Thanks for responding


>It's Sunday morning and my Aspirin hasn't kicked in yet but: > >-pi/2 <= 2*pi*f*t <= pi/2, > >-1/(4*f) <= t <= 1/(4*f), > >0 <= t + 1/(4*f) <= 1/(2*f), > >so replace t with T where: > >T = {[t + 1/(4*f)] modulo [1/(2*f)]} - 1/(4*t). > >For example: > >T = 0; > >while (1) >{ > signal = getSignal(); > f = 1/(2*pi*T)) * asin(signal/A); > T = T + dT; > > while(T > (1/(2*f))) T -= 1/(2*f); >} > >Note: I really don't see this going anywhere for a general, >composite "signal" with a time-varying A. It seems to me that >the math is only valid where "signal" is a pure sine with a >known, fixed A, so I wonder what the real-world application >might be.
"maxplanck" <erik.bowen@comcast.net> wrote in message 
news:a4CdncKDZrcEpVbanZ2dnUVZ_uWlnZ2d@giganews.com...

> I don't know what f is, > I'm trying to solve for f. > > I think you're talking about > using the instantaneous frequency > of signal to calculate the > instantaneous frequency of signal? >
I think you didn't even give cursory attention to what I wrote!
> I think that my question has gotten > buried too deep in this topic, I'm > going to post a new topic summarizing > what's been figure out so far in > this topic and what remains to be figured out
Well, if you read the responses to the new thread as carefully as you read the responses to this one, I think you can expect to remain uninformed after starting 1,000 new threads. Troll On!
On Sun, 02 Mar 2008 16:48:20 -0600, maxplanck <erik.bowen@comcast.net> wrote:
>>It sounds like you start with a signal S you assume to be composed >>of three individual scaled-and-perhaps-phase-shifted pure sine waves >>of frequencies f1, f2, and f3: >> >> S(t) = (k1 + sin(t * (2*%pi)/f1)) >> + (k2 + sin(t * (2*%pi)/f2)) >> + (k3 + sin(t * (2*%pi)/f3)) >> >>Since you don't specify any relationship between f1, f2, and f3, >>I'll assume there may not be / isn't one. > >>Based on this construction of S(t), S(t) will be periodic over the >>perhaps-very-long period 1/(f1*f2*f3). > > >(f1*f2*f3) is a much higher frequency than the instantaneous >frequency of S(t) at any t. I know that because I used numerical >methods to approximate the instantaneous frequency of S(t).
Apologies if I sound pedantic: I'm trying to listen to myself as I write to make sure it has some semblance of sense to it. <grin!> If you have three true-with-no-noise sine waves whose frequencies are "relatively prime" (e.g. 5Hz, 7Hz, and 11Hz), and you want to find the lowest frequency which exactly fits into the periods of all three sine waves, doesn't that have to be 5*7*11 Hz? Can't you then generate the original three waveforms by dividing the "output" from a 5*7*11Hz "oscillator" (hardware or software) appropriately: 5Hz = (5*7*11) / (7*11) 7Hz = (5*7*11) / (5*11) 11Hz = (5*7*11) / (5*7) The period of the oscillator is 1/(5*7*11) seconds. The period of the waveform which is the sum of these waveforms would be one second, since that's the smallest interval over which all three components exactly repeat. I'm not familiar with the nuances of "instantaneous frequency", but the _math_ implies that if your composite signal repeats "sooner" (has a period less than this) then your component frequencies aren't relatively prime. Example: 6Hz = (6*10*14) / (10*14) 10Hz = (6*10*14) / (6*14) 14Hz = (6*10*14) / (6*10) Now, it's true that the sum of these three waveforms will repeat every second, but since their frequencies aren't relatively prime -- they have a "2" in common -- the sum-waveform will have a period of 1/2 second rather than one second.
> The period 1/(f1*f2*f3) is far far shorter than one period of S(t).
Exactly. If you want one brick (oscillator cycle) to exactly fit all your walls, it has to fit along every wall by some exact count. Or were you expecting to find something with a longer period that that of S(t)? (In which case, I'm completely out of touch with what you're doing, and will steal silently away into the night. <grin!>)
> Also, for my signal k1=k2=k3=0.
No phase shift. Hm, so all three waveforms start at 0 at t=0, and all happen to be zero again at the end of the period. It simplifies the calculations a bit, but doesn't signifcantly alter the picture I'm working with.
> I don't quite understand what you're getting at, could you elaborate > please?
I'm replying with my best efforts based on my own interpretation of those bits and pieces of what you posted that seemed to fit together in a way that I could understand. A little un-clarity is not unexpected. <grin!> Two things are a little unclear to me. You may have already responded to them in a post I missed, but I'll ask them anyway: 1) What is the "permanence" of f1,f2,f3? Are they known-and-forever-constant? Are they human-modifiable in the field? Are they determined on-the-fly from some other calculations? 2) You've described using an "envelope" to "modulate" (I don't recall your exact words) a single-frequency oscillator. You _could_ just store one period's worth of your composite waveform at some sampling frequency and repeat as needed, and at one point you spoke of having calculated an "envelope" you would apply to the wave-for-which-you-seek, but you seemed to be looking for something other than a WAV-dump. Can you describe how your sought-for solution would differ from (say) a stored set of amplitude samples? Thanks, and sorry for any confusion I may have added. Frank -- Everything has to start with fantasy... Knowledge is what you finish up with, if you're lucky, after you've done the hard work -- but the hard work needs passion to drive it. People need reasons to be interested, reasons to be committed, reasons to do their damndest to find the truth. -- Brian Stableford / Dark Ararat -- Frank McKenney, McKenney Associates Richmond, Virginia / (804) 320-4887 Munged E-mail: frank uscore mckenney ayut mined spring dawt cahm (y'all)
What I'm trying to do is this:

I have generated a signal S(t):

S(t) = a1(sin(f1*t) + a2(sin(f2*t) + a3(sin(f3*t)

Then I further define S(t) as follows:

S(t) = S2(t) = A sin (F*t)

I want to calculate A and F.  I know that A and F will have to vary with
time in order for S(t)=S2(t) to be true.

I've already figured out how to calculate A.  I've also figured out how to
calculate the instantaneous phase of A sin(F*t).  I did this by generating
an analytic (i.e. complex) signal from S(t), then taking the magnitude of
the analytic signal to yield the amplitude envelope of S(t). Then
atan(Q/I) yields the phase. This is illustrated here:

http://www.studioprofessor.com/images/plot.jpg

I know that F should be the derivative of the instantaneous phase of A
sin(F*t), but I was told that taking d/dt atan(Q/I) will not work because
there are both amplitude and frequency symmetry requirements that my
signal does not meet.  I tried, and d/dt atan(Q/I) simplifies to 1, which
clearly cannot be F.  This calculation is illustrated here:

http://www.studioprofessor.com/images/derivativeofphase.txt

I know that there are numerical methods that I can use to approximate F,
using my calculated instantaneous phase of A sin(F*t). I tried one of them
by: plotting the slope of the tangent line between each adjacent data point
in the instantaneous phase of A sin(F*t).  This yielded a curve that is
probably pretty close to F. This curve is illustrated here (please ignore
the vertical lines, they appear due to the fact that I didn't unwrap the
phase angle before making this calculation):

http://www.studioprofessor.com/images/instantaneousfrequencyestimation.png


>Or were you expecting to find something with a longer period that >that of S(t)?
In the actual S(t) that I'm analyzing, f1 f2 and f3 are very close, within a few Hz of each other. The values appear here: http://www.studioprofessor.com/images/plot.jpg Therefore, I was expecting 1/F to always be close to 1/f1, 1/f2 and 1/f3. From this numerical estimate of F, it looks like F is always between f1, f2 and f3. http://www.studioprofessor.com/images/instantaneousfrequencyestimation.png
> 1) What is the "permanence" of f1,f2,f3? Are they > known-and-forever-constant? Are they human-modifiable in the > field? Are they determined on-the-fly from some other > calculations?
f1, f2 and f3 are known and forever constant. The sine oscillators which they control are software, and I'm doing all signal generation and analysis on one computer. There is no "field," other than the computer. Everything is being done on one lone computer. f1, f2, f3, a1, a2, and a3 are not calculated, they are simply constant values input to the frequency and amplitude controls of the software sine oscillators.
> 2) You've described using an "envelope" to "modulate" (I don't > recall your exact words) a single-frequency oscillator. You > _could_ just store one period's worth of your composite waveform > at some sampling frequency and repeat as needed, and at one > point you spoke of having calculated an "envelope" you would > apply to the wave-for-which-you-seek, but you seemed to be > looking for something other than a WAV-dump.
This won't cut it for what I'm trying to do. What I'm trying to do is a probably very uncommon and has little practical utility outside of my uncommon application, which is why I think people are having a hard time understanding what I'm trying to do and why I'm trying to do it. The most concise and exact way that I can state what I'm trying to do is the brief explanation and set of equations at the top of this post. I just need to find F, since I already know how to calculate A.
> Can you describe how your sought-for solution would differ from > (say) a stored set of amplitude samples?
My sought for solution is A and F in the second equation from the top of this post. Nothing more. I already have A, I just need to find the best way to calculate F, with the lowest possible amount of error. Thanks again for responding, if I've failed to explain something well enough please tell me and I'll try again
On Mar 3, 11:10 am, "maxplanck" <erik.bo...@comcast.net> wrote:

> > My sought for solution is A and F in the second equation from the top of > this post. Nothing more. I already have A, I just need to find the best > way to calculate F, with the lowest possible amount of error. > > Thanks again for responding, if I've failed to explain something well > enough please tell me and I'll try again
You have a calculation for F: http://www.studioprofessor.com/images/instantaneousfrequencyestimatio... so just do it as accurately as you like by reducing the size of the interval used and it's done. If that isn't 'best' then you need to explain what the criteria for 'best' would be. Dale B. Dalrymple
On Mar 3, 12:10 pm, "maxplanck" <erik.bo...@comcast.net> wrote:
> What I'm trying to do is this: > > I have generated a signal S(t): > > S(t) = a1(sin(f1*t) + a2(sin(f2*t) + a3(sin(f3*t) > > Then I further define S(t) as follows: > > S(t) = S2(t) = A sin (F*t) > > I want to calculate A and F. I know that A and F will have to vary with > time in order for S(t)=S2(t) to be true.
Errrmmm. Maybe I'm just being dense here, but it sounds like what you want to do is just modulation. You seem to believe that you need both amplitude and frequency modulation: S2(t) = A(t)*sin(F(t)*t) Seems to me that unless you're working under some additional constraints on A(t) and F(t) that you're not telling us, you're making things too complicated - why not just use simple mixing? Pick a constant frequency f4 and then simple frequency conversion defines A(t) in terms of a1, f1, a2, f2, a3, f3 and f4. What am I missing? Perhaps you have some limitations on the bandwidth or frequency of A(t) which make mixing impossible? EB
On Mar 3, 4:38 pm, emeb <ebromba...@gmail.com> wrote:
> On Mar 3, 12:10 pm, "maxplanck" <erik.bo...@comcast.net> wrote: > > > What I'm trying to do is this: > > > I have generated a signal S(t): > > > S(t) = a1(sin(f1*t) + a2(sin(f2*t) + a3(sin(f3*t) > > > Then I further define S(t) as follows: > > > S(t) = S2(t) = A sin (F*t) > > > I want to calculate A and F. I know that A and F will have to vary with > > time in order for S(t)=S2(t) to be true. > > Errrmmm. Maybe I'm just being dense here, but it sounds like what you > want to do is just modulation. You seem to believe that you need both > amplitude and frequency modulation: > > S2(t) = A(t)*sin(F(t)*t) > > Seems to me that unless you're working under some additional > constraints on A(t) and F(t) that you're not telling us, you're making > things too complicated - why not just use simple mixing? Pick a > constant frequency f4 and then simple frequency conversion defines > A(t) in terms of a1, f1, a2, f2, a3, f3 and f4. > > What am I missing? Perhaps you have some limitations on the bandwidth > or frequency of A(t) which make mixing impossible?
Not sure if this is the same OP, but somebody said that they heard a varying frequency when mixing 3 close but constant frequency sinusoids. I would be tempted to run the signal through some psychoacoustic perception models for pitch to estimate an F(t).
Ron N. wrote:

> > Not sure if this is the same OP, but somebody said that they > heard a varying frequency when mixing 3 close but constant > frequency sinusoids. I would be tempted to run the signal > through some psychoacoustic perception models for pitch > to estimate an F(t). >
One has to be ~very careful~ listening to tones involving heavy beats. The ear's response is non-linear, and a simple envelope fade in/out can easily be perceived as a dropping and rising in pitch (loud = lower, quiet = higher). If I remember my acoustics books correctly, the ear is linear only around 2KHz. It may even be more weird than that - above that freq the perception is opposite to that of tones below it. You can demonstrate this effect very easily synthesize a sinewave soundfile with tone bursts of the same freq and different levels, and play it back. It is not a subtle phenomenon, so no "golden ears" required. Richard Dobson
On Mar 1, 12:15 pm, "maxplanck" <erik.bo...@comcast.net> wrote:
> I have a signal composed of three sine waves added together, each sine wave > having constant frequency and amplitude. Each sine wave's frequency and > amplitude is different from that of the other two. > > I want to reproduce this signal using only ONE sine oscillator, of > variable amplitude and constant frequency. I know that the desired signal > reproduction can be accomplished using only one sine wave of constant > frequency, because it can be derived that for a successful signal > reproduction using only one sine wave the frequency of this lone sine wave > MUST be constant. What Dale said confirmed this as well. > > I have already calculated the amplitude envelope that would need to be > applied to the lone sine wave. Now all I need to do is calculate the > frequency that this lone sine wave would have to oscillate at in order for > it to equal the original "three summed sine wave" signal.
Have you looked at the zero crossings of the summed waveform? If your new carrier frequency has any zero crossing other than those of the summed waveform, then no amount of pure amplitude modulation will be able to remove those extra zero crossings. So the zero crossings of your summed waveform may well bound the possible local frequency of any FM modulated carrier (whether or not that carrier frequency makes any "sense"). IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M