diff --git a/examples/autumn_leaves.rs b/examples/autumn_leaves.rs new file mode 100644 index 0000000..1c3a8d1 --- /dev/null +++ b/examples/autumn_leaves.rs @@ -0,0 +1,21 @@ +use musika_rs::{Bar, A, B, C, D, E, F, G}; + +fn main() { + let chord = E.dom7(); + println!("E7: {chord:X}"); + + let bar0 = Bar::new().with_silence(1); + let bar1 = Bar::new().with_chord(D.min7(), 1); + let bar2 = Bar::new().with_chord(G.dom7(), 1); + let bar3 = Bar::new().with_chord(C.maj7(), 1); + let bar4 = Bar::new().with_chord(F.maj7(), 1); + let bar5 = Bar::new().with_chord(B.min7b5(), 1); + let bar6 = Bar::new().with_chord(E.dom7(), 1); + let bar7 = Bar::new().with_chord(A.min7(), 1); + let s = [bar0, bar1, bar2, bar3, bar4, bar5, bar6, bar7] + .into_iter() + .map(|bar| format!("{bar}")) + .collect::>() + .join(" | "); + println!("LH: | {s} |"); +} diff --git a/src/scales/penta_minor.rs b/src/scales/penta_minor.rs new file mode 100644 index 0000000..e86f879 --- /dev/null +++ b/src/scales/penta_minor.rs @@ -0,0 +1,35 @@ +use super::Scales; +use crate::Note; + +pub fn minor(tonic: Note) -> Scales { + let steps = [3, 2, 2, 3]; + Scales::minor_with_steps(" penta_minor", tonic, steps.into_iter()) +} + +pub fn pentatonic_minor(tonic: Note) -> Scales { + let steps = [3, 2, 2, 3, 2]; + Scales::minor_with_steps(" penta minor", tonic, steps.into_iter()) +} +#[cfg(test)] +mod tests { + use super::*; + use crate::{A, C}; + + #[test] + fn test_minor() { + let scale = minor(C); + assert_eq!(format!("{scale:X}"), "C minor [C, D, D#, F, G, G#, A#, C]"); + assert_eq!(format!("{scale:x}"), "C minor [C, D, Eb, F, G, Ab, Bb, C]"); + } + + #[test] + fn test_penta_minor() { + let scale = pentatonic_minor(A); + assert_eq!(format!("{scale:X}"), "A penta minor [A, C, D, E, G, A]"); + assert_eq!(format!("{scale:x}"), "A penta minor [A, C, D, E, G, A]"); + + let scale = pentatonic_minor(D); + assert_eq!(format!("{scale:X}"), "D penta minor [D, E, F, G, B, D]"); + assert_eq!(format!("{scale:x}"), "D penta minor [D, E, F, G, B, D]"); + } +}