# Wave frequency question

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

## Recommended Posts

So, 1 Hz Frequency wave looks like this: (The middle line is 0 amplitude)

But what if wave looks something like this:

Is it still 1Hz? Sorry if this is a stupid question.

##### Share on other sites
You have a composition of several frequencies. One dominating component is at 1 Hz, but due to the tone not being pure anymore, you also have other frequencies present.

##### Share on other sites
It depends.
1Hz means that each second the wave repeats itself once. If that happens, it's still 1Hz.
If, for example, the wave repeated itself 3 times per second, it would be 3Hz.

##### Share on other sites

Consider the waves above is played only once a second. That means the first wave is 1 Hz, what would be the frequency of second wave? Thanks!

##### Share on other sites
It would also repeat once every second, so the fundamental frequency would still be 1 Hz. But it also contains overtones, since it's not pure tone, which are multiples of the fundamental frequency. So you would hear not only 1 Hz, but also 2 Hz, and 3 Hz and so on, but with a much lower amplitude.

##### Share on other sites
Oh, Thank You!

XAudio2 has SetFrequencyRatio function to change frequency of the sound and to find frequency ratio, I need to detect the frequency at which the sound in a buffer plays at.
Consider the buffer is circular and is 64 bytes long, sample rate is 8 kHz and sample depth is 8 bits, I can find the frequency of the sound in buffer by finding the number of oscillations in the buffer and then multiplying 125 with the number of oscillations. And find frequency ratio by dividing the 'new frequency' by the frequency of the sound in buffer.
So, my question is that to find the frequency of the sound in buffer, do I have to consider the overtones too or just fundamental frequency?

##### Share on other sites
Either I don't understand what it is you're trying to do, or you're not understanding what the different meaning of frequency in these contexts are, because your question doesn't make much sense to me. You seem to mix the notation of frequency of the tone and the sampling frequency as if they are the same thing, or at least related to each other. I'm afraid you're going to have to make your question much clearer.

##### Share on other sites
Sorry, sometimes I can't express myself clearly in English since it's my second language.

As far as I understand, sampling frequency is the number of sample played per second. So, if the sample rate is 8kHz, it means 8000 samples are played per second.
And frequency of sound is number of oscillation of sound waves per second.
So they are not the same thing.

What I am trying to do is this, I have 64 bytes long buffer and the contains of it is played again and again, infinite loop. Now I have to find the frequency at which the sound in that buffer is playing at. Since I know the sample rate is 8 kHz, I can analyze the value in the buffer and find out the number of oscillation in the buffer. And lastly to find out the frequency I can simply do this:

Frequency = (Sample Rate / Size of Buffer) * number of oscillation in buffer
or, Frequency = (8000 / 64) * number of oscillation in buffer
or, Frequency = 125 * number of oscillation in buffer

After I find the frequency of the sound that is being played, I can use that to find the frequency ratio needed for the XAudio2 SetFrequencyRatio function.

Thanks!

##### Share on other sites
What is it that you want to do with the sampling frequency adjustment? I really see no connection between what you describe about the number of cycles in the sample buffer, and how you want to adjust the playback sample rate.

But let's just ask a question with specific numbers. Everything else being what you describe in your post; 8 kHz sample rate and 64 samples per buffer, what do you want to do if you know that the buffer contains three osscilations? That is, if the frequency of the tone is 375 Hz.

##### Share on other sites
I have a 13 bit frequency in which the sound in the buffer should be played at. To change sound frequency, I need to calculate the frequency ratio (so that I can use it in XAudio2::SetFrequencyRatio function) which is equal to '13 bit frequency / frequency of the tone' ('13 bit frequency / 375' in your above example).

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
14
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013643
×