ukebox/
lib.rs

1#![allow(clippy::upper_case_acronyms)]
2
3pub mod chord;
4pub mod chord_chart;
5pub mod chord_sequence;
6pub mod chord_type;
7pub mod distance;
8pub mod fingering;
9pub mod fret_pattern;
10pub mod interval;
11pub mod note;
12pub mod pitch_class;
13pub mod staff_position;
14pub mod tuning;
15pub mod voicing;
16pub mod voicing_graph;
17
18pub use chord::Chord;
19pub use chord_chart::ChordChart;
20pub use chord_sequence::ChordSequence;
21pub use chord_type::{ChordType, NoMatchingChordTypeFoundError};
22pub use distance::Distance;
23pub use fingering::Fingering;
24pub use fret_pattern::FretPattern;
25pub use interval::Interval;
26pub use note::Note;
27pub use pitch_class::PitchClass;
28pub use staff_position::StaffPosition;
29pub use tuning::Tuning;
30pub use voicing::Voicing;
31pub use voicing_graph::VoicingGraph;
32
33/// Number of strings on our string instrument.
34pub const STRING_COUNT: usize = 4;
35
36/// Number of fingers on our left hand to be used for pressing down strings.
37pub const FINGER_COUNT: usize = 4;
38
39/// Number of pitch classes.
40pub const PITCH_CLASS_COUNT: Semitones = 12;
41
42/// Minimal number of frets to be shown in a chord chart.
43pub const MIN_CHART_WIDTH: Semitones = 4;
44
45/// The ID of a fret on the fretboard. 0 corresponds to the nut,
46/// 1 corresponds to the first fret, 2 to the second etc.
47pub type FretID = u8;
48
49/// The number of semitones (corresponds to the number of frets)
50/// to move from one note or pitch class to another.
51pub type Semitones = u8;
52
53/// The number of steps in a staff to move from one staff position
54/// to another.
55pub type StaffSteps = u8;
56
57/// The position of a finger on a certain string in a certain fret.
58/// For example, (3, 4) depicts the fourth fret on the third string.
59pub type FingerPosition = (u8, u8);
60
61/// A certain configuration of a ukulele string consisting of
62/// the string's root note, the ID of a fret on this string and
63/// the note that is played if this fret is pressed down.
64pub type UkeString = (Note, FretID, Note);
65
66#[derive(Clone, Copy)]
67pub struct VoicingConfig {
68    pub tuning: Tuning,
69    pub min_fret: FretID,
70    pub max_fret: FretID,
71    pub max_span: Semitones,
72}
73
74impl Default for VoicingConfig {
75    fn default() -> Self {
76        Self {
77            tuning: Tuning::C,
78            min_fret: 0,
79            max_fret: 12,
80            max_span: 4,
81        }
82    }
83}