Struct InputPortHandle

Source
pub struct InputPortHandle<SampleType> { /* private fields */ }

Implementations§

Source§

impl<SampleType: Num> InputPortHandle<SampleType>

Source

pub fn get_read_buffer<'a>( &self, nframes: NumFrames, _ctx: &'a CallbackContext, ) -> &'a [SampleType]

Get the input port’s readable buffer

Examples found in repository?
examples/thru.rs (line 35)
32    fn process(&mut self, ctx: &jack::CallbackContext, nframes: jack::NumFrames) -> i32 {
33        // for each of our inputs and outputs, copy the input buffer into the output buffer
34        for index in 0..self.inputs.len() {
35            let i = self.inputs[index].get_read_buffer(nframes, ctx);
36            let o = self.outputs[index].get_write_buffer(nframes, ctx);
37            o.clone_from_slice(i);
38        }
39
40
41        // return 0 so jack lets us keep running
42        0
43    }
Source§

impl InputPortHandle<MidiEvent>

Source

pub fn get_read_buffer<'a>( &self, nframes: NumFrames, _ctx: &'a CallbackContext, ) -> MidiEventBuf<'a>

returns a vector of midi events Note that this returns by value (we are not returning by reference, like we have in the other get_read_buffer methods)

Examples found in repository?
examples/midi_sine.rs (line 100)
98    fn process(&mut self, ctx: &jack::CallbackContext, nframes: jack::NumFrames) -> i32 {
99        let output_buffer = self.output.get_write_buffer(nframes, &ctx);
100        let input_buffer  = self.input.get_read_buffer(nframes, &ctx);
101
102        let mut event_index = 0;
103        let event_count = input_buffer.len();
104
105        for i in 0..(nframes as usize) {
106            if event_index < event_count {
107                let event = input_buffer.get(event_index);
108
109                println!("evi={} evt={}, i={}", event_index, event.get_jack_time(), i);
110                if event.get_jack_time() == i as jack::NumFrames {
111                    let buf = event.raw_midi_bytes();
112
113                    if buf[0] & 0x90 == 0x90 {
114                        println!("note on!");
115                        self.note    = buf[1];
116                        self.note_on = 1.0;
117                    } else if buf[0] & 0x90 == 0x80 {
118                        println!("note off!");
119                        self.note    = buf[1];
120                        self.note_on = 0.0;
121                    }
122                    event_index += 1;
123                    if event_index < event_count {
124                        event_index += 1;
125                    }
126                }
127            }
128
129            self.ramp += self.note_freqs[self.note as usize];
130            self.ramp = if self.ramp > 1.0 { self.ramp - 2.0 } else { self.ramp };
131
132            let s = (2.0 * (consts::PI) * self.ramp).sin();
133            output_buffer[i] = self.note_on*s;
134            // println!("output_buffer[{}] = {}", i, output_buffer[i]);
135        }
136
137        match self.incoming.try_recv() {
138            Ok(freqs) => self.note_freqs = freqs,
139            Err(_) => (),
140        };
141
142        0
143    }

Trait Implementations§

Source§

impl<SampleType: Clone> Clone for InputPortHandle<SampleType>

Source§

fn clone(&self) -> InputPortHandle<SampleType>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<SampleType: Debug> Debug for InputPortHandle<SampleType>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<SampleType> Port for InputPortHandle<SampleType>

Source§

fn get_name(&self) -> String

Gets the port’s assigned full name (including the client name and the colon)
Source§

fn get_port_flags(&self) -> PortFlags

Get the flags used to construct this port
Source§

impl<SampleType: Copy> Copy for InputPortHandle<SampleType>

Auto Trait Implementations§

§

impl<SampleType> Freeze for InputPortHandle<SampleType>

§

impl<SampleType> RefUnwindSafe for InputPortHandle<SampleType>
where SampleType: RefUnwindSafe,

§

impl<SampleType> !Send for InputPortHandle<SampleType>

§

impl<SampleType> !Sync for InputPortHandle<SampleType>

§

impl<SampleType> Unpin for InputPortHandle<SampleType>
where SampleType: Unpin,

§

impl<SampleType> UnwindSafe for InputPortHandle<SampleType>
where SampleType: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.