Home
Insert
Update snippet 'Musical Note Frequencies'
Title
Description
With the usual Western music it is common to use the Equal temperament: http://en.wikipedia.org/wiki/Equal_temperament http://hyperphysics.phy-astr.gsu.edu/hbase/music/et.html Then the note frequencies are calculated by this formula. For more information: http://en.wikipedia.org/wiki/Pitch_(music) http://en.wikipedia.org/wiki/Musical_tuning#Tuning_systems
Source code
/// (Infinite) list of note-frequency -pairs let tones = let bass = 55.0 let octave = ["A"; "A#"; "B"; "C"; "C#"; "D"; "D#"; "E"; "F"; "F#"; "G"; "G#"] let notes = seq { while true do yield! octave } let frequency = bass |> Seq.unfold (fun x -> Some (x, x*System.Math.Pow(2.0, 1.0 / 12.0))) Seq.zip notes frequency //let ``guitar open A`` = tones |> Seq.nth 24 // val it : float * string = (220.0, "A") //let ``A to F#`` = tones |> Seq.skip 36 |> Seq.take 10 |> Seq.toArray // [|("A", 440.0); ("A#", 466.1637615); ("B", 493.8833013); ("C", 523.2511306); // ("C#", 554.365262); ("D", 587.3295358); ("D#", 622.2539674); // ("E", 659.2551138); ("F", 698.4564629); ("F#", 739.9888454)|]
Tags
music
frequency table
music
frequency table
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update