pub struct Spectrogram { /* private fields */ }Implementations§
Source§impl Spectrogram
impl Spectrogram
Sourcepub fn from_raw<T: NumCast + Copy>(
buf: &[T],
width: usize,
height: usize,
) -> Result<Spectrogram, SonogramError>
pub fn from_raw<T: NumCast + Copy>( buf: &[T], width: usize, height: usize, ) -> Result<Spectrogram, SonogramError>
Create a new Spectrogram from a raw buffer. It must of the correct size (width * height). But can be of any numeric type that can be converted to f32.
§Arguments
buf- The raw buffer of data to create the spectrogram from, real numbers only.width- The width of the spectrogram.height- The height of the spectrogram.
Sourcepub fn to_png(
&mut self,
fname: &Path,
freq_scale: FrequencyScale,
gradient: &mut ColourGradient,
w_img: usize,
h_img: usize,
) -> Result<(), Error>
pub fn to_png( &mut self, fname: &Path, freq_scale: FrequencyScale, gradient: &mut ColourGradient, w_img: usize, h_img: usize, ) -> Result<(), Error>
Save the calculated spectrogram as a PNG image.
§Arguments
fname- The path to the PNG to save to the filesystem.freq_scale- The type of frequency scale to use for the spectrogram.gradient- The colour gradient to use for the spectrogram.w_img- The output image width.h_img- The output image height.
Sourcepub fn to_png_in_memory(
&mut self,
freq_scale: FrequencyScale,
gradient: &mut ColourGradient,
w_img: usize,
h_img: usize,
) -> Result<Vec<u8>, Error>
pub fn to_png_in_memory( &mut self, freq_scale: FrequencyScale, gradient: &mut ColourGradient, w_img: usize, h_img: usize, ) -> Result<Vec<u8>, Error>
Create the spectrogram in memory as a PNG.
§Arguments
freq_scale- The type of frequency scale to use for the spectrogram.gradient- The colour gradient to use for the spectrogram.w_img- The output image width.h_img- The output image height.
Sourcepub fn to_rgba_in_memory(
&mut self,
freq_scale: FrequencyScale,
gradient: &mut ColourGradient,
w_img: usize,
h_img: usize,
) -> Vec<u8> ⓘ
pub fn to_rgba_in_memory( &mut self, freq_scale: FrequencyScale, gradient: &mut ColourGradient, w_img: usize, h_img: usize, ) -> Vec<u8> ⓘ
Create the spectrogram in memory as raw RGBA format.
§Arguments
freq_scale- The type of frequency scale to use for the spectrogram.gradient- The colour gradient to use for the spectrogram.w_img- The output image width.h_img- The output image height.
Sourcepub fn to_csv(
&mut self,
fname: &Path,
freq_scale: FrequencyScale,
cols: usize,
rows: usize,
) -> Result<(), Error>
pub fn to_csv( &mut self, fname: &Path, freq_scale: FrequencyScale, cols: usize, rows: usize, ) -> Result<(), Error>
Save the calculated spectrogram as a CSV file.
§Arguments
fname- The path to the CSV to save to the filesystem.freq_scale- The type of frequency scale to use for the spectrogram.cols- The number of columns.rows- The number of rows.
Sourcepub fn to_buffer(
&self,
freq_scale: FrequencyScale,
img_width: usize,
img_height: usize,
) -> Vec<f32>
pub fn to_buffer( &self, freq_scale: FrequencyScale, img_width: usize, img_height: usize, ) -> Vec<f32>
Map the spectrogram to the output buffer. Essentially scales the frequency to map to the vertical axis (y-axis) of the output and scale the x-axis to match the output. It will also convert the spectrogram to dB.
§Arguments
freq_scale- The type of frequency scale to use for the spectrogram.img_width- The output image width.img_height- The output image height.
Sourcepub fn get_min_max(&self) -> (f32, f32)
pub fn get_min_max(&self) -> (f32, f32)
Get the minimum and maximum values from the current spectrogram.
Auto Trait Implementations§
impl Freeze for Spectrogram
impl RefUnwindSafe for Spectrogram
impl Send for Spectrogram
impl Sync for Spectrogram
impl Unpin for Spectrogram
impl UnwindSafe for Spectrogram
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more