In this case, w is the wavelength calculated from frequency using the formula w = 1 / f. This value is used in a “for” loop to count to the number of cycles required. The number of cycles is simply the duration of the note divided by w. Wavelength (w) and frequency (f) are related, by the equations below.Ī complete period is one wavelength (w) therefore, a half period is w/2. The sound principle is very simple and anyone with basic knowledge should understand it.