Reputation: 31
I am trying to generate sound tones of various frequencies, by creating sample data using the sine function and playing using SDL. I am using
buffer[sample] = 32767 * sinf( 2 * PI * sample * sound_frequency / 44100)
to generate a samples for a sound of frequency - sound_frequency at a sampling rate of 44100. and got 44100 samples ie. a sample sound of 1 second and tried to play using SDL. It is sounding fine when i tried to generate sample for sound_frequency of 2000Hz. But it also sounding fine when tried to generate sample for sound_frequency of 60000Hz. But i expected i should sound for 20-20000Hz only? Could you please help in finding the problem?
Upvotes: 1
Views: 1767
Reputation: 18340
You cannot represent frequency higher than your sampling rate. Your sound will be distorted even with frequencies near the sampling rate. This is happening.
Upvotes: 5