Context

Struct Context 

Source
pub struct Context<'pd> { /* private fields */ }
Expand description

Pure Data context object: main API entrypoint and owner of all state (objects, graphs, etc).

In an Entity-Component-System (ECS) model, which this library is gradually adopting, this type is the System or ECS object.

Implementations§

Source§

impl<'pd> Context<'pd>

Source

pub fn new( num_input_channels: usize, num_output_channels: usize, block_size: usize, sample_rate: f32, ) -> Self

Create a new pd::Context. This is the first thing you’ll need to do in order to use this crate.

Source

pub fn get_num_input_channels(&self) -> usize

Get the number of input channels

Source

pub fn get_num_output_channels(&self) -> usize

Get the number of output channels

Source

pub fn get_block_size(&self) -> usize

Get the audio block size we’re generating in bytes

Source

pub fn get_sample_rate(&self) -> f32

Get the current sample rate

Source

pub fn get_global_dsp_buffer_at_inlet(&self, inlet_index: usize) -> &[f32]

Returns the global DSP buffer at the given inlet

Exclusively used by DspAdc

Source

pub fn get_global_dsp_buffer_at_outlet(&self, outlet_index: usize) -> &[f32]

Returns the global DSP buffer at the given outlet

Exclusively used by DspDac

Source

pub fn get_block_start_timestamp(&self) -> Timestamp

Returns the timestamp of the beginning of the current block

Source

pub fn get_block_duration(&self) -> Duration

Returns the duration of one block

Source

pub fn get_object_mut(&mut self, object_id: Id) -> Option<&mut Object>

Get an object with a given object ID

Source

pub fn get_graph_mut(&mut self, graph_id: Id) -> Option<&mut Graph>

Get the graph with a given graph ID

Source

pub fn process(&mut self, input_buffers: &[f32], output_buffers: &mut [f32])

Run the Pure Data engine, processing the given input and output buffers

Source

pub fn print_err(&mut self, msg: &str)

Prints the given message to error output

Source

pub fn print_std(&mut self, msg: &str)

Prints the given message to standard output

Source

pub fn set_value_for_name(&mut self, name: &str, constant: f32)

Set global floating point constant value.

Used with MessageValue for keeping track of global variables.

Source

pub fn get_value_for_name(&self, name: &str) -> Option<f32>

Get global floating point constant value.

Used with MessageValue for keeping track of global variables.

Source

pub fn register_external_receiver(&mut self, receiver_name: &str)

Register an external receiver.

Source

pub fn unregister_external_receiver(&mut self, receiver_name: &str)

Unregister an external receiver

Source

pub fn send_message_to_named_receivers<N>( &mut self, _name: &str, _message: &Message<'pd, N>, )
where N: ArrayLength<Atom<'pd>>,

Sends the given message to all receive objects with the given name.

This function is used by message boxes to send messages described be the syntax:

name message;

Source

pub fn schedule_external_message<N>( &mut self, receiver_name: &str, _message: &Message<'pd, N>, )
where N: ArrayLength<Atom<'pd>>,

Schedules a message to be sent to all receivers at the start of the next block.

Source

pub fn schedule_external_message_string( &mut self, receiver_name: &str, timestamp: Timestamp, init_string: &str, ) -> Result<(), Error>

Schedules a message described by the given string to be sent to named receivers at the given timestamp.

Source

pub fn schedule_message<N>( &mut self, _message_obj: Object, _outlet_index: Index, _message: Message<'pd, N>, )
where N: ArrayLength<Atom<'pd>>,

Schedules a pd::Message to be sent by the message::Object from the outlet_index at the specified time.

Source

pub fn cancel_message<N>( &mut self, _message_obj: &Object, _outlet_index: Index, _message: &Message<'pd, N>, )
where N: ArrayLength<Atom<'pd>>,

Cancel a scheduled pd::Message according to its id.

The message memory will be freed.

Source

pub fn receive_system_message<N>(&mut self, _message: &Message<'pd, N>)
where N: ArrayLength<Atom<'pd>>,

Receives and processes messages sent to the Pd system by sending to pd

Auto Trait Implementations§

§

impl<'pd> Freeze for Context<'pd>

§

impl<'pd> RefUnwindSafe for Context<'pd>

§

impl<'pd> Send for Context<'pd>

§

impl<'pd> Sync for Context<'pd>

§

impl<'pd> Unpin for Context<'pd>

§

impl<'pd> !UnwindSafe for Context<'pd>

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> Same for T

Source§

type Output = T

Should always be Self
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.