Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
ControlPort Class Referencefinal

Control port specifics. More...

#include <src/gui/dsp/control_port.h>

Inheritance diagram for ControlPort:
Collaboration diagram for ControlPort:

Data Structures

struct  ChangeEvent
 Used for queueing changes to be applied during processing. More...
struct  ScalePoint
 Scale point. More...

Public Types

using AutomationValueGetter
 Gets the current automation value if available (eg, from an automation track).
Public Types inherited from Port
using PortIdentifier = dsp::PortIdentifier
using PortType = dsp::PortType
using PortFlow = dsp::PortFlow
using PortConnection = dsp::PortConnection

Public Member Functions

 ControlPort (utils::Utf8String label={})
float normalized_val_to_real (float normalized_val) const
 Converts normalized value (0.0 to 1.0) to real value (eg.
float real_val_to_normalized (float real_val) const
 Converts real value (eg.
bool is_toggled () const
 Returns if the control port is toggled.
int get_int () const
 Gets the control value for an integer port.
void set_unit_from_str (const utils::Utf8String &str)
 Set the identifier's port unit from the given string.
float get_snapped_val () const
 Returns the snapped value (eg, if toggle, returns 0.f or 1.f).
float get_snapped_val_from_val (float val) const
 Returns the snapped value (eg, if toggle, returns 0.f or 1.f).
float get_val () const
 Get the current real value of the control.
float get_normalized_val () const
 Get the current normalized value of the control.
float get_unsnapped_val () const
 Get the current real unsnapped value of the control.
float get_default_val () const
 Get the default real value of the control.
void set_real_val (float val)
 Get the default real value of the control.
void set_real_val_w_events (float val)
 Set the default real value of the control and sends UI events.
void set_toggled (bool toggled, bool forward_events)
 Wrapper over port_set_control_value() for toggles.
void set_val_from_normalized (float val, bool automating)
 Updates the actual value.
void set_control_value (float val, bool is_normalized, bool forward_event_to_plugin)
 Sets the given control value to the corresponding underlying structure in the Port.
void set_automation_value_reader (AutomationValueGetter reader)
 Sets the automation value reader.
RtTimePoint ms_since_last_change () const
float get_control_value (bool normalize) const
 Gets the given control value from the corresponding underlying structure in the Port.
void process_block (EngineProcessTimeInfo time_nfo) override
void clear_buffer (std::size_t block_length) override
 Clears the port buffer.
Public Member Functions inherited from Port
void init_loaded (IPortOwner &owner)
 This function finds the Ports corresponding to the PortIdentifiers for srcs and dests.
void set_owner (IPortOwner &owner)
utils::Utf8String get_label () const
bool is_control () const
bool is_audio () const
bool is_cv () const
bool is_event () const
bool is_midi () const
bool is_input () const
bool is_output () const
utils::Utf8String get_node_name () const override
 Returns a human friendly name of the node.
nframes_t get_single_playback_latency () const override
 Ports have no latency.
virtual bool has_sound () const
 If MIDI port, returns if there are any events, if audio port, returns if there is sound in the buffer.
utils::Utf8String get_full_designation () const
 Gets a full designation of the port in the format "Track/Port" or "Track/Plugin/Port".
void change_track (IPortOwner::TrackUuid new_track_id)
 Updates the owner track identifier.
bool has_label () const
PortType get_type () const
PortFlow get_flow () const
Public Member Functions inherited from zrythm::dsp::graph::IProcessable
virtual void prepare_for_processing (sample_rate_t sample_rate, nframes_t max_block_length)
 Called to allocate resources required for processing.
virtual void release_resources ()
 Called to release resources allocated by prepare_for_processing().
Public Member Functions inherited from zrythm::utils::UuidIdentifiableObject< Port >
UuidIdentifiableObjectoperator= (const UuidIdentifiableObject &other)=default
auto get_uuid () const

Static Public Member Functions

static bool is_val_toggled (float val)
 Checks if the given value is toggled.
static int get_int_from_val (float val)
 Gets the control value for an integer port.

Data Fields

float control_ = 0.f
 To be called when a control's value changes so that a message can be sent to the plugin UI.
float base_value_ = 0.f
 For control ports, when a modulator is attached to the port the previous value will be saved here.
std::vector< ScalePointscale_points_
 Scale points.
midi_byte_t midi_channel_ = 0
 MIDI channel, starting from 1.
midi_byte_t midi_cc_no_ = 0
 MIDI CC number, if not pitchbend/poly key/channel pressure.
float deff_ = 0.f
 Default value.
int carla_param_id_ = 0
 Index of the control parameter (for Carla plugin ports).
bool automating_ = false
 Whether this value was set via automation.
float unsnapped_control_ = 0.f
 Unsnapped value, used by widgets.
bool value_changed_from_reading_ {}
 Flag that the value of the port changed from reading automation.
bool received_ui_event_ {}
 Whether the port received a UI event from the plugin UI in this cycle.
Data Fields inherited from Port
std::unique_ptr< PortIdentifierid_
 Owned pointer.
IPortOwnerowner_ {}
PortRange range_
Data Fields inherited from PortConnectionsCacheMixin< CVPort >
std::vector< ElementType > port_sources_
 Caches filled when recalculating the graph.

Friends

void init_from (ControlPort &obj, const ControlPort &other, utils::ObjectCloneType clone_type)
void to_json (nlohmann::json &j, const ControlPort &p)
void from_json (const nlohmann::json &j, ControlPort &p)

Additional Inherited Members

Protected Member Functions inherited from Port
 Port (utils::Utf8String label, PortType type={}, PortFlow flow={}, float minf=0.f, float maxf=1.f, float zerof=0.f)

Detailed Description

Control port specifics.

Definition at line 15 of file control_port.h.

Member Typedef Documentation

◆ AutomationValueGetter

Initial value:
std::function<std::optional<float> (signed_frame_t global_frame)>
int_fast64_t signed_frame_t
Signed type for frame index.
Definition types.h:78

Gets the current automation value if available (eg, from an automation track).

If available, the ControlPort will be overridden to this value during processing.

Parameters
global_frameFrame in global coordinates (timeline).
Returns
Optional normalized automation value (0.0-1.0)

Definition at line 34 of file control_port.h.

Member Function Documentation

◆ clear_buffer()

void ControlPort::clear_buffer ( std::size_t block_length)
inlineoverridevirtual

Clears the port buffer.

Implements Port.

Definition at line 254 of file control_port.h.

◆ get_control_value()

float ControlPort::get_control_value ( bool normalize) const

Gets the given control value from the corresponding underlying structure in the Port.

Parameters
normalizeWhether to get the value normalized or not.

◆ get_default_val()

float ControlPort::get_default_val ( ) const
inline

Get the default real value of the control.

Definition at line 176 of file control_port.h.

◆ get_int()

int ControlPort::get_int ( ) const
inline

Gets the control value for an integer port.

Definition at line 120 of file control_port.h.

◆ get_int_from_val()

int ControlPort::get_int_from_val ( float val)
inlinestatic

Gets the control value for an integer port.

Definition at line 130 of file control_port.h.

◆ get_normalized_val()

float ControlPort::get_normalized_val ( ) const
inline

Get the current normalized value of the control.

Definition at line 162 of file control_port.h.

◆ get_snapped_val()

float ControlPort::get_snapped_val ( ) const
inline

Returns the snapped value (eg, if toggle, returns 0.f or 1.f).

Definition at line 142 of file control_port.h.

◆ get_unsnapped_val()

float ControlPort::get_unsnapped_val ( ) const
inline

Get the current real unsnapped value of the control.

Definition at line 171 of file control_port.h.

◆ get_val()

float ControlPort::get_val ( ) const
inline

Get the current real value of the control.

TODO "normalize" parameter.

Definition at line 157 of file control_port.h.

◆ is_toggled()

bool ControlPort::is_toggled ( ) const
inline

Returns if the control port is toggled.

Definition at line 115 of file control_port.h.

◆ is_val_toggled()

bool ControlPort::is_val_toggled ( float val)
inlinestatic

Checks if the given value is toggled.

Definition at line 110 of file control_port.h.

◆ ms_since_last_change()

RtTimePoint ControlPort::ms_since_last_change ( ) const
inline

Definition at line 239 of file control_port.h.

◆ normalized_val_to_real()

float ControlPort::normalized_val_to_real ( float normalized_val) const

Converts normalized value (0.0 to 1.0) to real value (eg.

-10.0 to 100.0).

Note
This behaves differently from port_set_control_value() and port_get_control_value() and should be used in widgets.

◆ process_block()

void ControlPort::process_block ( EngineProcessTimeInfo time_nfo)
overridevirtual

Reimplemented from zrythm::dsp::graph::IProcessable.

◆ real_val_to_normalized()

float ControlPort::real_val_to_normalized ( float real_val) const

Converts real value (eg.

-10.0 to 100.0) to normalized value (0.0 to 1.0).

Note
This behaves differently from port_set_control_value() and port_get_control_value() and should be used in widgets.

◆ set_automation_value_reader()

void ControlPort::set_automation_value_reader ( AutomationValueGetter reader)
inline

Sets the automation value reader.

This should be called any time before processing (the automation value reaer is only used during process_block()).

Definition at line 234 of file control_port.h.

◆ set_control_value()

void ControlPort::set_control_value ( float val,
bool is_normalized,
bool forward_event_to_plugin )

Sets the given control value to the corresponding underlying structure in the Port.

Note: this is only for setting the base values (eg when automating via an automation lane). For CV automations this should not be used.

Parameters
is_normalizedWhether the given value is normalized between 0 and 1.
forward_event_to_pluginWhether to forward a port control change event to the plugin UI. Only applicable for plugin control ports. If the control is being changed manually or from within Zrythm, this should be true to notify the plugin of the change.

◆ set_real_val()

void ControlPort::set_real_val ( float val)
inline

Get the default real value of the control.

Definition at line 181 of file control_port.h.

◆ set_real_val_w_events()

void ControlPort::set_real_val_w_events ( float val)
inline

Set the default real value of the control and sends UI events.

Definition at line 186 of file control_port.h.

◆ set_toggled()

void ControlPort::set_toggled ( bool toggled,
bool forward_events )
inline

Wrapper over port_set_control_value() for toggles.

Definition at line 194 of file control_port.h.

◆ set_val_from_normalized()

void ControlPort::set_val_from_normalized ( float val,
bool automating )

Updates the actual value.

The given value is always a normalized 0.0-1.0 value and must be translated to the actual value before setting it.

Parameters
automatingWhether this is from an automation event. This will set Lv2Port's automating field to true, which will cause the plugin to receive a UI event for this change.

◆ from_json

void from_json ( const nlohmann::json & j,
ControlPort & p )
friend

Definition at line 276 of file control_port.h.

◆ to_json

void to_json ( nlohmann::json & j,
const ControlPort & p )
friend

Definition at line 267 of file control_port.h.

Field Documentation

◆ automating_

bool ControlPort::automating_ = false

Whether this value was set via automation.

Definition at line 337 of file control_port.h.

◆ base_value_

float ControlPort::base_value_ = 0.f

For control ports, when a modulator is attached to the port the previous value will be saved here.

Automation in AutomationTrack's will overwrite this value.

Definition at line 309 of file control_port.h.

◆ carla_param_id_

int ControlPort::carla_param_id_ = 0

Index of the control parameter (for Carla plugin ports).

Definition at line 334 of file control_port.h.

◆ control_

float ControlPort::control_ = 0.f

To be called when a control's value changes so that a message can be sent to the plugin UI.

The control value.

FIXME for fader, this should be the fader_val (0.0 to 1.0) and not the amplitude.

This value will be snapped (eg, if integer or toggle).

Definition at line 301 of file control_port.h.

◆ deff_

float ControlPort::deff_ = 0.f

Default value.

Definition at line 331 of file control_port.h.

◆ midi_cc_no_

midi_byte_t ControlPort::midi_cc_no_ = 0

MIDI CC number, if not pitchbend/poly key/channel pressure.

Definition at line 326 of file control_port.h.

◆ midi_channel_

midi_byte_t ControlPort::midi_channel_ = 0

MIDI channel, starting from 1.

Definition at line 323 of file control_port.h.

◆ received_ui_event_

bool ControlPort::received_ui_event_ {}

Whether the port received a UI event from the plugin UI in this cycle.

This is used to avoid re-sending that event to the plugin.

Definition at line 350 of file control_port.h.

◆ scale_points_

std::vector<ScalePoint> ControlPort::scale_points_

Scale points.

Definition at line 312 of file control_port.h.

◆ unsnapped_control_

float ControlPort::unsnapped_control_ = 0.f

Unsnapped value, used by widgets.

Definition at line 340 of file control_port.h.

◆ value_changed_from_reading_

bool ControlPort::value_changed_from_reading_ {}

Flag that the value of the port changed from reading automation.

Definition at line 343 of file control_port.h.


The documentation for this class was generated from the following file: