The velocity of a wave is equal to it’s frequency times it’s wavelength — (v = f * λ) — Frequency is measured in Hertz (Hz) which is the crests of the wave that pass a fixed point per second. Wavelength is measured in meters from crest to crest (or more realistically in nanometers). Velocity is measured in meters per second.

Two things to note here. First, an audible sound wave has a fixed velocity when traveling through air (343 meters per second) this is what you commonly hear called “the speed of sound”. Any sound wave will travel at this velocity, the only way to change the velocity is to change the medium that the wave is traveling through. Second, the amplitude of a wave has no effect on it’s velocity. A sound wave will displace air particles as it travels, a larger amplitude means that more particles will be displaced but the wave still travels at the same speed. Amplitude affects the volume of a sound not the pitch.

Which means for audible sound waves the values that are variable from note to note are the frequencies and the wavelengths, and those change inversely to each other. So for all intents and purposes the only thing that varies from one “note” to another is the frequency of the sound wave it produces. When someone refers to a “note” they are referring to a frequency. When someone refers to a “pitch” they are also referring to a frequency. A “higher pitch” means a higher frequency. The range of human hearing is ~20Hz to 20,000Hz you can test that here if you’re curious what range you’re personally capable of hearing.

There are twelve “notes” used in western music: A, A#, B, C, C#, D, D#, E, F, F#, G, G#

If you’re any kind of sensible hacker this will immediately raise some questions like “why is there no B# or E#?”, “how are there only 12 notes when there are 88 keys on a piano?”, “how exactly does the Latin alphabet connect to physics anyway?” etc…

Back before we had oscilloscopes and other ways to computationally measure wavelengths people still made music. And one of the things they figured out was that you could change the “pitch” of a sound wave by vibrating a string faster or slower. The faster you vibrated a string the “higher” the pitch seemed to be. And as you raised the pitch higher and higher it would eventually reach a point where the sound seemed to match a previous lower sound that it had made. Almost as if the two pitches were different shades of the same color. You’re probably already somewhat aware of this idea, if you sing “do re mi fa so la ti do” there’s something similar about the two “do”s even though you’re at a higher pitch when you sing the second one.

These similar sounds got classified as letters of the alphabet (A, B, C etc..) and you could add a number next to them to differentiate which one was the higher sound. So there could be an A0, A1, A2, A3, A4, A5, A6, A7, A8 etc… where each number was a higher pitch where the sound had that similar quality to the lower sound.

When humans first figured out how to measure wave frequencies in the 1800’s, we discovered that the places where sounds were “similar” were where the frequency was exactly 2x the other one. So the sound classified as A3 turned out to have 2x the frequency as the sound at A2.

That’s the first insight that you need. The “pitch” of a note refers to a frequency (in Hz). A sound wave of frequency 49Hz is called a “G”. A sound wave of frequency 98Hz is also called a “G”.

G0 = 24.50 Hz

G1 = 49.00 Hz

G2 = 98.00 Hz

G3 = 196.00 Hz

G4 = 392.00 Hz

G5 = 783.99 Hz

G6 = 1567.98 Hz

G7 = 3135.96 Hz

G8 = 6271.93 Hz

Things like “sharps” and “flats” are arbitrary constructs. The note we call A4 has a frequency of 440Hz. The note we call B4 has a frequency of 493.88Hz. The note we call A#4 has a frequency of 466.16Hz. Sharps aren’t real things, they’re just a hack because musicians used discrete alphanumeric values to represent continuous numbers and then went back and wanted to add things in between.

You could just as easily use numbers instead of letters and call the notes 1,2,3,4,5,6,7,8,9,10,11,12 and it would probably be slightly more logical.

Because notes are just frequencies, you can think of notes as being of type float.