I'm working on a pitch shifting program. Everything works up to the point where I try to do the IDFT. Because I cut the DFT array past the Nyquist limit, when I run the IDFT, I don't get the same signal as I originally did. For example, If I pass a 1024 item buffer into my DFT code, it returns a 512 item array. If I don't cut the DFT in half and pass it to the IDFT I do get the same signal as original. Logically it makes sense that if you cut the DFT in half, you're not gonna get the same signal that you started with. But everywhere I read insist on cutting the array past the Nyquist limit and double all the values left over. And I understand the purpose of doing this, but what I am wondering is how to reconstruct the original signal after making the modifications to remove the values past the Nyquist limit?

Just for reference, here's my DFT and IDFT code (JavaScript):


enter image description here


enter image description here

  • $\begingroup$ What do you mean with "cut past the Nyquist limit"? That makes no sense, the discrete Fourier transform inherently works on the discrete Frequencies only. $\endgroup$ Oct 3, 2022 at 23:21
  • $\begingroup$ It might really help us understand where you're coming from if you could vote your "everywhere i read". Because if you learn about the DFT in the context of signals and systems, it's usually introduced as bijective base Transform within the $\mathbb C^N$; can't cut anything from that, or else it's not working anymore. $\endgroup$ Oct 3, 2022 at 23:30
  • $\begingroup$ Please pick one or two examples out of that "everywhere I read" and cite them, the same as you would for a paper. Then, if it seems appropriate, quote the relevant sentence or two that you're seeing as directions to do this. $\endgroup$
    – TimWescott
    Oct 4, 2022 at 0:34
  • $\begingroup$ The code that you included, is that text-book implementations of a dft and idft, or something else? $\endgroup$
    – Knut Inge
    Oct 4, 2022 at 3:40
  • $\begingroup$ Perhaps “cut” was the wrong term. Allow me to clarify. I am attempting to change the pitch of the signal, thus in the analysis step I only need to focus on the values that come before the Nyquist limit. Thus, momentarily setting the other values to zero. What I need to do now is synthesized a signa based on the pitch modification. However now I am stuck with a “half” of the transform and cannot get the correct signal from the ifft. $\endgroup$ Oct 4, 2022 at 4:13

1 Answer 1


If I don't cut the DFT in half and pass it to the IDFT I do get the same signal as original

There's a french joke that goes something like:

Doctor, my stomach hurts when I say the word "Blinktzriegshodd" out-loud.
To which the doctor answers: well, don't say it.

Moral of this is: if you get what you expect through option A, and not through option B, use option A:
Don't cut the DFT.

As a more general answer to your question, when you say you've read everywhere about cutting the DFT, and that you understand the purpose, I'm assuming you (and the readings you mention) refer to discarding the "negative frequencies", which you can do if you're only using the DFT for analysis, since the information is redundant (for real input signals).
However, for synthesis, you need both sides of the spectrum. I guess you could theoretically discard half the DFT output (by replacing that half with 0s, doing the inverse transform, scaling (and shifting?), discarding the imaginary part, leading to no gain in processing time), but I don't see the point...
Hope this helps!

  • 1
    $\begingroup$ As a side note, I get a picture of how you're approaching your problem (pitch shifting) through the multiple questions you've asked here. Take it step by step, keep asking questions when you're stuck, and you'll get there. It takes time and patience, and I believe you're going at it the right way ;) $\endgroup$
    – Jdip
    Oct 3, 2022 at 23:52
  • $\begingroup$ Thank you! I’m almost there $\endgroup$ Oct 4, 2022 at 1:08
  • $\begingroup$ Hi, so I've tried doing this, and the issue is that I am doing analysis on the DFT (by shifting pitch) so I kind of need to work with the "cut" DFT. can I just simply mirror the modified DFT over the Nyquist limit? Would that even work? $\endgroup$ Oct 4, 2022 at 2:49
  • $\begingroup$ I’m sorry I know I’m a noob, I’m only a high school student so I’m limited in my knowledge. I’m trying my best! Thank you for working with me! $\endgroup$ Oct 4, 2022 at 4:15
  • $\begingroup$ Nothing to be sorry about! I'm happy to help, but let's take this to a chat at this point: chat.stackexchange.com/rooms/139623/pitch-shift $\endgroup$
    – Jdip
    Oct 4, 2022 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.