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>
impl<'pd> Context<'pd>
Sourcepub fn new(
num_input_channels: usize,
num_output_channels: usize,
block_size: usize,
sample_rate: f32,
) -> Self
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.
Sourcepub fn get_num_input_channels(&self) -> usize
pub fn get_num_input_channels(&self) -> usize
Get the number of input channels
Sourcepub fn get_num_output_channels(&self) -> usize
pub fn get_num_output_channels(&self) -> usize
Get the number of output channels
Sourcepub fn get_block_size(&self) -> usize
pub fn get_block_size(&self) -> usize
Get the audio block size we’re generating in bytes
Sourcepub fn get_sample_rate(&self) -> f32
pub fn get_sample_rate(&self) -> f32
Get the current sample rate
Sourcepub fn get_global_dsp_buffer_at_inlet(&self, inlet_index: usize) -> &[f32]
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
Sourcepub fn get_global_dsp_buffer_at_outlet(&self, outlet_index: usize) -> &[f32]
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
Sourcepub fn get_block_start_timestamp(&self) -> Timestamp
pub fn get_block_start_timestamp(&self) -> Timestamp
Returns the timestamp of the beginning of the current block
Sourcepub fn get_block_duration(&self) -> Duration
pub fn get_block_duration(&self) -> Duration
Returns the duration of one block
Sourcepub fn get_object_mut(&mut self, object_id: Id) -> Option<&mut Object>
pub fn get_object_mut(&mut self, object_id: Id) -> Option<&mut Object>
Get an object with a given object ID
Sourcepub fn get_graph_mut(&mut self, graph_id: Id) -> Option<&mut Graph>
pub fn get_graph_mut(&mut self, graph_id: Id) -> Option<&mut Graph>
Get the graph with a given graph ID
Sourcepub fn process(&mut self, input_buffers: &[f32], output_buffers: &mut [f32])
pub fn process(&mut self, input_buffers: &[f32], output_buffers: &mut [f32])
Run the Pure Data engine, processing the given input and output buffers
Sourcepub fn set_value_for_name(&mut self, name: &str, constant: f32)
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.
Sourcepub fn get_value_for_name(&self, name: &str) -> Option<f32>
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.
Sourcepub fn register_external_receiver(&mut self, receiver_name: &str)
pub fn register_external_receiver(&mut self, receiver_name: &str)
Register an external receiver.
Sourcepub fn unregister_external_receiver(&mut self, receiver_name: &str)
pub fn unregister_external_receiver(&mut self, receiver_name: &str)
Unregister an external receiver
Sourcepub fn send_message_to_named_receivers<N>(
&mut self,
_name: &str,
_message: &Message<'pd, N>,
)where
N: ArrayLength<Atom<'pd>>,
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;
Sourcepub fn schedule_external_message<N>(
&mut self,
receiver_name: &str,
_message: &Message<'pd, N>,
)where
N: ArrayLength<Atom<'pd>>,
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.
Sourcepub fn schedule_external_message_string(
&mut self,
receiver_name: &str,
timestamp: Timestamp,
init_string: &str,
) -> Result<(), Error>
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.
Sourcepub fn schedule_message<N>(
&mut self,
_message_obj: Object,
_outlet_index: Index,
_message: Message<'pd, N>,
)where
N: ArrayLength<Atom<'pd>>,
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.
Sourcepub fn cancel_message<N>(
&mut self,
_message_obj: &Object,
_outlet_index: Index,
_message: &Message<'pd, N>,
)where
N: ArrayLength<Atom<'pd>>,
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.
Sourcepub fn receive_system_message<N>(&mut self, _message: &Message<'pd, N>)where
N: ArrayLength<Atom<'pd>>,
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