# Is this conversion correct

This topic is 5403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Supposing I am converting an audio signal to the frequency domain at 44.1 kHz, how do I do the actual frequency mapping for each segment (if the segment is, say, 1024 points long)? That is, if I get the frequency domain signal, how can I pinpoint where 16 kHz is, for instance? Here's what I'm using to test it, but it isn't really giving me anything solid as to how I should go about converting these values. Suppose I were to take a look at the signal generated by the following piece of pseudocode: static float freq = 0; float sine_freq = 22050; signal[n] = sin(freq); freq += CONSTANT_PI / 44100 * sine_freq; When converting by chunks of 1024 points, I get a peak at the center of the spectrum. Does this say that I'm getting a spectrum with 44 kHz bandwidth? Now, if I only want the first 20 kHz, I should just cut away the remainder? What about the fact that I'm perfectly capable of hearing the sine wave at sine_freq = 30000, or even 36000. I know my hearing is okay, but it's not that okay...

##### Share on other sites
CONSTANT_PI / 44100 * sine_freq

should be

2.0 * CONSTANT_PI / 44100 * sine_freq

If you set the frequency above 44100/2 you will still hear a tone, but with the wrong frequency.

##### Share on other sites
Thanks for pointing that out.

Is what you're suggesting that I should only map frequencies up to the Nyquist frequency? As in, for a 44.1 kHz signal, FFT'ing each segment would give me 22.05 kHz bands?

##### Share on other sites
When doing a FFT you only get frequencies up to the Nyquist frequency. Converting a 1024 sample block will give you 513 amplitudes from 0 to 22050 Hz in 44100/1024 = 43.066 Hz steps.

##### Share on other sites
Aha - that's what I thought you implied in your first post. Thanks!

• 21
• 13
• 9
• 17
• 13