[−][src]Struct sonogram::SpecOptionsBuilder
A builder struct that will output a spectrogram creator when complete.
This builder will require the height and width of the final spectrogram,
at a minimum. However you can load data from a .wav file, or directly
from a Vec
Limitations
- Currently the builder only allows for one channel of audio.
Example
let mut spectrograph = SpecOptionsBuilder::new(512, 128)
.set_window_fn(utility::blackman_harris)
.load_data_from_file(&std::path::Path::new("test.wav"))?
.build();
Methods
impl SpecOptionsBuilder
[src]
pub fn new(width: u32, height: u32) -> Self
[src]
Create a new SpecOptionsBuilder. The final height and width of
the spectrogram must be supplied. Before the build
function
can be called a load_data_from_*
function needs to be called.
Arguments
width
- The final width of the spectrogram.height
- The final height of the spectrogram.
pub fn set_window_fn(&mut self, window: fn(_: u32, _: u32) -> f32) -> &mut Self
[src]
A window function describes the type of window to use during the DFT (discrete fourier transform). See (here)[https://en.wikipedia.org/wiki/Window_function] for more details.
Arguments
window
- The window function to be used.
pub fn load_data_from_file(
&mut self,
fname: &Path
) -> Result<&mut Self, SonogramError>
[src]
&mut self,
fname: &Path
) -> Result<&mut Self, SonogramError>
pub fn load_data_from_memory(
&mut self,
data: Vec<i16>,
sample_rate: u32
) -> &mut Self
[src]
&mut self,
data: Vec<i16>,
sample_rate: u32
) -> &mut Self
Load data directly from memory.
Arguments
data
- The raw wavform data that will be converted to a spectrogram.sample_rate
- The sample rate, in Hz, of the data.
pub fn downsample(&mut self, divisor: usize) -> &mut Self
[src]
Down sample the data by the given divisor. This is a cheap way of improving the performance of the FFT.
Arguments
divisor
- How much to reduce the data by.
pub fn set_verbose(&mut self) -> &mut Self
[src]
pub fn set_greyscale(&mut self) -> &mut Self
[src]
pub fn build(&self) -> Spectrograph
[src]
Last method to be called. This will calculate the colour gradients and
generate an instance of Spectrograph
.
Auto Trait Implementations
impl Send for SpecOptionsBuilder
impl Unpin for SpecOptionsBuilder
impl Sync for SpecOptionsBuilder
impl UnwindSafe for SpecOptionsBuilder
impl RefUnwindSafe for SpecOptionsBuilder
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,