pub struct InputPortHandle<SampleType> { /* private fields */ }
Implementations§
Source§impl<SampleType: Num> InputPortHandle<SampleType>
impl<SampleType: Num> InputPortHandle<SampleType>
Sourcepub fn get_read_buffer<'a>(
&self,
nframes: NumFrames,
_ctx: &'a CallbackContext,
) -> &'a [SampleType]
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>
impl InputPortHandle<MidiEvent>
Sourcepub fn get_read_buffer<'a>(
&self,
nframes: NumFrames,
_ctx: &'a CallbackContext,
) -> MidiEventBuf<'a>
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>
impl<SampleType: Clone> Clone for InputPortHandle<SampleType>
Source§fn clone(&self) -> InputPortHandle<SampleType>
fn clone(&self) -> InputPortHandle<SampleType>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<SampleType: Debug> Debug for InputPortHandle<SampleType>
impl<SampleType: Debug> Debug for InputPortHandle<SampleType>
Source§impl<SampleType> Port for InputPortHandle<SampleType>
impl<SampleType> Port for InputPortHandle<SampleType>
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> 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