Skip to main content

Module pitch

Module pitch 

Source
Expand description

Pitch classes, spelling for display and the three middle-C labels.

Inside the tool a pitch is a MIDI number and a pitch class an integer from 0 (C) to 11 (B). Names are for display only. MIDI fixes note 60 as middle C but names no octave, so programs label it C3, C4 or C5; an OctaveLabel names each convention by that label.

use sound_to_patch::music::pitch::{OctaveLabel, Spelling, note_name, parse_note};

assert_eq!(note_name(60, OctaveLabel::C4, Spelling::Sharps), "C4");
assert_eq!(note_name(60, OctaveLabel::C3, Spelling::Sharps), "C3");
assert_eq!(parse_note("A-1", OctaveLabel::C3)?, 21);

Structs§

NoteReading
A note name read without a stated convention.

Enums§

OctaveLabel
A convention for octave numbers, named by the label it gives note 60.
Spelling
Whether a name uses sharps or flats.

Functions§

class_name
The name of a pitch class.
note_name
The name of a MIDI pitch in a convention, such as C4 or A-1.
parse_note
The MIDI pitch of a note name in a convention: a letter, up to two sharps or flats and an octave number, such as C4, F#2 or A-1.
pitch_class
The pitch class of a MIDI number.
read_note
Reads a note name when the producer names no convention.