TuningFork.Notes (TuningFork v0.1.0)

Copy Markdown View Source

Pitches, scales and chords by note name, such as :a4, :fs3 or :eb5.

Notes.scale(:a3, :minor_pentatonic)

Summary

Functions

A chord from root, as note names. name must be one of chords/0.

The names chord/2 accepts.

The frequency of a note name in Hz; :a4 is 440.0.

The name of a MIDI number, using sharps: name_of(semitone(:eb5)) is :ds5.

A scale from root, as note names, ascending.

The names scale/3 accepts.

The MIDI number of a note name, with :a4 being 69.

The frequency interval semitones from name. A negative interval goes down.

Functions

chord(root, name)

@spec chord(atom(), atom()) :: [atom()]

A chord from root, as note names. name must be one of chords/0.

chords()

@spec chords() :: [atom()]

The names chord/2 accepts.

freq(hz)

@spec freq(atom() | number()) :: float()

The frequency of a note name in Hz; :a4 is 440.0.

A note name is a letter a to g, an optional s for sharp or b for flat, then an octave, which may be negative. A number is returned as a float unchanged. An atom that is not a note name raises ArgumentError.

name_of(midi)

@spec name_of(integer()) :: atom()

The name of a MIDI number, using sharps: name_of(semitone(:eb5)) is :ds5.

scale(root, name, opts \\ [])

@spec scale(atom(), atom(), keyword()) :: [atom()]

A scale from root, as note names, ascending.

name must be one of scales/0. :octaves gives that many octaves, each continuing upwards from the last rather than starting again; default 1.

scales()

@spec scales() :: [atom()]

The names scale/3 accepts.

semitone(name)

@spec semitone(atom() | String.t()) :: integer()

The MIDI number of a note name, with :a4 being 69.

Takes the name as an atom or a string; the string need not exist as an atom. Raises ArgumentError on anything that is not a note name.

step(name, interval)

@spec step(atom() | number(), integer()) :: float()

The frequency interval semitones from name. A negative interval goes down.