Sampling a low-frequency sound doesn't work at some sampling rates When sampling a low-frequency sound (like a 55Hz sine wave) I hear an additional high frequency sound at certain sampling rates, but not at others. This happens in Audacity and in my own program. For example, I hear both a low and a high pitch when sampling at 44,100 Hz, but only a low pitch when sampling at 48,000 Hz. What could this be?
More information:
The high frequencies are present for other input frequencies and it's not dependent on amplitude.
I'm sampling the sine wave using the standard sin() function in C++:
for( int i = 0; i &lt; N; i++ )
{
    float time = float(i) / float(samples_per_second);
    output[i] = sin( 2*pi * 55 * time ) * 0.5;
}

Not sure how Audacity is doing it. With Audacity I generate a sine tone, and then changing just the project's sampling rate will make the high pitch appear/disappear.
The same thing happens playing back a bass drum sound (in Audacity and my program). I sample it just by indexing into a table loaded from a .wav file.
Even more information:
I noticed that the high frequency artifact sounds the same as sampling at a different rate with no interpolation, like this:
float in_idx = 0.0f;
for( int out_idx = 0; out_idx &lt; N; out_idx++ )
{
    output[out_idx] = input[ int(in_idx) ];
    in_idx += 44100.0f / 48000.0f;
}

So maybe Windows or the driver or the hardware are deciding not to use interpolation for some reason.
Could be a few things

You may be borderline clipping. Your sine wave has an amplitude of 1, which is just at the edge of clipping (depending on how its rendered). Try it with an amplitude of 0.5
Your hardware is sloppy. For example, cheap laptop sound cards often cut corners in the anti aliasing filters and or clipping management
Your operating system is poorly configured, particular if you use Windows. If you change sample rate in the project, it may just trigger the operating system  to do sample rate conversion. If the sound card only supports 48 kHz natively, the OS will up-convert 44.1 kHz to 48 kHz and the quality of the sample rate converter can be fairly bad. On Windows all audio goes through the kernel mixer (unless you specifically bypass it) and that often messes with the audio as well.
Driver problem. The interface between the OS and the sound card could be sloppy.