ozankasikci / rust-music-theory

A music theory guide written in Rust.
MIT License
627 stars 29 forks source link

Fixes off by one error in excess octave calculation #13

Closed 0x7CFE closed 4 years ago

0x7CFE commented 4 years ago

tldr:

let scale = Scale::new(
    ScaleType::Diatonic,
    PitchClass::G,
    5,
    Some(Mode::Mixolydian)
).unwrap();

scale
    .notes()
    .iter()

Before:

Note { pitch_class: G, octave: 5 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: A, octave: 5 } (0)
Note { pitch_class: A, octave: 5 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: B, octave: 5 } (0)
Note { pitch_class: B, octave: 5 } + Interval { semitone_count: 1, quality: Minor, number: Second, step: Some(Half) } = Note { pitch_class: C, octave: 5 } (0)
Note { pitch_class: C, octave: 5 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: D, octave: 5 } (0)
Note { pitch_class: D, octave: 5 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: E, octave: 5 } (0)
Note { pitch_class: E, octave: 5 } + Interval { semitone_count: 1, quality: Minor, number: Second, step: Some(Half) } = Note { pitch_class: F, octave: 5 } (0)
Note { pitch_class: F, octave: 5 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: G, octave: 5 } (0)

After:

Note { pitch_class: G, octave: 5 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: A, octave: 5 } (0)
Note { pitch_class: A, octave: 5 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: B, octave: 5 } (0)
Note { pitch_class: B, octave: 5 } + Interval { semitone_count: 1, quality: Minor, number: Second, step: Some(Half) } = Note { pitch_class: C, octave: 6 } (1)
Note { pitch_class: C, octave: 6 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: D, octave: 6 } (0)
Note { pitch_class: D, octave: 6 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: E, octave: 6 } (0)
Note { pitch_class: E, octave: 6 } + Interval { semitone_count: 1, quality: Minor, number: Second, step: Some(Half) } = Note { pitch_class: F, octave: 6 } (0)
Note { pitch_class: F, octave: 6 } + Interval { semitone_count: 2, quality: Major, number: Second, step: Some(Whole) } = Note { pitch_class: G, octave: 6 } (0)
ozankasikci commented 4 years ago

Awesome! Could you also add tests for excess notes where the octave should be incremented, please? Otherwise, I can add them. Apparently I missed those tests in the first place.

ozankasikci commented 4 years ago

Merging this one as @henryksloan opened a PR for the requested test!