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

A TrackProcessor is a processor that is used as the first entry point when processing a track. More...

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

Inheritance diagram for TrackProcessor:
Collaboration diagram for TrackProcessor:

Public Types

using SixteenPortUuidArray = std::array<PortUuidReference, 16>
 
- Public Types inherited from IPortOwner
using TrackUuid = dsp::PortIdentifier::TrackUuid
 
using PluginUuid = dsp::PortIdentifier::PluginUuid
 
using PortUuid = dsp::PortIdentifier::PortUuid
 

Public Member Functions

 TrackProcessor (ProcessableTrack &track, PortRegistry &port_registry, bool new_identity)
 Creates a new track processor for the given track.
 
bool is_in_active_project () const override
 
bool is_audio () const
 
bool is_midi () const
 
void set_port_metadata_from_owner (dsp::PortIdentifier &id, PortRange &range) const override
 Function that will be called by the Port to update the identifier's relevant members based on this port owner.
 
void on_control_change_event (const dsp::PortIdentifier::PortUuid &port_uuid, const dsp::PortIdentifier &id, float value) override
 Will be called when a control port's value changes.
 
utils::Utf8String get_full_designation_for_port (const dsp::PortIdentifier &id) const override
 
bool should_sum_data_from_backend () const override
 Whether during processing, the port should sum the data from its backend buffers coming in.
 
bool should_bounce_to_master (utils::audio::BounceStep step) const override
 Whether the port should add its data to the master output when bouncing.
 
bool are_events_on_midi_channel_approved (midi_byte_t channel) const override
 Returns whether MIDI events on this channel on an input port should be processed (not ignored).
 
void on_midi_activity (const dsp::PortIdentifier &id) override
 Called during processing if the MIDI port contains new MIDI events.
 
dsp::PortConnectionsManagerget_port_connections_manager () const
 
ProcessableTrackget_track () const
 
void init_loaded (ProcessableTrack *track, PortRegistry &port_registry)
 Inits a TrackProcessor after a project is loaded.
 
void clear_buffers (std::size_t block_length)
 Clears all buffers.
 
void disconnect_all ()
 Disconnects all ports connected to the TrackProcessor.
 
void process (const EngineProcessTimeInfo &time_nfo)
 Process the TrackProcessor.
 
void disconnect_from_prefader ()
 Disconnect the TrackProcessor's stereo out ports from the prefader.
 
void connect_to_prefader ()
 Connects the TrackProcessor's stereo out ports to the Channel's prefader in ports.
 
void disconnect_from_plugin (gui::old_dsp::plugins::Plugin &pl)
 Disconnect the TrackProcessor's out ports from the Plugin's input ports.
 
void connect_to_plugin (gui::old_dsp::plugins::Plugin &pl)
 Connect the TrackProcessor's out ports to the Plugin's input ports.
 
void append_ports (std::vector< Port * > &ports)
 
void init_after_cloning (const TrackProcessor &other, ObjectCloneType clone_type) override
 Initializes the cloned object.
 
std::pair< AudioPort &, AudioPort & > get_stereo_in_ports () const
 
std::pair< AudioPort &, AudioPort & > get_stereo_out_ports () const
 
ControlPortget_mono_port () const
 
ControlPortget_input_gain_port () const
 
ControlPortget_output_gain_port () const
 
ControlPortget_monitor_audio_port () const
 
MidiPortget_midi_in_port () const
 
MidiPortget_midi_out_port () const
 
MidiPortget_piano_roll_port () const
 
ControlPortget_midi_cc_port (int channel_index, int cc_index) const
 
ControlPortget_pitch_bend_port (int channel_index) const
 
ControlPortget_poly_key_pressure_port (int channel_index) const
 
ControlPortget_channel_pressure_port (int channel_index) const
 
- Public Member Functions inherited from ICloneable< TrackProcessor >
std::unique_ptr< TrackProcessorclone_unique (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
std::shared_ptr< TrackProcessorclone_shared (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
TrackProcessorclone_raw_ptr (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
TrackProcessorclone_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
QScopedPointer< TrackProcessorclone_unique_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 

Data Fields

PortRegistryport_registry_
 
std::optional< PortUuidReferencestereo_in_left_id_
 L & R audio input ports, if audio.
 
std::optional< PortUuidReferencestereo_in_right_id_
 
std::optional< PortUuidReferencemono_id_
 Mono toggle, if audio.
 
std::optional< PortUuidReferenceinput_gain_id_
 Input gain, if audio.
 
std::optional< PortUuidReferenceoutput_gain_id_
 Output gain, if audio.
 
std::optional< PortUuidReferencestereo_out_left_id_
 L & R audio output ports, if audio.
 
std::optional< PortUuidReferencestereo_out_right_id_
 
std::optional< PortUuidReferencemidi_in_id_
 MIDI in Port.
 
std::optional< PortUuidReferencemidi_out_id_
 MIDI out port, if MIDI.
 
std::optional< PortUuidReferencepiano_roll_id_
 MIDI input for receiving MIDI signals from the piano roll (i.e., MIDI notes inside regions) or other sources.
 
std::optional< PortUuidReferencemonitor_audio_id_
 Whether to monitor the audio output.
 
std::unique_ptr< MidiMappingscc_mappings_
 Mappings to each CC port.
 
std::unique_ptr< std::array< PortUuidReference, 16_zu *128 > > midi_cc_ids_
 MIDI CC control ports, 16 channels x 128 controls.
 
std::unique_ptr< SixteenPortUuidArray > pitch_bend_ids_
 Pitch bend x 16 channels.
 
std::unique_ptr< SixteenPortUuidArray > poly_key_pressure_ids_
 Polyphonic key pressure (aftertouch).
 
std::unique_ptr< SixteenPortUuidArray > channel_pressure_ids_
 Channel pressure (aftertouch).
 
float l_port_db_ = 0.0f
 Current dBFS after processing each output port.
 
float r_port_db_ = 0.0f
 
ProcessableTracktrack_ = nullptr
 Pointer to owner track, if any.
 
bool pending_midi_panic_ = false
 To be set to true when a panic (all notes off) message should be sent during processing.
 
std::unique_ptr< MPMCQueue< ControlPort * > > updated_midi_automatable_ports_
 A queue of MIDI CC ports whose values have been recently updated.
 
- Data Fields inherited from ICloneable< TrackProcessor >
friend Derived
 

Friends

void to_json (nlohmann::json &j, const TrackProcessor &tp)
 
void from_json (const nlohmann::json &j, TrackProcessor &tp)
 

Detailed Description

A TrackProcessor is a processor that is used as the first entry point when processing a track.

Definition at line 33 of file track_processor.h.

Member Typedef Documentation

◆ SixteenPortUuidArray

using TrackProcessor::SixteenPortUuidArray = std::array<PortUuidReference, 16>

Definition at line 396 of file track_processor.h.

Member Function Documentation

◆ are_events_on_midi_channel_approved()

bool TrackProcessor::are_events_on_midi_channel_approved ( midi_byte_t channel) const
overridevirtual

Returns whether MIDI events on this channel on an input port should be processed (not ignored).

This is used to implement MIDI channel filtering in tracks that have piano rolls based on the enabled MIDI channels.

Reimplemented from IPortOwner.

◆ connect_to_prefader()

void TrackProcessor::connect_to_prefader ( )

Connects the TrackProcessor's stereo out ports to the Channel's prefader in ports.

Used when deleting the only plugin left.

◆ disconnect_from_prefader()

void TrackProcessor::disconnect_from_prefader ( )

Disconnect the TrackProcessor's stereo out ports from the prefader.

Used when there is no plugin in the channel.

◆ get_channel_pressure_port()

ControlPort & TrackProcessor::get_channel_pressure_port ( int channel_index) const
inline

Definition at line 222 of file track_processor.h.

◆ get_full_designation_for_port()

utils::Utf8String TrackProcessor::get_full_designation_for_port ( const dsp::PortIdentifier & id) const
overridevirtual

Reimplemented from IPortOwner.

◆ get_input_gain_port()

ControlPort & TrackProcessor::get_input_gain_port ( ) const
inline

Definition at line 179 of file track_processor.h.

◆ get_midi_cc_port()

ControlPort & TrackProcessor::get_midi_cc_port ( int channel_index,
int cc_index ) const
inline

Definition at line 203 of file track_processor.h.

◆ get_midi_in_port()

MidiPort & TrackProcessor::get_midi_in_port ( ) const
inline

Definition at line 191 of file track_processor.h.

◆ get_midi_out_port()

MidiPort & TrackProcessor::get_midi_out_port ( ) const
inline

Definition at line 195 of file track_processor.h.

◆ get_monitor_audio_port()

ControlPort & TrackProcessor::get_monitor_audio_port ( ) const
inline

Definition at line 187 of file track_processor.h.

◆ get_mono_port()

ControlPort & TrackProcessor::get_mono_port ( ) const
inline

Definition at line 175 of file track_processor.h.

◆ get_output_gain_port()

ControlPort & TrackProcessor::get_output_gain_port ( ) const
inline

Definition at line 183 of file track_processor.h.

◆ get_piano_roll_port()

MidiPort & TrackProcessor::get_piano_roll_port ( ) const
inline

Definition at line 199 of file track_processor.h.

◆ get_pitch_bend_port()

ControlPort & TrackProcessor::get_pitch_bend_port ( int channel_index) const
inline

Definition at line 210 of file track_processor.h.

◆ get_poly_key_pressure_port()

ControlPort & TrackProcessor::get_poly_key_pressure_port ( int channel_index) const
inline

Definition at line 215 of file track_processor.h.

◆ get_stereo_in_ports()

std::pair< AudioPort &, AudioPort & > TrackProcessor::get_stereo_in_ports ( ) const
inline

Definition at line 154 of file track_processor.h.

◆ get_stereo_out_ports()

std::pair< AudioPort &, AudioPort & > TrackProcessor::get_stereo_out_ports ( ) const
inline

Definition at line 164 of file track_processor.h.

◆ get_track()

ProcessableTrack * TrackProcessor::get_track ( ) const
inline

Definition at line 75 of file track_processor.h.

◆ init_after_cloning()

void TrackProcessor::init_after_cloning ( const TrackProcessor & other,
ObjectCloneType clone_type )
overridevirtual

Initializes the cloned object.

Note
Only final classes should implement this.
Exceptions
ZrythmExceptionIf the object could not be cloned.

Implements ICloneable< TrackProcessor >.

◆ is_in_active_project()

bool TrackProcessor::is_in_active_project ( ) const
overridevirtual

Implements IPortOwner.

◆ on_control_change_event()

void TrackProcessor::on_control_change_event ( const dsp::PortIdentifier::PortUuid & port_uuid,
const dsp::PortIdentifier & id,
float val )
overridevirtual

Will be called when a control port's value changes.

Parameters
valThe real value of the control port.
Attention
This may be called from the audio thread so it must not block.

Reimplemented from IPortOwner.

◆ on_midi_activity()

void TrackProcessor::on_midi_activity ( const dsp::PortIdentifier & id)
overridevirtual

Called during processing if the MIDI port contains new MIDI events.

Reimplemented from IPortOwner.

◆ process()

void TrackProcessor::process ( const EngineProcessTimeInfo & time_nfo)

Process the TrackProcessor.

This function performs the following:

  • produce output audio/MIDI into stereo out or midi out, based on any audio/MIDI regions, if has piano roll or is audio track
  • produce additional output MIDI events based on any MIDI CC automation regions, if applicable
  • change MIDI CC control port values based on any MIDI input, if recording — at this point the output is ready —
  • handle recording (create events in regions and automation, including MIDI CC automation, based on the MIDI CC control ports)
Parameters
g_start_framesThe global start frames.
local_offsetThe local start frames.
nframesThe number of frames to process.

◆ set_port_metadata_from_owner()

void TrackProcessor::set_port_metadata_from_owner ( dsp::PortIdentifier & id,
PortRange & range ) const
overridevirtual

Function that will be called by the Port to update the identifier's relevant members based on this port owner.

Parameters
idThe identifier to update.

Implements IPortOwner.

◆ should_bounce_to_master()

bool TrackProcessor::should_bounce_to_master ( utils::audio::BounceStep step) const
overridevirtual

Whether the port should add its data to the master output when bouncing.

When bouncing a track directly to master (e.g., when bouncing the track on its own without parents), the buffer should be added to the master track output.

This is only utilized for stereo output audio ports.

Reimplemented from IPortOwner.

◆ should_sum_data_from_backend()

bool TrackProcessor::should_sum_data_from_backend ( ) const
overridevirtual

Whether during processing, the port should sum the data from its backend buffers coming in.

If this is a TrackProcessor input port for a recordable track, this should only return true when currently armed recording. Otherwise, we always consider incoming external data.

Reimplemented from IPortOwner.

Friends And Related Symbol Documentation

◆ from_json

void from_json ( const nlohmann::json & j,
TrackProcessor & tp )
friend

Definition at line 266 of file track_processor.h.

◆ to_json

void to_json ( nlohmann::json & j,
const TrackProcessor & tp )
friend

Definition at line 246 of file track_processor.h.

Field Documentation

◆ cc_mappings_

std::unique_ptr<MidiMappings> TrackProcessor::cc_mappings_

Mappings to each CC port.

Definition at line 391 of file track_processor.h.

◆ channel_pressure_ids_

std::unique_ptr<SixteenPortUuidArray> TrackProcessor::channel_pressure_ids_

Channel pressure (aftertouch).

This message is different from polyphonic after-touch - sends the single greatest pressure value (of all the current depressed keys).

Definition at line 418 of file track_processor.h.

◆ input_gain_id_

std::optional<PortUuidReference> TrackProcessor::input_gain_id_

Input gain, if audio.

Definition at line 338 of file track_processor.h.

◆ l_port_db_

float TrackProcessor::l_port_db_ = 0.0f

Current dBFS after processing each output port.

Transient variables only used by the GUI.

Definition at line 426 of file track_processor.h.

◆ midi_cc_ids_

std::unique_ptr<std::array<PortUuidReference, 16_zu * 128> > TrackProcessor::midi_cc_ids_

MIDI CC control ports, 16 channels x 128 controls.

Definition at line 394 of file track_processor.h.

◆ midi_in_id_

std::optional<PortUuidReference> TrackProcessor::midi_in_id_

MIDI in Port.

This port is for receiving MIDI signals from an external MIDI source.

This is also where piano roll, midi in and midi manual press will be routed to and this will be the port used to pass midi to the plugins.

Definition at line 361 of file track_processor.h.

◆ midi_out_id_

std::optional<PortUuidReference> TrackProcessor::midi_out_id_

MIDI out port, if MIDI.

Definition at line 366 of file track_processor.h.

◆ monitor_audio_id_

std::optional<PortUuidReference> TrackProcessor::monitor_audio_id_

Whether to monitor the audio output.

This is only used on audio tracks. During recording, if on, the recorded audio will be passed to the output. If off, the recorded audio will not be passed to the output.

When not recording, this will only take effect when paused.

Definition at line 386 of file track_processor.h.

◆ mono_id_

std::optional<PortUuidReference> TrackProcessor::mono_id_

Mono toggle, if audio.

Definition at line 335 of file track_processor.h.

◆ output_gain_id_

std::optional<PortUuidReference> TrackProcessor::output_gain_id_

Output gain, if audio.

This is applied after regions are processed to stereo_out_.

Definition at line 345 of file track_processor.h.

◆ pending_midi_panic_

bool TrackProcessor::pending_midi_panic_ = false

To be set to true when a panic (all notes off) message should be sent during processing.

Only applies to tracks that receive MIDI input.

Definition at line 438 of file track_processor.h.

◆ piano_roll_id_

std::optional<PortUuidReference> TrackProcessor::piano_roll_id_

MIDI input for receiving MIDI signals from the piano roll (i.e., MIDI notes inside regions) or other sources.

This will not be a separately exposed port during processing. It will be processed by the TrackProcessor internally.

Definition at line 375 of file track_processor.h.

◆ pitch_bend_ids_

std::unique_ptr<SixteenPortUuidArray> TrackProcessor::pitch_bend_ids_

Pitch bend x 16 channels.

Definition at line 399 of file track_processor.h.

◆ poly_key_pressure_ids_

std::unique_ptr<SixteenPortUuidArray> TrackProcessor::poly_key_pressure_ids_

Polyphonic key pressure (aftertouch).

This message is most often sent by pressing down on the key after it "bottoms out".

FIXME this is completely wrong. It's supposed to be per-key, so 128 x 16 ports.

Definition at line 410 of file track_processor.h.

◆ port_registry_

PortRegistry& TrackProcessor::port_registry_

Definition at line 326 of file track_processor.h.

◆ r_port_db_

float TrackProcessor::r_port_db_ = 0.0f

Definition at line 427 of file track_processor.h.

◆ stereo_in_left_id_

std::optional<PortUuidReference> TrackProcessor::stereo_in_left_id_

L & R audio input ports, if audio.

Definition at line 331 of file track_processor.h.

◆ stereo_in_right_id_

std::optional<PortUuidReference> TrackProcessor::stereo_in_right_id_

Definition at line 332 of file track_processor.h.

◆ stereo_out_left_id_

std::optional<PortUuidReference> TrackProcessor::stereo_out_left_id_

L & R audio output ports, if audio.

Definition at line 350 of file track_processor.h.

◆ stereo_out_right_id_

std::optional<PortUuidReference> TrackProcessor::stereo_out_right_id_

Definition at line 351 of file track_processor.h.

◆ track_

ProcessableTrack* TrackProcessor::track_ = nullptr

Pointer to owner track, if any.

Definition at line 430 of file track_processor.h.

◆ updated_midi_automatable_ports_

std::unique_ptr<MPMCQueue<ControlPort *> > TrackProcessor::updated_midi_automatable_ports_

A queue of MIDI CC ports whose values have been recently updated.

This is used during processing to avoid checking every single MIDI CC port for changes.

Definition at line 446 of file track_processor.h.


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