Skip to main content

InstrumentType

Enum InstrumentType 

Source
pub enum InstrumentType {
    Synth,
    DrumRack,
    DX7,
    Jupiter8,
    Odyssey,
    Juno60,
    Rhodes,
    Sampler,
    LittlePhatty,
}

Variants§

§

Synth

§

DrumRack

§

DX7

§

Jupiter8

§

Odyssey

§

Juno60

§

Rhodes

§

Sampler

§

LittlePhatty

Implementations§

Source§

impl InstrumentType

Source

pub const ALL: &[InstrumentType]

Appended to, never reordered: a session stores an instrument by its key rather than by position, but the menu’s own order is what a player has learned, and the preset browser walks this list.

Source

pub fn label(self) -> &'static str

Examples found in repository?
examples/session_digest.rs (line 22)
14fn main() {
15    println!("== instrument layouts ==");
16    for instrument in InstrumentType::ALL {
17        let key = session::instrument_key(*instrument);
18        println!(
19            "{key:<10} params={:<3} layout={} label={:?}",
20            param_count(*instrument),
21            layout_fingerprint(*instrument),
22            instrument.label()
23        );
24        // Every selector on the panel, and how many positions it has, because
25        // that is what a stored position is an index into.
26        let count = param_count(*instrument);
27        let mut selectors = Vec::new();
28        for param in 0..count {
29            if let Some(positions) = phosphor_app::discrete::positions(*instrument, param) {
30                selectors.push(format!("{param}:{}", positions.len()));
31            }
32        }
33        println!("           selectors {}", selectors.join(" "));
34    }
35
36    for path in std::env::args().skip(1) {
37        println!("\n== {path} ==");
38        let file = match session::load(std::path::Path::new(&path)) {
39            Ok(f) => f,
40            Err(e) => {
41                println!("  unreadable: {e}");
42                continue;
43            }
44        };
45        println!("  version {} tracks {}", file.version, file.tracks.len());
46        for track in &file.tracks {
47            let Some(instrument) = session::parse_instrument_type(&track.instrument_type) else {
48                println!("  {:<12} UNKNOWN {}", track.name, track.instrument_type);
49                continue;
50            };
51            let mut params = track.synth_params.clone();
52            let clamped = session::apply_selectors(instrument, &mut params, &track.discrete);
53            let digest: u64 = params.iter().fold(0xcbf2_9ce4_8422_2325u64, |h, v| {
54                v.to_bits().to_le_bytes().iter().fold(h, |h, b| {
55                    (h ^ u64::from(*b)).wrapping_mul(0x0000_0100_0000_01b3)
56                })
57            });
58            println!(
59                "  {:<12} {:<10} n={:<3} digest={digest:016x} clamped={clamped:?}",
60                track.name, track.instrument_type, params.len()
61            );
62        }
63    }
64}
Source

pub fn description(self) -> &'static str

Trait Implementations§

Source§

impl Clone for InstrumentType

Source§

fn clone(&self) -> InstrumentType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for InstrumentType

Source§

impl Debug for InstrumentType

Source§

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

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

impl Eq for InstrumentType

Source§

impl PartialEq for InstrumentType

Source§

fn eq(&self, other: &InstrumentType) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for InstrumentType

Auto Trait Implementations§

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more