[][src]Struct thorium::dmg_apu::FrequencySweep

pub struct FrequencySweep {
    pub frequency_setting: u16,
    pub rate: i8,
    pub shift: u8,
    pub samples: usize,
}

Fields

frequency_setting: u16

The frequency setting is an 11-bit value.

  • 131072/(2048-x) Hz
  • Should always be set in the range 0..2048
rate: i8

How often the frequency will sweep up or down.

  • Given in 1/128th Sec units, correct range is +/- 7.
  • + sweeps the frequency up, - sweeps the frequency down.
  • Use 0 for no sweeping.
shift: u8

How much to sweep by when a sweep happens.

samples: usize

How many samples until we trigger a sweep and re-assess things.

Methods

impl FrequencySweep[src]

pub fn setting_for(target: i32) -> u16[src]

Gets the frequency setting that is as close as possible to the target.

pub fn samples_until_trigger(rate: i8, samples_per_second: i32) -> usize[src]

Given a rate and SPS, how many samples until the effect triggers.

If the rate is 0, it will "never" trigger, so usize::MAX is given.

pub fn new(freq: i32, rate: i8, shift: u8, samples_per_second: i32) -> Self[src]

Constructs a new FrequencySweep with appropriate settings

Does a debug_assert! that all values are correct.

pub fn frequency(&self) -> i32[src]

Obtains the real frequency of the current frequency setting.

pub fn in_samples_per_out_sample(&self, samples_per_second: i32) -> f32[src]

pub fn tick_sample(&mut self, samples_per_second: i32) -> SweepTickResult[src]

Ticks down a sample, returns if the effect actually changed the frequency.

Trait Implementations

impl Clone for FrequencySweep[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Copy for FrequencySweep[src]

impl Default for FrequencySweep[src]

impl Debug for FrequencySweep[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]