Struct sonogram::Spectrogram
source · pub struct Spectrogram { /* private fields */ }
Implementations§
source§impl Spectrogram
impl 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.