Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Musical note frequency

Run this example

# Musical note frequencies in the 12 equal temperament system let frequency_A4: Frequency = 440 Hz # the A above middle C, A4 fn note_frequency(n: Scalar) -> Frequency = frequency_A4 * 2^(n / 12) print("A5: {note_frequency(12)}") # one octave higher up, 880 Hz print("E4: {note_frequency(7)}") print("C4: {note_frequency(-3)}")