Enum Sample

Source
pub enum Sample {
    I16(i16),
    I32(i32),
    F32(f32),
}

Variants§

§

I16(i16)

§

I32(i32)

§

F32(f32)

Implementations§

Source§

impl Sample

Source

pub fn decode_f64(&self, channel: &ChannelMetadata) -> f64

Calculates the final value of this sample as a f64

Examples found in repository?
examples/read.rs (line 40)
5fn main() -> I2Result<()> {
6    let path = env::args()
7        .skip(1)
8        .next()
9        .unwrap_or("./samples/Sample1.ld".into());
10    println!("Reading file: {}", path);
11
12    let mut file = File::open(path).expect("Failed to open file!");
13    let mut reader = LDReader::new(&mut file);
14
15    let header = reader.read_header()?;
16    println!("Header: {:#?}", header);
17
18    let event = reader.read_event()?;
19    println!("Event: {:#?}", event);
20
21    let venue = reader.read_venue()?;
22    println!("Venue: {:#?}", venue);
23
24    let vehicle = reader.read_vehicle()?;
25    println!("Vehicle: {:#?}", vehicle);
26
27    let channels = reader.read_channels()?;
28    println!("File has {} channels", channels.len());
29
30    let channel = &channels[0];
31    println!(
32        "Reading channel 0: {} ({} samples at {} Hz)",
33        channel.name, channel.data_count, channel.sample_rate
34    );
35    println!("Channle: {:#?}", channel);
36
37    let data = reader.channel_data(channel)?;
38    for i in 0..6 {
39        let sample = &data[i];
40        let value = sample.decode_f64(channel);
41        println!("[{}]: {:.1} - (Raw Sample: {:?})", i, value, sample);
42    }
43
44    Ok(())
45}

Trait Implementations§

Source§

impl Clone for Sample

Source§

fn clone(&self) -> Sample

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Sample

Source§

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

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

impl PartialEq for Sample

Source§

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

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

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 StructuralPartialEq for Sample

Auto Trait Implementations§

§

impl Freeze for Sample

§

impl RefUnwindSafe for Sample

§

impl Send for Sample

§

impl Sync for Sample

§

impl Unpin for Sample

§

impl UnwindSafe for Sample

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