[][src]Struct wavetable::wt_manager::WtManager

pub struct WtManager { /* fields omitted */ }

Implementations

impl WtManager[src]

pub fn new(sample_rate: Float, data_dir: &str) -> WtManager[src]

Generate a new WtManager instance.

The data_dir is the name of the directory that is used for loading wavetable files.

use wavetable::WtManager;

let wt_manager = WtManager::new(44100.0, "data");

pub fn add_basic_tables(&mut self, id: usize)[src]

Add table containing basic waveshapes with the given ID.

The wavetable added will contain data for sine, triangle, saw and square waves, 2048 samples per wave, bandlimited with one table per octave, for 11 octaves, covering the full range of MIDI notes for standard tuning.

The wave indices to use for querying sine, triangle, saw and square are 0.0, 1/3, 2/3 and 1.0 respectively.

use wavetable::WtManager;

let mut wt_manager = WtManager::new(44100.0, "data");
wt_manager.add_basic_tables(0);

pub fn add_pwm_tables(&mut self, id: usize, num_pwm_tables: usize)[src]

Add table containing pulse width modulated square waves with the given ID.

The wavetable added will contain the specified number of square waves with different amounts of pulse width modulation, 2048 samples per wave, bandlimited with one table per octave, for 11 octaves, covering the full range of MIDI notes for standard tuning.

use wavetable::WtManager;

let mut wt_manager = WtManager::new(44100.0, "data");
wt_manager.add_pwm_tables(1, 64);

pub fn get_table(&self, id: usize) -> Option<WavetableRef>[src]

Get a single wavetable by id from the cache.

use wavetable::WtManager;

let mut wt_manager = WtManager::new(44100.0, "data");
wt_manager.add_basic_tables(0);
let table_ref = wt_manager.get_table(0);

pub fn load_table(
    &mut self,
    wt_info: &mut WtInfo,
    fallback: WavetableRef,
    bandlimit: bool
)
[src]

Loads a wavetable file and adds the table to the cache.

Tries to load the table from the given file and put it into the cache. If loading the file fails, the provided fallback table is inserted instead.

The WtInfo::valid flag is set to true if loading was successfull, false if it failed.

If the flag bandlimit is set to true, the table will automatically be converted to a bandlimited version, consisting of 11 tables per wav shape with reduced number of harmonics, which means the data will consume 11 times more memory than the un-bandlimited version.

use wavetable::{WtManager, WtInfo};

let mut wt_manager = WtManager::new(44100.0, "data");
wt_manager.add_basic_tables(0);
let mut wt_info = WtInfo{
        id: 1,
        valid: false,
        name: "TestMe".to_string(),
        filename: "TestMe.wav".to_string()};
let fallback = if let Some(table) = wt_manager.get_table(0) {
    table
} else {
    panic!();
};
wt_manager.load_table(&mut wt_info, fallback, false);

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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.