Welcome back to the course on RSNO processing for music applications. We are in the second week in the course and this is the second part of the lecture on the Discrete Fourier Transform. In the first part we focused on the basic equation of the DFT, so now let's continue. We will briefly review the DFT equation, and then we will talk about how the DFT works when our input signal is a complex sinusoid, or when itâ€™s a real sinusoid. And then we will talk about the Inverse-DFT. So DFT can be understood as the projection of a signal into a finite set of complex sine waves. Thus, it is able to identify how much of each of these sinusoids is present in the signal. So from the equation, the concept of the inner product expresses this idea that the signal, x of n when we project it on the complex sinusoid it's e to the minus j to pi k n over N. We are basically measuring the amount of the sinusoids in the signal. If we show an example, this violin sound, so we are taking a fragment of this sound. [MUSIC] Okay, so we are taking capital N samples of this violin sound and we are projecting it into these complex sinusoids that we are generating. Under result is this spectrum express in units, so we see the magnitude and the phase spectrum. In the magnitude we see the amount of each of the sinusoids present in the signal, and in the phase we are identifying the location of these sinusoids with respect to time zero. So, if we plan how to compute the DFT of one single complex sinusoid, we'll understand this concept a little bit better. So let's start from an input signal, x sub 1, which is defined as a complex sinusoid of length, capital N, and has a given frequency expressed by this index, k sub 0. And what we going to do is, we're going to substitute our input signal X in our DFT equation by these complex sinusoid. So therefore, we have a product of two complex sinusoids, we can sum the exponents, and we obtain a single complex sinusoid with a more complex exponent. And this, in fact, is the sum of a geometric series, and therefore, it has a closed form that can be expressed by this equation. And by basically inspecting this equation we can see that when k is not equal to k sub 0, the denominator is not 0, and the numerator is 0. Therefore, all the output signal X of k is equal to capital N when k is equal to k sub 0, and is equal to 0 for the rest. So what we're saying is that it has a single value that k equals k sub 0 and this value is n. So let's see the plot of this operation. So this is the DFT of a complex sinusoid, so on top we see this complex sinusoid that k is equal to 7, so basically it means that it has 7 periods in the length of capital N. And in this case, we have defined N as 64, so there's 7 periods in these 64 samples, and of course, we see the cosine and the sine, and when we compute, the DFT, again we see the magnitude and phase. The phase so let's not talk about that right now, let's just focus on the magnitude and here we see clearly, the value of 64 at one location, which is at location k=7. The rest of the values are 0. However, this is a very special case in which the complex sinusoid is one of the basic functions of the DFT, this never happens when dealing with a real segments. Let's see a more realistic example. The DFT of a complex sinusoid of any frequency. Let's start with the signal X sub 2 in which is a complex exponential, but. The frequency is not one of the frequencies of the DFT sinusoids. So the frequency is expressed by f sub 0 and it has an initial phase. And It has the same duration, so it has a duration of N, but it doesn't have lets say, a fix number of periods in that duration. So, anyways, so lets put this sinusoid into the DFT equation, and we again, get the product of two complex exponentials. We can sum the exponents, except that the phase term of the sinusoid can be pulled outside, because it does not depend on N. And also, being a geometric series, we can have a closed form. But is not so easy, it's not as nice as the previous one, who doesn't have fixed values that are clearly identified. So let's see a plot of this operation and how this function looks like. This shows the display of what is the DFT of a complex sinusoid that doesn't have a discreet frequency, is not as nice as the previous case. So in here we have taken k=7.5, so our frequency is not an integer value and capital N is 64. So here, it means that we do not have an integer number of periods within the 64 samples, in fact, we have 7.5 periods. And when we computed the DFT, the first thing that we notice is that the magnitude spectrum has positive values for all k. Of course, there is one area that has a prominence, and that is the area around 7.5. In fact, for k equal 7 and k equal 8 has the same value and for the rest of k has a much of smaller value. The phase, let's not talk much about it here. But it's not that relevant for this situation. Okay, but even this is not that real. We do not encounter complex sinusoids like these in our physical life. So let's go a step further and compute the DFT of a real sinusoids, not a complex one. Thus, something that is closer to the reality of sounds, but it's a bit more messy. So let's take a signal that is a real sinusoid with a frequency that is an integer value of frequency. So by using Euler's identity that we talked about, we can express this cosine as the sum of two complex sinusoids. And if we pluck this real sinusoids in the DFT and then we express it as the sum of two complex sinusoids we basically can do the same operation that we did in the previous case, being the DFT linear function, and we'll talk about that. We basically can express the DFT of this sum of two complex sinusoids as the sum of two DFTs of each sinusoid separately. Therefore, the result is basically two DFTs that we basically have seen, one is of a frequency of negative frequency and the other is the DFT of a frequency of positive frequency, and with the given amplitude, each one. So what the result, basically we go through the logic that we did before is that it's going to have an amplitude, a sub zero over two for two frequency locations. For the frequency location of k sub zero. And for the frequency location of minus k sub zero. And it will have 0 for the rest of k and let's see, plot for it. Okay, so this shows the output of calculating the DFT of a real sinusoid, but we have complicate it a little bit more and we have not express it for k equal to an integer value. But again, for a k being a floating point value, in this case, 7.5. So if we take the real signal and take the DFT of that, we will see that it has two bumps, one around -7.5 and the other around 7.5. And again it has positive values for all k. Okay, however, still we do not find sinusoids like this in our daily life. But we're getting quite close, some sound are not that different from a real sinusoid like this one. So, one of the great properties of the DFT is that it's invertible, which means that we can get back the original signal from its spectrum. So this is the equation of the inverse DFT in which our input signal now is the spectrum, is X of K. And then we do a similar operation, like the DFT, we multiply by complex exponentials. But in this case, it's not a negative exponential, it's a positive exponential because were not taking the conjugate. So were basically multiplying the spectrum by a complex exponential and then we are summing over this result of over N sample. And then there is a normalization factor that we include, which is 1 over n. So the main differences with the DFT is that the complex exponential are not conjugated, so we have a positive exponent. And there is this normalization factor, apart from that, is basically the same, but conceptually is very different. Basically, what we're doing here, it's kind of a synthesis, we are regenerating the sinusoid, we are recomputing the sinusoids that we identified. So, let's put an example. If we start from spectrum, like one we saw before in which there was one positive value at k = 1. So we started from a sequence of four samples and we obtained a positive value as k = 1. So this is a spectrum of a sequence and now if we apply this Inverse DFT function. Therefore, we multiply each of these spectral samples by the samples of four sinusoids or complex sinusoids. Of different frequencies, we will see that the result is basically the signal we started with. So this is a complex signal, the result that has for 4 J minus 4 and minus 4 J, so this is the inverse transform of this spectrum. And let's show an example. So for real signals, we do not need the complete spectrum in order to recover the original signal. We saw that it was symmetric so it's enough to have half of the spectrum, and typically we use the positive of the spectrum. So if we have for example in these figure we have a given magnitude spectrum and of course we have a phase spectrum, then we can do the inverse of that. And we can compute it using these equations. So we first have to generate the negative part of the spectrum so the positive part will be the magnitude multiplied by the complex exponential tool, the phase. And the negative part is going to be the magnitude again multiplied by the negative part of the phase. Okay, and then if we do the inverse DFT, we apply that equation into these whole sequence, these whole spectrum X [k] we will get back a real sinusoid. Okay, so this is a sinusoid that has the length of the spectrum we started from, in this case, it's 64 samples. The spectrum had 32 positive samples and 32 negative samples, and the inverse for your transfer has this 64 samples of a real sinusoid. Okay, so we will come back to these concepts in the next lectures so do not worry if you still are not understanding completely this concept. So again, you can find a lot of information about the Discrete Fourier transform in Wikipedia and of course on the website of Julius and here you have all the standard credits that we have in every class. So in the first part of this lecture we introduced the DFT equation. And in the second part, we have seen how the DFT works when the input is a sinusoid. We have also explained the members DFT. If you have been able to understand this, you are doing very good. You should have no problem with the rest. So, see you next class. Thank you.