Struct Frets

Source
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>

Source

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
Source§

impl Frets<6>

Source

pub fn new_four_string(frets: [i16; 4]) -> Self

Creates a chord where the first four strings are specified and the last two are muted.

Trait Implementations§

Source§

impl<const N: usize> Clone for Frets<N>

Source§

fn clone(&self) -> Frets<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for Frets<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> From<[i16; N]> for Frets<N>

Source§

fn from(frets: [i16; N]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> Hash for Frets<N>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const N: usize> PartialEq for Frets<N>

Source§

fn eq(&self, other: &Frets<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> Copy for Frets<N>

Source§

impl<const N: usize> Eq for Frets<N>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,