Calculus/predicting position in a damped oscillatory system
Expert: Alon Mandes - 3/7/2009
QuestionHi! I hardly know any calculus or differential equations so I'll need a complete answer. I've tried asking in a forum and didn't get any answers that were really clear.
I want to get frequency analysis on a digital audio signal in real-time, but I don't want to use Fourier transform because those must operate on blocks of samples at a time, which would create a number of problems for my purposes.
So I want to get the frequency spectrum on the signal continuously, and here's my idea on how to do it: to simulate a number of damped oscillators, each oscillator having a different "spring" strength which determines the resonant frequency of that oscillator. So if I have, e.g. 20 oscillators then I can get intensities at 20 different frequencies in real-time, by polling their amplitudes.
The damping I figure is needed because if I don't damp then an oscillator could increase in amplitude indefinitely over the life of the signal, so I'm not sure how much damping I need, but I figure maybe just enough so that given an exact sine wave of maximum intensity on its exact resonant frequency it would damp just enough to not diverge to infinity.
So that's the purpose for the equations I want, just in case you know of a better way or you know that this wouldn't work for some reason. The equations I want more specifically are below.
The damping equation on Wikipedia is shown as mx''+cx'+kx=0, where m=mass, k=spring constant, and c is the viscous damping coefficient. Then later from that equation it deduces an equation for x(t) where t is time. I don't understand where the amplitude of oscillation is entered into the system in order to know x(t), but in any case, I was thinking what I need is a somewhat different set of solutions: x'[t,x'(0),x(0)], and x[t, x'(0), x(0)]. The more steps that can be done only once and used to get both x' and x, the better, since CPU time is crucial. And t will always be the same value. Also, the more steps that can be done only once per oscillator regarding its specific c, m and k, before operating on the input stream, the better.
So with those equations, my plan is to, for each input sample of the pulse-code modulation, for each oscillator, take the previous x' as given by the equation and add to it the difference between the current sample value and the previous one, to simulate the force being applied to the oscillator by the air waves at that instance in time as it (instantaneously) increases or decreases the oscillator's speed. The result will be my new x'(0), and the previous value of x will be my new x(0). The new value of t that's plugged in will always be 1/(sampling frequency), since the equations are predicting results at the point at which it's time to compute the next sample. The only thing left is how to compute the amplitude of the oscillator at that moment, so that I can get my frequency spectrum. I don't know how this can be done, but for the above solutions to be useful, I assume amplitude must be deducible from x' and x, for example at x'=0 the amplitude should be exactly x.
Some things I'm not sure about are:
- Would the frequency range of sensitivity for an oscillator be too wide or too narrow for the number of bands I'm analyzing? How would I control the frequency range of response for an individual oscillator? It doesn't seem to be a variable that can be controlled. I expect I'll be analyzing somewhere between 20 to 22,050 bands bands (in other words, 20 to 22,050 oscillators), or possibly more in the case of an extra-high sampling frequency.
- What happens if the signal continues to have a certain frequency, but changes phase on that frequency? Is my oscillator too slow to respond? Does it not register a frequency at all that's on a different phase from what it started out as, i.e. can the oscillator change its phase?
- Should I convolve the signal with a hamming wave before processing it?
So I don't think I saw signal processing in your list of specialties, so maybe you can't answer all of these questions, but I'm hoping at least that the solutions I want for the damping systems are clear in themselves. Thanks for any help!
AnswerHello Richard,
Yes, there is no calculus involved in your problem, it's much more
Differential Equations combined with DSP. But, here are some useful
facts that you should consider before getting engage in this proj :
1. The Audio frequencies range from 0-30 KHz (max) "Waves of Sound")
2. The amplitudes will be set when solving the Diff Equ. In your
case the solution will be harmonic function where its amplitude
& frequency are functions of k,m & c.
3. Usually, Spectrum Analyses are performed with Fourier Transform
or furrier series, Which yields: amplitude & phase as function of
frequency. So, even if the phase are different, the analyze will
still give the same frequency.
4. The frequency range of sensitivity for an oscillator can be
controlled by choosing the Constance k & m.
5. The solutions of the set of equations, will be calculated when
the initial conditions are provided..such as x(t=0) & x'(t=0)
as VECTORS.
6. The system is Linear one, say the sum of all response will equal
the response of the sum of all excitations.
7. As for the most important question If this Model will represent
well the Fourier frequency analyze, I would say it depends on how
accurate your result will be. It's important to understand that
thee oscillators commonly can generate a wave form or a time
envelope function that is very sensitive to phase shift. Phase
shift (or jittering) in Electronics language can easily change
the amplitude of two wave interference. Thus, must be very
carefully handling forces. Because the interference of the waves
with each others here is crucial.
Good luck, & I'm here for further consultations & information.
Alon,