Trait culsynth::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)

Object Safety§

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§