Problem with last sample


(I’m not sure whether this question is related to audio processing.)

  1. When I generate (say) 3 samples of tone (or noise for that matter) in Audacity, the waveform shows a connecting line only until second sample. Why is it not connected to the third sample?

  2. What is the time of the first sample? Is it 0 or 1/Sampling_Rate or something else?



If you generate 3 samples, you should get one sample at the beginning (t=0), a second sample at 1/(sample rate), and a third sample at 2/(sample rate)

Just tested on Audacity 1.3.12 (Linux) and it works as expected.

Thank you for your time on this trivial question but please see the screen-shot attached. I have kept the cursor at 3rd sample (using → arrow keys on keyboard) and the waveform doesn’t seem to connect to it. What am I doing wrong?

I’m using Audacity 1.3.12 (beta, on Windows).


If you zoom-in really close (as you have done) so you can see individual samples, (the dots on the waveform line),
there is sometimes a gap one sample wide on the waveform display without a line connecting two parts …
Audacity gap one sample wide #.gif
This apparent break in the line usually doesn’t affect the sound: the break is graphical rather than an actual discontinuity in the waveform.

The first sample is at time = 0.00000 (if you look closely at the extreme left edge of the track you can see a dot - or is it half a dot :slight_smile: )
So this first sample you could say is the 0’th sample. If you generate 1 sample, this will be the one and only dot.

You can also see the 2nd and 3rd samples, and your cursor is at the position of the 4th sample.
It’s a bit like birthdays; on your 3rd birthday you are in your 4th year. Your first actual birthday is the day that you are born - your 0’th birthday, after which you are into your first year. Similarly, the first sample is at time = 0, the second sample is positioned 1 sample period after 0, and the third sample is positioned 2 periods after 0. Your cursor is positioned 3 periods after 0 (as indicated by the number at the bottom), which is where the 4th sample would go if there was one.

The box at the bottom is a “time” counter. Usually you have it set to seconds, or some other obvious unit of time. When set to “Samples”, it is still measuring time periods, but in this case the time period is “sample periods”. Just as you would expect seconds to count up from 0, so too the sample periods count up from 0.

Yes, thanks to both of you, I get it now. It was just that my cursor always went one sample ahead (even when I generate a single sample, the cursor can still go to right by 1/Sampling_Rate) of the last sample that caused confusion.