1use std::{cmp::Ordering, collections::HashMap};
2
3use crate::{defaults::IntegerType, stepname::StepName};
4
5pub(crate) mod concretescale;
6pub mod diatonicscale;
8pub mod hexatonicblues;
9pub(crate) mod realized;
11pub mod scaletype;
12pub mod stepscale;
13
14pub use diatonicscale::DiatonicScale;
15pub use hexatonicblues::{BluesForm, WeightedHexatonicBlues};
16pub use scaletype::{
17 DegreeComparison, HUMDRUM_SOLFEG_SYLLABLES, SOLFEG_SYLLABLES, Scale, ScaleType, SolfegVariant,
18};
19pub use stepscale::StepScale;
20
21pub(crate) const FIFTHS_ORDER_SHARP: [StepName; 7] = [
22 StepName::F,
23 StepName::C,
24 StepName::G,
25 StepName::D,
26 StepName::A,
27 StepName::E,
28 StepName::B,
29];
30pub(crate) const FIFTHS_ORDER_FLAT: [StepName; 7] = [
31 StepName::B,
32 StepName::E,
33 StepName::A,
34 StepName::D,
35 StepName::G,
36 StepName::C,
37 StepName::F,
38];
39
40pub(crate) fn altered_steps_from_sharps(sharps: IntegerType) -> HashMap<StepName, IntegerType> {
41 let mut map = HashMap::new();
42 match sharps.cmp(&0) {
45 Ordering::Greater => {
46 for step in FIFTHS_ORDER_SHARP.iter().cycle().take(sharps as usize) {
47 *map.entry(*step).or_insert(0) += 1;
48 }
49 }
50 Ordering::Less => {
51 for step in FIFTHS_ORDER_FLAT.iter().cycle().take((-sharps) as usize) {
52 *map.entry(*step).or_insert(0) -= 1;
53 }
54 }
55 Ordering::Equal => {}
56 }
57 map
58}