pub struct Frets<const N: usize>(pub [Option<i16>; N]);
Expand description
Represents fret positions on a string instrument.
This type stores the fret positions for each string, where None
indicates
a muted string and Some(fret_number)
indicates which fret to press.
§Example
use symphoxy::instrument_tools::strings::{GuitarTuning, GuitarFrets};
use symphoxy::prelude::*;
use symphoxy::scales::tet12::{A4, get_note_name};
// GuitarTuning is an alias for StringTuning<6>
let tuning = GuitarTuning::DEFAULT_GUITAR_TUNING;
let g_major_frets = GuitarFrets::new_full([3, 0, 0, 0, 2, 3]);
let g_major_chord = tuning.get_chord(&g_major_frets);
// Check each note is a G, B, or D
assert!(g_major_chord.0.into_iter().all(|pitch|
get_note_name(pitch, A4) == "G" ||
get_note_name(pitch, A4) == "B" ||
get_note_name(pitch, A4) == "D"
));
Tuple Fields§
§0: [Option<i16>; N]
Implementations§
Source§impl<const N: usize> Frets<N>
impl<const N: usize> Frets<N>
Sourcepub fn new_full(frets: [i16; N]) -> Self
pub fn new_full(frets: [i16; N]) -> Self
Creates a new fret configuration where all strings are fretted.
Takes an array of fret numbers and converts them to Some(fret)
for each string.
No strings will be muted with this constructor.
§Examples
use symphoxy::instrument_tools::strings::*;
let all_fretted = GuitarFrets::new_full([3, 2, 0, 0, 3, 3]); // All strings active
Trait Implementations§
impl<const N: usize> Copy for Frets<N>
impl<const N: usize> Eq for Frets<N>
impl<const N: usize> StructuralPartialEq for Frets<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Frets<N>
impl<const N: usize> RefUnwindSafe for Frets<N>
impl<const N: usize> Send for Frets<N>
impl<const N: usize> Sync for Frets<N>
impl<const N: usize> Unpin for Frets<N>
impl<const N: usize> UnwindSafe for Frets<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more