Trait lipsi::SetOperations
[−]
[src]
pub trait SetOperations { fn complement(&self) -> Self; fn retrograde(&self) -> Self; fn sort(&self) -> Self; fn rotate(&self, _: usize) -> Self; fn zero(&self) -> Self; fn normal(&self) -> Self; fn reduced(&self) -> Self; fn prime(&self) -> Self; fn intervals(&self) -> Vec<i8>; fn transposition_number(&self, other: &Self) -> Option<i8>; fn index_number(&self, other: &Self) -> Option<i8>; }
Required Methods
fn complement(&self) -> Self
Returns the complement of the pitch-class set
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.complement(), vec![0,4,5,6,7,8,9,10,11]);
fn retrograde(&self) -> Self
Returns the retrograde of the pitch-class set
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.retrograde(), vec![3,2,1]);
fn sort(&self) -> Self
Returns the sorted pitch-class set in ascending order
Examples
use lipsi::*; let pcset: PcSet = vec![3,2,1]; assert_eq!(pcset.sort(), vec![1,2,3]);
fn rotate(&self, _: usize) -> Self
Returns the rotation of the pitch-class set by n semitones
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.rotate(4), vec![3,1,2]);
fn zero(&self) -> Self
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.zero(), vec![0,1,2]);
fn normal(&self) -> Self
Returns the normal form of the pitch-class set
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.normal(), vec![1,2,3]);
fn reduced(&self) -> Self
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.reduced(), vec![0,1,2]);
fn prime(&self) -> Self
Returns the prime form of the pitch-class set
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.prime(), vec![0,1,2]);
fn intervals(&self) -> Vec<i8>
Helper function that returns a vector containing the interval-classes for the first and n to last pitch-class in a pitch-class set
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; assert_eq!(pcset.intervals(), vec![2,1,0]);
fn transposition_number(&self, other: &Self) -> Option<i8>
Returns the transposition number of two pitch-class sets if they are related by transposition
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; let other: PcSet = vec![5,6,7]; assert_eq!(pcset.transposition_number(&other), Some(4));
fn index_number(&self, other: &Self) -> Option<i8>
Returns the index number of two pitch-class sets if they are related by inversion
Examples
use lipsi::*; let pcset: PcSet = vec![1,2,3]; let other: PcSet = vec![3,2,1]; assert_eq!(pcset.index_number(&other), Some(4));
Implementors
impl SetOperations for PcSet