JackCallbackContext

Struct JackCallbackContext 

Source
pub struct JackCallbackContext { /* private fields */ }
Expand description

Context for some callbacks.

Implementations§

Source§

impl JackCallbackContext

Source

pub fn nframes(&self) -> u32

Returns the number of frames that must be processed in this callback.

Source

pub fn get_port_buffer(&self, port: &JackPort) -> Option<&mut [f32]>

Gets the buffer of a port, if the port is valid.

Examples found in repository?
examples/simple_client.rs (line 11)
10    fn process(&mut self, ctx: &JackCallbackContext) -> JackControl {
11        let inp = ctx.get_port_buffer(&self.inp).unwrap();
12        let out = ctx.get_port_buffer(&self.out).unwrap();
13        for (out, inp) in out.iter_mut().zip(inp.iter()) {
14            *out = *inp;
15        }
16        JackControl::Continue
17    }
More examples
Hide additional examples
examples/sawtooth.rs (line 13)
12    fn process(&mut self, ctx: &JackCallbackContext) -> JackControl {
13        let out1 = ctx.get_port_buffer(&self.out1).unwrap();
14        let out2 = ctx.get_port_buffer(&self.out2).unwrap();
15        for (out1, out2) in out1.iter_mut().zip(out2.iter_mut()) {
16            *out1 = self.left_saw * 0.2;
17            *out2 = self.right_saw * 0.2;
18            self.left_saw += 0.01;
19            if self.left_saw >= 1.0 { self.left_saw -= 2.0; }
20            self.right_saw += 0.03;
21            if self.right_saw >= 1.0 { self.right_saw -= 2.0; }
22        }
23        JackControl::Continue
24    }

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>,

Source§

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>,

Source§

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.