Float

Trait Float 

Source
pub trait Float:
    NumTraitsFloat
    + From<u16>
    + Default
    + Copy {
Show 14 associated constants and 6 methods const ZERO: Self; const ONE: Self; const TWO: Self; const THREE: Self; const ONE_HALF: Self; const POINT_ONE: Self; const POINT_NINE_EIGHT: Self; const RES_MAX: Self; const NOTE_MAX: Self; const SHAPE_CLIP: Self; const FRAC_2_PI: Self; const FRAC_PI_2: Self; const PI: Self; const TAU: Self; // Required methods fn fsin(self) -> Self; fn fcos(self) -> Self; fn ftan(self) -> Self; fn midi_to_freq(self) -> Self; fn as_f32(self) -> f32; // Provided method fn from_u16(x: u16) -> Self { ... }
}
Expand description

Types must implement this trait to instantiate any of the generic devices in this module. Implementations are provided for f32 and f64.

Required Associated Constants§

Source

const ZERO: Self

0

Source

const ONE: Self

1

Source

const TWO: Self

2

Source

const THREE: Self

3

Source

const ONE_HALF: Self

1/2

Source

const POINT_ONE: Self

0.1

Source

const POINT_NINE_EIGHT: Self

0.98

Source

const RES_MAX: Self

0xF000 / 0xFFFF

Source

const NOTE_MAX: Self

127 * (0xFFFF / 0x10000)

Source

const SHAPE_CLIP: Self

0.9375

Source

const FRAC_2_PI: Self

2 / pi

Source

const FRAC_PI_2: Self

pi / 2

Source

const PI: Self

pi

Source

const TAU: Self

2*pi

Required Methods§

Source

fn fsin(self) -> Self

Returns the sine of self

Source

fn fcos(self) -> Self

Returns the cosine of self

Source

fn ftan(self) -> Self

Returns the tangent of self

Source

fn midi_to_freq(self) -> Self

Convert a MIDI note number to a frequency

Source

fn as_f32(self) -> f32

Convert to a f32

Provided Methods§

Source

fn from_u16(x: u16) -> Self

Creates a value of this type from a u16. Functionality provided by the trait (uses the From<u16> implementation)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Float for f32

Source§

const ZERO: f32 = 0f32

Source§

const ONE: f32 = 1f32

Source§

const TWO: f32 = 2f32

Source§

const THREE: f32 = 3f32

Source§

const ONE_HALF: f32 = 0.5f32

Source§

const POINT_ONE: f32 = 0.100000001f32

Source§

const POINT_NINE_EIGHT: f32 = 0.980000019f32

Source§

const FRAC_PI_2: f32 = 1.57079637f32

Source§

const FRAC_2_PI: f32 = 0.636619746f32

Source§

const PI: f32 = 3.14159274f32

Source§

const TAU: f32 = 6.28318548f32

Source§

const RES_MAX: f32 = 0.937514305f32

Source§

const NOTE_MAX: f32 = 126.998062f32

Source§

const SHAPE_CLIP: f32 = 0.9375f32

Source§

fn fsin(self) -> Self

Source§

fn fcos(self) -> Self

Source§

fn ftan(self) -> Self

Source§

fn midi_to_freq(self) -> Self

Source§

fn as_f32(self) -> f32

Source§

impl Float for f64

Source§

const ZERO: f64 = 0f64

Source§

const ONE: f64 = 1f64

Source§

const TWO: f64 = 2f64

Source§

const THREE: f64 = 3f64

Source§

const ONE_HALF: f64 = 0.5f64

Source§

const POINT_ONE: f64 = 0.10000000000000001f64

Source§

const POINT_NINE_EIGHT: f64 = 0.97999999999999998f64

Source§

const RES_MAX: f64 = 0.93751430533302815f64

Source§

const FRAC_PI_2: f64 = 1.5707963267948966f64

Source§

const FRAC_2_PI: f64 = 0.63661977236758138f64

Source§

const PI: f64 = 3.1415926535897931f64

Source§

const TAU: f64 = 6.2831853071795862f64

Source§

const NOTE_MAX: f64 = 126.99806213378906f64

Source§

const SHAPE_CLIP: f64 = 0.9375f64

Source§

fn fsin(self) -> Self

Source§

fn fcos(self) -> Self

Source§

fn ftan(self) -> Self

Source§

fn midi_to_freq(self) -> Self

Source§

fn as_f32(self) -> f32

Implementors§