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

Represents a channel strip on the mixer. More...

#include <src/gui/backend/channel.h>

Inheritance diagram for zrythm::gui::Channel:
Collaboration diagram for zrythm::gui::Channel:

Public Types

using PortType = zrythm::dsp::PortType
 
using PortIdentifier = dsp::PortIdentifier
 
using TrackUuid = utils::UuidIdentifiableObject<Track>::Uuid
 
using Plugin = gui::old_dsp::plugins::Plugin
 
using PluginDescriptor = zrythm::plugins::PluginDescriptor
 
using PluginSlot = zrythm::plugins::PluginSlot
 
using PluginSlotType = zrythm::plugins::PluginSlotType
 
using PluginPtrVariant = gui::old_dsp::plugins::PluginPtrVariant
 
using PluginUuid = Plugin::Uuid
 
- Public Types inherited from IPortOwner
using TrackUuid = dsp::PortIdentifier::TrackUuid
 
using PluginUuid = dsp::PortIdentifier::PluginUuid
 
using PortUuid = dsp::PortIdentifier::PortUuid
 

Public Member Functions

 Channel (TrackRegistry &track_registry, PluginRegistry &plugin_registry, PortRegistry &port_registry, OptionalRef< ChannelTrack > track)
 Main constructor used by the others.
 
 Channel (TrackRegistry &track_registry, PluginRegistry &plugin_registry, PortRegistry &port_registry)
 To be used when deserializing or cloning an existing identity.
 
FadergetFader () const
 
FadergetPreFader () const
 
AudioPortgetLeftAudioOut () const
 
AudioPortgetRightAudioOut () const
 
MidiPortgetMidiOut () const
 
void init ()
 Initializes the Channel (performs logic that needs the object to be constructed).
 
bool is_in_active_project () const override
 
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.
 
utils::Utf8String get_full_designation_for_port (const dsp::PortIdentifier &id) const override
 
bool should_bounce_to_master (utils::audio::BounceStep step) const override
 Whether the port should add its data to the master output when bouncing.
 
MidiPortget_midi_out_port () const
 
std::pair< AudioPort &, AudioPort & > get_stereo_out_ports () const
 
void reset_fader (bool fire_events)
 Sets fader to 0.0.
 
void handle_plugin_import (const Plugin *pl, std::optional< PluginSpan > plugins, const PluginDescriptor *descr, PluginSlot slot, bool copy, bool ask_if_overwrite)
 Handles import (paste/drop) of plugins or plugin descriptors or mixer selections.
 
void prepare_process (nframes_t nframes)
 Prepares the channel for processing.
 
void process ()
 Perform processing of the audio signal.
 
PluginPtrVariant add_plugin (PluginUuidReference plugin_id, PluginSlot slot, bool confirm, bool moving_plugin, bool gen_automatables, bool recalc_graph, bool pub_events)
 Adds given plugin to given position in the strip.
 
ChannelTrackget_track () const
 
GroupTargetTrackget_output_track () const
 
void reconnect_ext_input_ports (AudioEngine &engine)
 Called when the input has changed for Midi, Instrument or Audio tracks.
 
AutomationTrackget_automation_track (PortIdentifier::Flags port_flags) const
 Convenience function to get the automation track of the given type for the channel.
 
PluginUuid remove_plugin_from_channel (PluginSlot slot, bool moving_plugin, bool deleting_plugin)
 Removes a plugin at the given slot from the channel.
 
void get_plugins (std::vector< Plugin * > &pls)
 Returns all existing plugins in the channel.
 
void paste_plugins_to_slot (PluginSpan plugins, PluginSlot slot)
 Paste the selections starting at the slot in the given channel.
 
bool get_mono_compat_enabled ()
 Gets whether mono compatibility is enabled.
 
void set_mono_compat_enabled (bool enabled, bool fire_events)
 Sets whether mono compatibility is enabled.
 
bool get_swap_phase ()
 Gets whether mono compatibility is enabled.
 
void set_swap_phase (bool enabled, bool fire_events)
 Sets whether mono compatibility is enabled.
 
std::optional< PluginPtrVariant > get_plugin_at_slot (PluginSlot slot) const
 
auto get_plugin_slot (const PluginUuid &plugin_id) const -> PluginSlot
 
std::optional< PluginPtrVariant > get_plugin_from_id (PluginUuid id) const
 
std::optional< PluginPtrVariant > get_instrument () const
 
void select_all (PluginSlotType type, bool select)
 Selects/deselects all plugins in the given slot type.
 
void set_caches ()
 Sets caches for processing.
 
void init_after_cloning (const Channel &other, ObjectCloneType clone_type) override
 
void disconnect_channel ()
 Disconnects the channel from the processing chain and removes any plugins it contains.
 
void connect_channel (dsp::PortConnectionsManager &mgr, AudioEngine &engine)
 Connects the channel's ports.
 
void init_loaded ()
 
void handle_recording (long g_frames_start, nframes_t nframes)
 Handles the recording logic inside the process cycle.
 
void append_ports (std::vector< Port * > &ports, bool include_plugins)
 Appends all channel ports and optionally plugin ports to the array.
 
void expose_ports_to_backend (AudioEngine &engine)
 Exposes the channel's ports to the backend.
 
void set_phase (float phase)
 
float get_phase () const
 
void set_balance_control (float val)
 
void add_balance_control (float pan)
 Adds to (or subtracts from) the pan.
 
float get_balance_control () const
 
void set_track_ptr (ChannelTrack &track)
 Set the track ptr to the channel and all its internals that reference a track (Plugin, Fader, etc.)
 
bool has_output () const
 
Faderget_post_fader () const
 
Faderget_pre_fader () const
 
auto & get_sends () const
 
- Public Member Functions inherited from ICloneable< Channel >
std::unique_ptr< Channel > clone_unique (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
std::shared_ptr< Channel > clone_shared (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
Channel * clone_raw_ptr (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
Channel * clone_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
QScopedPointer< Channel > clone_unique_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
- Public Member Functions inherited from IPortOwner
virtual void on_control_change_event (const PortUuid &port_uuid, const dsp::PortIdentifier &id, float val)
 Will be called when a control port's value changes.
 
virtual void on_midi_activity (const dsp::PortIdentifier &id)
 Called during processing if the MIDI port contains new MIDI events.
 
virtual bool should_sum_data_from_backend () const
 Whether during processing, the port should sum the data from its backend buffers coming in.
 
virtual bool are_events_on_midi_channel_approved (midi_byte_t channel) const
 Returns whether MIDI events on this channel on an input port should be processed (not ignored).
 

Data Fields

TrackRegistrytrack_registry_
 
PortRegistryport_registry_
 
PluginRegistryplugin_registry_
 
std::array< std::optional< PluginUuidReference >, STRIP_SIZE > midi_fx_
 The MIDI effect strip on instrument/MIDI tracks.
 
std::array< std::optional< PluginUuidReference >, STRIP_SIZE > inserts_
 The channel insert strip.
 
std::optional< PluginUuidReferenceinstrument_
 The instrument plugin, if instrument track.
 
std::array< std::unique_ptr< ChannelSend >, STRIP_SIZE > sends_
 The sends strip.
 
std::vector< std::unique_ptr< ExtPort > > ext_midi_ins_
 External MIDI inputs that are currently connected to this channel as official inputs, unless all_midi_ins is enabled.
 
bool all_midi_ins_ = true
 If true, the channel will connect to all MIDI ins found.
 
std::vector< std::unique_ptr< ExtPort > > ext_stereo_l_ins_
 External audio L inputs that are currently connected to this channel as official inputs, unless all_stereo_l_ins is enabled.
 
bool all_stereo_l_ins_ = false
 If true, the channel will connect to all stereo L ins found.
 
std::vector< std::unique_ptr< ExtPort > > ext_stereo_r_ins_
 External audio R inputs that are currently connected to this channel as official inputs, unless all_stereo_r_ins is enabled.
 
bool all_stereo_r_ins_ = false
 If true, the channel will connect to all stereo R ins found.
 
std::array< bool, 16 > midi_channels_ {}
 1 or 0 flags for each channel to enable it or disable it.
 
bool all_midi_channels_ = true
 If true, the channel will accept MIDI messages from all MIDI channels.
 
Faderfader_ = nullptr
 The channel fader.
 
Faderprefader_ = nullptr
 Prefader.
 
std::optional< PortUuidReferencemidi_out_id_
 MIDI output for sending MIDI signals to other destinations, such as other channels when directly routed (eg MIDI track to ins track).
 
std::optional< PortUuidReferencestereo_out_left_id_
 
std::optional< PortUuidReferencestereo_out_right_id_
 
std::optional< TrackUuidoutput_track_uuid_
 Whether or not output_pos corresponds to a Track or not.
 
std::optional< TrackUuidtrack_uuid_
 Track associated with this channel.
 
int width_ = 0
 Channel widget width - reserved for future use.
 
ChannelTracktrack_
 Owner track.
 
- Data Fields inherited from ICloneable< Channel >
friend Derived
 

Static Public Attributes

static constexpr auto STRIP_SIZE = zrythm::dsp::STRIP_SIZE
 

Properties

QML_ELEMENT Faderfader
 
FaderpreFader
 
AudioPortleftAudioOut
 
AudioPortrightAudioOut
 
MidiPortmidiOut
 

Friends

struct PluginImportData
 
void to_json (nlohmann::json &j, const Channel &c)
 
void from_json (const nlohmann::json &j, Channel &c)
 

Detailed Description

Represents a channel strip on the mixer.

The Channel class encapsulates the functionality of a channel strip, including its plugins, fader, sends, and other properties. It provides methods for managing the channel's state and processing the audio signal.

Channels are owned by Tracks and handle the output part of the signal chain, while TrackProcessor handles the input part.

See also
Track

Definition at line 43 of file channel.h.

Member Typedef Documentation

◆ Plugin

◆ PluginDescriptor

◆ PluginPtrVariant

using zrythm::gui::Channel::PluginPtrVariant = gui::old_dsp::plugins::PluginPtrVariant

Definition at line 62 of file channel.h.

◆ PluginSlot

◆ PluginSlotType

using zrythm::gui::Channel::PluginSlotType = zrythm::plugins::PluginSlotType

Definition at line 61 of file channel.h.

◆ PluginUuid

using zrythm::gui::Channel::PluginUuid = Plugin::Uuid

Definition at line 63 of file channel.h.

◆ PortIdentifier

◆ PortType

using zrythm::gui::Channel::PortType = zrythm::dsp::PortType

Definition at line 55 of file channel.h.

◆ TrackUuid

Constructor & Destructor Documentation

◆ Channel() [1/2]

zrythm::gui::Channel::Channel ( TrackRegistry & track_registry,
PluginRegistry & plugin_registry,
PortRegistry & port_registry,
OptionalRef< ChannelTrack > track )
explicit

Main constructor used by the others.

Parameters
track_registry
plugin_registry
port_registry
track_idMust be passed when creating a new Channel identity instance.

◆ Channel() [2/2]

zrythm::gui::Channel::Channel ( TrackRegistry & track_registry,
PluginRegistry & plugin_registry,
PortRegistry & port_registry )
inlineexplicit

To be used when deserializing or cloning an existing identity.

Definition at line 87 of file channel.h.

Member Function Documentation

◆ add_plugin()

PluginPtrVariant zrythm::gui::Channel::add_plugin ( PluginUuidReference plugin_id,
PluginSlot slot,
bool confirm,
bool moving_plugin,
bool gen_automatables,
bool recalc_graph,
bool pub_events )

Adds given plugin to given position in the strip.

The plugin must be already instantiated at this point.

Parameters
channelThe Channel.
slotThe position in the strip starting from 0.
pluginThe plugin to add.
confirmConfirm if an existing plugin will be overwritten.
moving_pluginWhether or not we are moving the plugin.
gen_automatablesGeneratate plugin automatables. To be used when creating a new plugin only.
recalc_graphRecalculate mixer graph.
pub_eventsPublish events.
Exceptions
ZrythmExceptionon error.

◆ connect_channel()

void zrythm::gui::Channel::connect_channel ( dsp::PortConnectionsManager & mgr,
AudioEngine & engine )

Connects the channel's ports.

This should only be called on project tracks.

◆ get_full_designation_for_port()

utils::Utf8String zrythm::gui::Channel::get_full_designation_for_port ( const dsp::PortIdentifier & id) const
overridevirtual

Reimplemented from IPortOwner.

◆ get_instrument()

std::optional< PluginPtrVariant > zrythm::gui::Channel::get_instrument ( ) const
inline

Definition at line 293 of file channel.h.

◆ get_midi_out_port()

MidiPort & zrythm::gui::Channel::get_midi_out_port ( ) const
inline

Definition at line 145 of file channel.h.

◆ get_plugins()

void zrythm::gui::Channel::get_plugins ( std::vector< Plugin * > & pls)

Returns all existing plugins in the channel.

Parameters
plsVector to add plugins to.

◆ get_post_fader()

Fader & zrythm::gui::Channel::get_post_fader ( ) const
inline

Definition at line 372 of file channel.h.

◆ get_pre_fader()

Fader & zrythm::gui::Channel::get_pre_fader ( ) const
inline

Definition at line 373 of file channel.h.

◆ get_sends()

auto & zrythm::gui::Channel::get_sends ( ) const
inline

Definition at line 375 of file channel.h.

◆ get_stereo_out_ports()

std::pair< AudioPort &, AudioPort & > zrythm::gui::Channel::get_stereo_out_ports ( ) const
inline

Definition at line 149 of file channel.h.

◆ get_track()

ChannelTrack & zrythm::gui::Channel::get_track ( ) const
inline

Definition at line 220 of file channel.h.

◆ getFader()

Fader * zrythm::gui::Channel::getFader ( ) const
inline

Definition at line 108 of file channel.h.

◆ getLeftAudioOut()

AudioPort * zrythm::gui::Channel::getLeftAudioOut ( ) const
inline

Definition at line 110 of file channel.h.

◆ getMidiOut()

MidiPort * zrythm::gui::Channel::getMidiOut ( ) const
inline

Definition at line 122 of file channel.h.

◆ getPreFader()

Fader * zrythm::gui::Channel::getPreFader ( ) const
inline

Definition at line 109 of file channel.h.

◆ getRightAudioOut()

AudioPort * zrythm::gui::Channel::getRightAudioOut ( ) const
inline

Definition at line 116 of file channel.h.

◆ handle_plugin_import()

void zrythm::gui::Channel::handle_plugin_import ( const Plugin * pl,
std::optional< PluginSpan > plugins,
const PluginDescriptor * descr,
PluginSlot slot,
bool copy,
bool ask_if_overwrite )

Handles import (paste/drop) of plugins or plugin descriptors or mixer selections.

Parameters
plPassed when passing sel to be used for validation.
selPlugins to import.
copyWhether to copy instead of move, when copying plugins.
ask_if_overwriteWhether to ask for permission if the import overwrites existing plugins.

◆ handle_recording()

void zrythm::gui::Channel::handle_recording ( long g_frames_start,
nframes_t nframes )

Handles the recording logic inside the process cycle.

The MidiEvents are already dequeued at this point.

Parameters
g_frames_startGlobal start frames.
nframesNumber of frames to process.

◆ has_output()

bool zrythm::gui::Channel::has_output ( ) const
inline

Definition at line 370 of file channel.h.

◆ is_in_active_project()

bool zrythm::gui::Channel::is_in_active_project ( ) const
overridevirtual

Implements IPortOwner.

◆ paste_plugins_to_slot()

void zrythm::gui::Channel::paste_plugins_to_slot ( PluginSpan plugins,
PluginSlot slot )

Paste the selections starting at the slot in the given channel.

This calls gen_full_from_this() internally to generate FullMixerSelections with cloned plugins (calling init_loaded() on each), which are then pasted.

◆ prepare_process()

void zrythm::gui::Channel::prepare_process ( nframes_t nframes)

Prepares the channel for processing.

To be called before the main cycle each time on all channels.

◆ process()

void zrythm::gui::Channel::process ( )

Perform processing of the audio signal.

Normally, the channel will call the process func on each of its plugins in order.

◆ remove_plugin_from_channel()

PluginUuid zrythm::gui::Channel::remove_plugin_from_channel ( PluginSlot slot,
bool moving_plugin,
bool deleting_plugin )

Removes a plugin at the given slot from the channel.

FIXME this is the same as modulator_track_remove_modulator(). TODO refactor into track_remove_plugin().

Parameters
moving_pluginWhether or not we are moving the plugin.
deleting_pluginWhether or not we are deleting the plugin.
Returns
The plugin that was removed (in case we want to move it).

◆ set_port_metadata_from_owner()

void zrythm::gui::Channel::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.

◆ set_track_ptr()

void zrythm::gui::Channel::set_track_ptr ( ChannelTrack & track)

Set the track ptr to the channel and all its internals that reference a track (Plugin, Fader, etc.)

Parameters
trackThe owner track.

This is intended to be used when cloning ChannelTracks where we can't use the constructor.

◆ should_bounce_to_master()

bool zrythm::gui::Channel::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.

Friends And Related Symbol Documentation

◆ PluginImportData

friend struct PluginImportData
friend

Definition at line 66 of file channel.h.

◆ to_json

void to_json ( nlohmann::json & j,
const Channel & c )
friend

Definition at line 399 of file channel.h.

Field Documentation

◆ all_midi_channels_

bool zrythm::gui::Channel::all_midi_channels_ = true

If true, the channel will accept MIDI messages from all MIDI channels.

Definition at line 589 of file channel.h.

◆ all_midi_ins_

bool zrythm::gui::Channel::all_midi_ins_ = true

If true, the channel will connect to all MIDI ins found.

Definition at line 550 of file channel.h.

◆ all_stereo_l_ins_

bool zrythm::gui::Channel::all_stereo_l_ins_ = false

If true, the channel will connect to all stereo L ins found.

Definition at line 564 of file channel.h.

◆ all_stereo_r_ins_

bool zrythm::gui::Channel::all_stereo_r_ins_ = false

If true, the channel will connect to all stereo R ins found.

Definition at line 578 of file channel.h.

◆ ext_midi_ins_

std::vector<std::unique_ptr<ExtPort> > zrythm::gui::Channel::ext_midi_ins_

External MIDI inputs that are currently connected to this channel as official inputs, unless all_midi_ins is enabled.

These should be serialized every time and connected to when the project gets loaded if Channel.all_midi_ins is not enabled.

If all_midi_ins is enabled, these are ignored.

Definition at line 547 of file channel.h.

◆ ext_stereo_l_ins_

std::vector<std::unique_ptr<ExtPort> > zrythm::gui::Channel::ext_stereo_l_ins_

External audio L inputs that are currently connected to this channel as official inputs, unless all_stereo_l_ins is enabled.

These should be serialized every time and if all_stereo_l_ins is not enabled, connected to when the project gets loaded.

If all_stereo_l_ins is enabled, these are ignored.

Definition at line 561 of file channel.h.

◆ ext_stereo_r_ins_

std::vector<std::unique_ptr<ExtPort> > zrythm::gui::Channel::ext_stereo_r_ins_

External audio R inputs that are currently connected to this channel as official inputs, unless all_stereo_r_ins is enabled.

These should be serialized every time and if all_stereo_r_ins is not enabled, connected to when the project gets loaded.

If all_stereo_r_ins is enabled, these are ignored.

Definition at line 575 of file channel.h.

◆ fader_

Fader* zrythm::gui::Channel::fader_ = nullptr

The channel fader.

Definition at line 592 of file channel.h.

◆ inserts_

std::array<std::optional<PluginUuidReference>, STRIP_SIZE> zrythm::gui::Channel::inserts_

The channel insert strip.

Definition at line 524 of file channel.h.

◆ instrument_

std::optional<PluginUuidReference> zrythm::gui::Channel::instrument_

The instrument plugin, if instrument track.

Definition at line 527 of file channel.h.

◆ midi_channels_

std::array<bool, 16> zrythm::gui::Channel::midi_channels_ {}

1 or 0 flags for each channel to enable it or disable it.

If all_midi_channels is enabled, this is ignored.

Definition at line 585 of file channel.h.

◆ midi_fx_

std::array<std::optional<PluginUuidReference>, STRIP_SIZE> zrythm::gui::Channel::midi_fx_

The MIDI effect strip on instrument/MIDI tracks.

This is processed before the instrument/inserts.

Definition at line 521 of file channel.h.

◆ midi_out_id_

std::optional<PortUuidReference> zrythm::gui::Channel::midi_out_id_

MIDI output for sending MIDI signals to other destinations, such as other channels when directly routed (eg MIDI track to ins track).

Definition at line 605 of file channel.h.

◆ output_track_uuid_

std::optional<TrackUuid> zrythm::gui::Channel::output_track_uuid_

Whether or not output_pos corresponds to a Track or not.

If not, the channel is routed to the engine. Output track.

Definition at line 622 of file channel.h.

◆ plugin_registry_

PluginRegistry& zrythm::gui::Channel::plugin_registry_

Definition at line 514 of file channel.h.

◆ port_registry_

PortRegistry& zrythm::gui::Channel::port_registry_

Definition at line 513 of file channel.h.

◆ prefader_

Fader* zrythm::gui::Channel::prefader_ = nullptr

Prefader.

The last plugin should connect to this.

Definition at line 599 of file channel.h.

◆ sends_

std::array<std::unique_ptr<ChannelSend>, STRIP_SIZE> zrythm::gui::Channel::sends_

The sends strip.

The first 6 (slots 0-5) are pre-fader and the rest are post-fader.

Note
See CHANNEL_SEND_POST_FADER_START_SLOT.

Definition at line 536 of file channel.h.

◆ stereo_out_left_id_

std::optional<PortUuidReference> zrythm::gui::Channel::stereo_out_left_id_

Definition at line 611 of file channel.h.

◆ stereo_out_right_id_

std::optional<PortUuidReference> zrythm::gui::Channel::stereo_out_right_id_

Definition at line 612 of file channel.h.

◆ STRIP_SIZE

auto zrythm::gui::Channel::STRIP_SIZE = zrythm::dsp::STRIP_SIZE
staticconstexpr

Definition at line 54 of file channel.h.

◆ track_

ChannelTrack* zrythm::gui::Channel::track_

Owner track.

Definition at line 631 of file channel.h.

◆ track_registry_

TrackRegistry& zrythm::gui::Channel::track_registry_

Definition at line 512 of file channel.h.

◆ track_uuid_

std::optional<TrackUuid> zrythm::gui::Channel::track_uuid_

Track associated with this channel.

Definition at line 625 of file channel.h.

◆ width_

int zrythm::gui::Channel::width_ = 0

Channel widget width - reserved for future use.

Definition at line 628 of file channel.h.

Property Documentation

◆ fader

QML_ELEMENT Fader * zrythm::gui::Channel::fader
read

Definition at line 47 of file channel.h.

◆ leftAudioOut

AudioPort * zrythm::gui::Channel::leftAudioOut
read

Definition at line 49 of file channel.h.

◆ midiOut

MidiPort * zrythm::gui::Channel::midiOut
read

Definition at line 51 of file channel.h.

◆ preFader

Fader * zrythm::gui::Channel::preFader
read

Definition at line 48 of file channel.h.

◆ rightAudioOut

AudioPort * zrythm::gui::Channel::rightAudioOut
read

Definition at line 50 of file channel.h.


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