Struct ParamValue

Source
pub struct ParamValue<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> ParamValue<'a>

Source

pub const unsafe fn new_unchecked(header: &'a Header) -> Self

§Safety

The header must be a header of type: clap_event_param_value.

Source

pub const fn channel(&self) -> i16

Source

pub const fn key(&self) -> i16

Source

pub const fn note_id(&self) -> i32

Source

pub fn param_id(&self) -> ClapId

Examples found in repository?
examples/state.rs (line 163)
155    fn process(&mut self, process: &mut clap::Process) -> Result<clap::Status, clap::Error> {
156        let in_events = process.in_events();
157
158        for i in 0..in_events.size() {
159            let header = in_events.get(i);
160
161            if let Ok(param) = header.param_value() {
162                let value = param.value();
163                let id: usize = param.param_id().into();
164
165                if id < NUM_PARAMS {
166                    self.state[id].store(value.to_bits(), Ordering::Release);
167                }
168            }
169        }
170        Ok(clap::Continue)
171    }
Source

pub const fn port_index(&self) -> i16

Source

pub const fn value(&self) -> f64

Examples found in repository?
examples/state.rs (line 162)
155    fn process(&mut self, process: &mut clap::Process) -> Result<clap::Status, clap::Error> {
156        let in_events = process.in_events();
157
158        for i in 0..in_events.size() {
159            let header = in_events.get(i);
160
161            if let Ok(param) = header.param_value() {
162                let value = param.value();
163                let id: usize = param.param_id().into();
164
165                if id < NUM_PARAMS {
166                    self.state[id].store(value.to_bits(), Ordering::Release);
167                }
168            }
169        }
170        Ok(clap::Continue)
171    }
More examples
Hide additional examples
examples/gain.rs (line 141)
121    fn process(&mut self, process: &mut clap::Process) -> Result<clap::Status, clap::Error> {
122        let mut gain = f64::from_bits(self.gain.load(Ordering::Relaxed));
123
124        let nframes = process.frames_count();
125        let nev = process.in_events().size();
126        let mut ev_index = 0;
127        let mut next_ev_frame = if nev > 0 { 0 } else { nframes };
128
129        let mut i = 0;
130        while i < nframes {
131            while ev_index < nev && next_ev_frame == i {
132                {
133                    let in_events = process.in_events();
134                    let header = in_events.get(ev_index);
135                    if header.time() != i {
136                        next_ev_frame = header.time();
137                        break;
138                    }
139
140                    if let Ok(param_value) = header.param_value() {
141                        gain = param_value.value();
142                        self.gain.store(gain.to_bits(), Ordering::Release);
143                    }
144                }
145
146                ev_index += 1;
147
148                if ev_index == nev {
149                    next_ev_frame = nframes;
150                    break;
151                }
152            }
153
154            {
155                let i = i as usize;
156                let gain = gain as f32;
157
158                // Get the input signal from the main input port.
159                let in_l = process.audio_inputs(0).data32(0)[i];
160                let in_r = process.audio_inputs(0).data32(1)[i];
161
162                let smoothed = self.smoothed.tick(gain);
163                let out_l = in_l * smoothed;
164                let out_r = in_r * smoothed;
165
166                // Write the audio signal to the main output port.
167                process.audio_outputs(0).data32(0)[i] = out_l;
168                process.audio_outputs(0).data32(1)[i] = out_r;
169            }
170
171            i += 1;
172        }
173        Ok(clap::Continue)
174    }
Source

pub const fn build() -> ParamValueBuilder

Source

pub fn update(&self) -> ParamValueBuilder

Trait Implementations§

Source§

impl<'a> Clone for ParamValue<'a>

Source§

fn clone(&self) -> ParamValue<'a>

Returns a duplicate 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<'a> Debug for ParamValue<'a>

Source§

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

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

impl Event for ParamValue<'_>

Source§

fn header(&self) -> &Header

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl<'a> PartialEq for ParamValue<'a>

Source§

fn eq(&self, other: &ParamValue<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Copy for ParamValue<'a>

Source§

impl<'a> StructuralPartialEq for ParamValue<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ParamValue<'a>

§

impl<'a> RefUnwindSafe for ParamValue<'a>

§

impl<'a> Send for ParamValue<'a>

§

impl<'a> Sync for ParamValue<'a>

§

impl<'a> Unpin for ParamValue<'a>

§

impl<'a> UnwindSafe for ParamValue<'a>

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.