Skip to main content

violations

Function violations 

Source
pub fn violations(
    a: &[Pitch],
    b: &[Pitch],
    rule: ConsecutiveRule,
) -> Result<Vec<(usize, usize)>>
Expand description

Every pair of parts, as part numbers, that breaks the rule moving from a to b: music21’s checker.parallelFifths and its three siblings.

use music21::Pitch;
use music21::figuredbass::checker::{ConsecutiveRule, violations};

let pitches = |names: &[&str]| -> Vec<Pitch> {
    names.iter().map(|name| Pitch::from_name(*name).unwrap()).collect()
};
let a = pitches(&["B4", "G3", "C3"]);
let b = pitches(&["A4", "A3", "D3"]);
assert_eq!(violations(&a, &b, ConsecutiveRule::ParallelFifths)?, [(2, 3)]);

§Errors

Two possibilities with different numbers of parts, or none.