Dmitry Kiryashov wrote: > > > While i've read this i've thinking - "May be exist reverse technique ?" > For example we have an input digitized signal ( only logical "1" and "0" > sequence). > And we want to detect some fundamental frequencies in this stream while > harmonics > should not have influence on result of detection. Are there some way to > apply > that magic sinewaves technique reversly i.e. not for synthesis but for > detection ? Yes. But unfortunately there are some practical problems... > And second question - what happen in case when we take into account N = > odd value, > i.e. not 384 but for example 385 or 383 pieces ? Well for starters, it's not theoretically possible to suppress all of the even harmonics if N is an odd value (recall N is the number of subdivisions of the fundamental frequency; ie. if the fundamental frequency is f=1/T, then the time resolution for pulse transitions are limited to the time quanta T/N.) Pushing theory aside however, it is possible to come fairly close to suppressing the even harmonics. And with a little magic, it's possible to suppress a large subset of the lower harmonics. Think about how you would generate a pulse stream that could be low-pass filtered to generate a sine wave. Intuitively, you might expect to have some sort of frequency modulated square wave. When the the frequency is "low" the filter has a large output and when the frequency is "high" the filter has a small output. Your intuition may further lead you to this equation: g(t) = (1 + sign(A1*cos(2*pi*f1*t) + A2*cos(2*pi*f2*t)) )/2 This dual tone signal (which for the context of our current discussion has nothing to do with DTMF) consist of two harmonically related sinusoids: f2 = m*f1 f1 is the frequency of the fundamental waveform that we wish to synthesize (e.g. DTMF generation) or detect (DTMF decoding). f2 is a much high frequency that can be easily filtered with our low pass filter. The sign() function returns the sign of its arguement. Loosely speaking, it's the mathematical function of a comparator. The rest of the equation for g(t) shifts the DC offset so we have a stream of 1's and 0's. There's a simple way to see what this function is doing. Imagine that the lower frequency sinusoid's amplitude, A1, is twice the higher one. When the low frequency cosine is passing through zero, there are many zero crossings in the higher frequency cosine. For every zero crossing, there is a corresponding pulse transition. Now as the lower frequency cosine approaches it's peak, the higher frequency cosine at some point will no longer be able to cause the sum (of the sinuoids) to change signs. Here's another way to see what's happening. If the amplitudes A1 and A2 are equal then the sum can be expressed as a product: sum = A1*cos(2*pi*f1*t) + A2*cos(2*pi*f2*t) = A1*(cos(2*pi*f1*t) + cos(2*pi*f2*t)) = 2 * A1 * cos(pi*(f1+f2)*t) * cos(pi*(f1-f2)*t)) Which is seen to be one cosine wave being modulated by another. Now to address Dmitry's question. So far we've made no assumption about the sampling rate. But it's sort of obvious that the faster we can generate the pulse stream the easier it will be to filter the high frequency components. If it's not obvious, then please take my word for it. I haven't investigated the case for there being an odd number of samples per T1 (=1/f1). I can only speculate that it might induce a subharmonic oscillation. There are two reasons. First, the phases of the cosine waves could be such that every other cycle differs by one extra pulse. The frequency of this extra pulse is 1/2 the frequency of the fundamental (f1). Thus the introduction of the subharmonic. Secondly, if you take the odd number of samples and multiply it by two you get an even number of samples that is twice as long. Using the same theory as above, it's then possible to generate a sine wave of half the frequency of f1. And as we all know from O.J., if it's remotely possible then we can assume it as true. One more point. Think about what happens when the relative amplitudes of the cosines are varied. For example looking at just the extremes: if A1>>A2 then g(t) is a low frequency square wave and the low pass filter's output will have a large output. if A1<