Hey
Sorry if this is a dumb questions, but I became really confused by how Audacity handles the sample rate. I was 100% sure I knew what the sample rate does, but now I am not so certain. To keep it simple, say I generate a tone for a duration of 1 second. I then change the sample rate from 44100 to 22050Hz and my tone doubles from 1 second to 2 seconds. I cannot figure out why it would do this? Is this desired behavior?
Is the sample rate simply how many points it takes in a given second. This was my original understanding. E.g. 44100 is how many points along lets say a sine wave would be taken in a given second of the sine waves life? So in theory, if I had a sine wave with a frequency of ‘44100’ , then it would be sampled 44100 times exactly.
If I were to generate a sine wave at 200Hz then it would be sampled a total of (44100220.5) times (math below).
1/200Hz = period 0.005
1/44100 = 0.000022676
(0.005/0.000022676) = 220.5
And using the same math, a sampling rate of 22050 for a sine wave of 200Hz would be (22050110.25) times. So sampled half as much.
I guess I am confused as to why my audio sample grew (given that the above math is correct. Is the sampling rate sampling the period of the sine wave some how or am I missing something. Does it simply say at a frequency of 44100 that I have so many points, and when I go to 22050 I still have as many points so lets extend the duration to use all those points with the 22050Hz sample. It would have to resample each point I am guessing as the points from the 44100 sampling are not the same points that would be sampled in a 22050 sampling (e.g. they would each sample at different parts of the sine wave (actually the 22050 should sample the same points as the 44100, just fewer over the same period of time)). So if it had to resample anyways, I am not sure why it just did not resample only as many points were needed for the 1 second duration. I am very concerned my understanding is now flawed though as a result of the time growth. That was very unexpected (I am also very new to audio programming).
Also, since I am asking questions, what would happen if I were to generate a sine wave of 88000 and only want a single sample at 44100. So the duration of this would actually be smaller then the duration of the number of samples I would get in 44100 (1.1364E-5 vs 2.2676E-5 seconds). Is this possible for an audio format to handle (I know that its not a very likely scenario that anyone would need this or even be able to hear it. I am just curious if this would break things as I would really be playing something with nearly half as many samples as needed to be at 44100Hz).
Thanks