Struct maia_wasm::waterfall::Waterfall

source ·
pub struct Waterfall { /* private fields */ }
Expand description

Waterfall.

This object is used to create and add a WebGL2 waterfall display to a RenderEngine and to modify the parameters of the waterfall.

Implementations§

source§

impl Waterfall

source

pub fn new( engine: &mut RenderEngine, performance: Performance ) -> Result<Waterfall, JsValue>

Creates a new waterfall, adding it to the RenderEngine.

The performance parameter should contain a performance object obtained with web_sys::Window::performance.

source

pub fn put_waterfall_spectrum(&mut self, spectrum_linear: &Float32Array)

Adds a spectrum line to the waterfall.

This function updates the waterfall by adding a new spectrum line to it. The spectrum is given in linear power units.

source

pub fn prepare_render( &mut self, engine: &mut RenderEngine, dt: f32 ) -> Result<(), JsValue>

Updates the waterfall for rendering.

This function must be called before each call to RenderEngine::render. It updates and prepares the waterfall render objects for rendering. The vale of dt should be the timestamp given to the request_animation_frame callback in which this function is called. It is currently unused, since the waterfall scroll rate is determined by how often put_waterfall_spectrum is called.

source

pub fn resize_canvas( &mut self, engine: &mut RenderEngine ) -> Result<(), JsValue>

Updates the waterfall according to the new dimensions of the canvas.

This function should be called each time that the canvas size or the device pixel ratio changes, so that the waterfall can be update accordingly.

source

pub fn set_freq_samprate( &mut self, center_freq: f64, samp_rate: f64, engine: &mut RenderEngine ) -> Result<(), JsValue>

Updates the waterfall with a new center frequency and sample rate.

The center frequency and sample rate should be given in units of Hz and samples per second.

source

pub fn get_freq_samprate(&self) -> (f64, f64)

Returns the current waterfall center frequency and sample rate.

The center frequency and sample rate are given in units of Hz and samples per second.

source

pub fn is_channel_visible(&self) -> bool

Returns whether the DDC channel is visible in the waterfall.

source

pub fn set_channel_visible(&self, visible: bool)

Sets whether the DDC channel is visible in the waterfall.

By default the channel is not visible.

source

pub fn get_channel_frequency(&self) -> f64

Returns the frequency of the DDC channel in the waterfall.

The frequency is given in Hz of offset with respect to the waterfall center frequency.

source

pub fn set_channel_frequency(&mut self, frequency: f64)

Sets the frequency of the DDC channel in the waterfall.

This function shall be called when the DDC frequency changes. The frequency is given in Hz of offset with respect to the waterfall center frequency.

This funciton must also be called when the sample rate is changed using [Self::set_freq_samp_rate].

source

pub fn set_channel_decimation(&mut self, decimation: u32)

Sets the decimation factor of the DDC channel in the waterfall.

This function shall be called when the DDC decimation factor changes.

source

pub fn load_colormap( &self, engine: &mut RenderEngine, colormap: &[u8] ) -> Result<(), JsValue>

Loads a new colormap for the waterfall.

The colormap is given as a slice whose length is a multiple of 3 and contains the concatenation of the RGB values of the list of colors that defines the colormap (typically, 256 colors are used for the colormap, so the length of the colormap slice is 3 * 256).

source

pub fn set_zoom(&mut self, zoom: f32)

Sets the zoom level of the waterfall.

source

pub fn get_zoom(&self) -> f32

Returns the current zoom level of the waterfall.

source

pub fn set_center_frequency(&mut self, frequency: f32)

Sets the center frequency of the waterfall.

This function is used when dragging the waterfall to scroll in frequency. The frequency does not use physical units, but rather has a value between -1 and 1 that corresponds to screen coordinates.

source

pub fn get_center_frequency(&self) -> f32

Returns the current center frequency of the waterfall.

The frequency is defined as in the set_center_frequency function.

source

pub fn set_waterfall_min(&mut self, value: f32)

Sets the waterfall minimum power value.

The minimum value is used to scale the colormap. The value is in dB units.

source

pub fn set_waterfall_max(&mut self, value: f32)

Sets the waterfall maximum power value.

The maximum value is used to scale the colormap. The value is in dB units.

source

pub fn get_channel_frequency_uniform(&self) -> f32

Returns the value of the uniform associated with the DDC channel frequency.

source

pub fn get_channel_width_uniform(&self) -> f32

Returns the value of the uniform associated with the DDC channel width.

source

pub fn set_waterfall_update_rate(&mut self, rate: f32)

Sets the waterfall update rate.

The waterfall update rate is used for smooth animation interpolation between waterfall lines. If the rate is not set, smooth animation interpolation is not used.

The rate is indicated in Hz (updates per second).

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.