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

A Fader is a processor that is used for volume controls and pan. More...

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

Inheritance diagram for Fader:
Collaboration diagram for Fader:

Public Types

enum class  Type {
  None , Monitor , SampleProcessor , AudioChannel ,
  MidiChannel , Generic
}
 Fader type. More...
 
enum class  MidiFaderMode { MIDI_FADER_MODE_VEL_MULTIPLIER , MIDI_FADER_MODE_CC_VOLUME }
 
using Channel = zrythm::gui::Channel
 
- Public Types inherited from IPortOwner
using TrackUuid = dsp::PortIdentifier::TrackUuid
 
using PluginUuid = dsp::PortIdentifier::PluginUuid
 
using PortUuid = dsp::PortIdentifier::PortUuid
 

Public Member Functions

 Fader (QObject *parent=nullptr)
 
 Fader (PortRegistry &port_registry, Type type, bool passthrough, Track *track, ControlRoom *control_room, SampleProcessor *sample_processor)
 Creates a new fader.
 
void init_loaded (PortRegistry &port_registry, Track *track, ControlRoom *control_room, SampleProcessor *sample_processor)
 Inits fader after a project is loaded.
 
void append_ports (std::vector< Port * > &ports) const
 Appends the ports owned by fader to the given array.
 
utils::Utf8String get_node_name () const override
 Returns a human friendly name of the node.
 
void set_amp (float amp)
 Sets the amplitude of the fader.
 
void set_amp_with_action (float amp_from, float amp_to, bool skip_if_equal)
 Sets the amp value with an undoable action.
 
void add_amp (float amp)
 Adds (or subtracts if negative) to the amplitude of the fader (clamped at 0.0 to 2.0).
 
void set_midi_mode (MidiFaderMode mode, bool with_action, bool fire_events)
 
void set_muted (bool mute, bool fire_events)
 Sets track muted and optionally adds the action to the undo stack.
 
bool get_muted () const
 Returns if the fader is muted.
 
bool get_soloed () const
 Returns if the track is soloed.
 
bool get_implied_soloed () const
 Returns whether the fader is not soloed on its own but its direct out (or its direct out's direct out, etc.) or its child (or its children's child, etc.) is soloed.
 
bool get_listened () const
 Returns whether the fader is listened.
 
void set_listened (bool listen, bool fire_events)
 Sets fader listen and optionally adds the action to the undo stack.
 
void set_soloed (bool solo, bool fire_events)
 Sets track soloed and optionally adds the action to the undo stack.
 
float get_amp () const
 Gets the fader amplitude (not db)
 
bool get_mono_compat_enabled () const
 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 () const
 Gets whether mono compatibility is enabled.
 
void set_swap_phase (bool enabled, bool fire_events)
 Sets whether mono compatibility is enabled.
 
float get_fader_val () const
 
float get_default_fader_val () const
 
std::string db_string_getter () const
 
Channelget_channel () const
 
Trackget_track () const
 
void update_volume_and_fader_val ()
 
void clear_buffers (std::size_t block_length)
 Clears all buffers.
 
void set_fader_val (float fader_val)
 Sets the fader levels from a normalized value 0.0-1.0 (such as in widgets).
 
void set_fader_val_with_action_from_db (const std::string &str)
 
void disconnect_all ()
 Disconnects all ports connected to the fader.
 
void process_block (EngineProcessTimeInfo time_nfo) override
 Process the Fader.
 
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
 
void on_control_change_event (const PortUuid &port_uuid, const dsp::PortIdentifier &id, float val) override
 Will be called when a control port's value changes.
 
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 has_audio_ports () const
 
bool has_midi_ports () const
 
void init_after_cloning (const Fader &other, ObjectCloneType clone_type) override
 Initializes the cloned object.
 
ControlPortget_amp_port () const
 
ControlPortget_balance_port () const
 
ControlPortget_mute_port () const
 
ControlPortget_solo_port () const
 
ControlPortget_listen_port () const
 
ControlPortget_mono_compat_enabled_port () const
 
ControlPortget_swap_phase_port () const
 
std::pair< AudioPort &, AudioPort & > get_stereo_in_ports () const
 
std::pair< AudioPort &, AudioPort & > get_stereo_out_ports () const
 
MidiPortget_midi_in_port () const
 
MidiPortget_midi_out_port () const
 
auto get_stereo_in_left_id () const
 
auto get_stereo_in_right_id () const
 
auto get_stereo_out_left_id () const
 
auto get_stereo_out_right_id () const
 
auto get_midi_in_id () const
 
auto get_midi_out_id () const
 
- Public Member Functions inherited from ICloneable< Fader >
std::unique_ptr< Faderclone_unique (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
std::shared_ptr< Faderclone_shared (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
Faderclone_raw_ptr (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
Faderclone_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
QScopedPointer< Faderclone_unique_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
- Public Member Functions inherited from zrythm::dsp::graph::IProcessable
virtual nframes_t get_single_playback_latency () const
 Returns the latency of only the given processable, without adding the previous/next latencies.
 
virtual void clear_external_buffer (nframes_t block_length)
 
virtual bool needs_external_buffer_clear_on_early_return () const
 
- Public Member Functions inherited from IPortOwner
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).
 

Static Public Member Functions

static int fade_frames_for_type (Type type)
 

Data Fields

float volume_ = 0.f
 Volume in dBFS.
 
float phase_ = 0.f
 Used by the phase knob (0.0 ~ 360.0).
 
float fader_val_ = 0.f
 0.0 ~ 1.0 for widgets.
 
float last_cc_volume_ = 0.f
 Value of amp during last processing.
 
float l_port_db_ = 0.f
 Current dBFS after processing each output port.
 
float r_port_db_ = 0.f
 
Type type_ = (Type) 0
 
MidiFaderMode midi_mode_ = (MidiFaderMode) 0
 MIDI fader mode.
 
bool passthrough_ = false
 Whether this is a passthrough fader (like a prefader).
 
Tracktrack_ = nullptr
 Pointer to owner track, if any.
 
ControlRoomcontrol_room_ = nullptr
 Pointer to owner control room, if any.
 
SampleProcessorsample_processor_ = nullptr
 Pointer to owner sample processor, if any.
 
int magic_ = FADER_MAGIC
 
bool is_project_ = false
 
bool implied_soloed_ = false
 
bool soloed_ = false
 
std::atomic< int > fade_out_samples_ = 0
 Number of samples left to fade out.
 
std::atomic< int > fade_in_samples_ = 0
 Number of samples left to fade in.
 
std::atomic< bool > fading_out_ = false
 Whether currently fading out.
 
bool was_effectively_muted_ = false
 Cache.
 
OptionalRef< PortRegistryport_registry_
 
- Data Fields inherited from ICloneable< Fader >
friend Derived
 

Friends

void to_json (nlohmann::json &j, const Fader &fader)
 
void from_json (const nlohmann::json &j, Fader &fader)
 

Detailed Description

A Fader is a processor that is used for volume controls and pan.

Definition at line 46 of file fader.h.

Member Typedef Documentation

◆ Channel

Definition at line 88 of file fader.h.

Member Enumeration Documentation

◆ MidiFaderMode

enum class Fader::MidiFaderMode
strong
Enumerator
MIDI_FADER_MODE_VEL_MULTIPLIER 

Multiply velocity of all MIDI note ons.

MIDI_FADER_MODE_CC_VOLUME 

Send CC volume event on change TODO.

Definition at line 79 of file fader.h.

◆ Type

enum class Fader::Type
strong

Fader type.

Enumerator
Monitor 

Audio fader for the monitor.

SampleProcessor 

Audio fader for the sample processor.

AudioChannel 

Audio fader for Channel's.

Generic 

For generic uses.

Definition at line 59 of file fader.h.

Constructor & Destructor Documentation

◆ Fader()

Fader::Fader ( PortRegistry & port_registry,
Type type,
bool passthrough,
Track * track,
ControlRoom * control_room,
SampleProcessor * sample_processor )

Creates a new fader.

This assumes that the channel has no plugins.

Parameters
typeThe Fader::Type.
chChannel, if this is a channel Fader.

Member Function Documentation

◆ get_amp()

float Fader::get_amp ( ) const
inline

Gets the fader amplitude (not db)

Definition at line 193 of file fader.h.

◆ get_amp_port()

ControlPort & Fader::get_amp_port ( ) const
inline

Definition at line 283 of file fader.h.

◆ get_balance_port()

ControlPort & Fader::get_balance_port ( ) const
inline

Definition at line 287 of file fader.h.

◆ get_default_fader_val()

float Fader::get_default_fader_val ( ) const
inline

Definition at line 220 of file fader.h.

◆ get_fader_val()

float Fader::get_fader_val ( ) const
inline

Definition at line 218 of file fader.h.

◆ get_full_designation_for_port()

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

Reimplemented from IPortOwner.

◆ get_listen_port()

ControlPort & Fader::get_listen_port ( ) const
inline

Definition at line 299 of file fader.h.

◆ get_listened()

bool Fader::get_listened ( ) const
inline

Returns whether the fader is listened.

Definition at line 176 of file fader.h.

◆ get_midi_in_id()

auto Fader::get_midi_in_id ( ) const
inline

Definition at line 376 of file fader.h.

◆ get_midi_in_port()

MidiPort & Fader::get_midi_in_port ( ) const
inline

Definition at line 331 of file fader.h.

◆ get_midi_out_id()

auto Fader::get_midi_out_id ( ) const
inline

Definition at line 385 of file fader.h.

◆ get_midi_out_port()

MidiPort & Fader::get_midi_out_port ( ) const
inline

Definition at line 335 of file fader.h.

◆ get_mono_compat_enabled()

bool Fader::get_mono_compat_enabled ( ) const
inline

Gets whether mono compatibility is enabled.

Definition at line 198 of file fader.h.

◆ get_mono_compat_enabled_port()

ControlPort & Fader::get_mono_compat_enabled_port ( ) const
inline

Definition at line 303 of file fader.h.

◆ get_mute_port()

ControlPort & Fader::get_mute_port ( ) const
inline

Definition at line 291 of file fader.h.

◆ get_muted()

bool Fader::get_muted ( ) const
inline

Returns if the fader is muted.

Definition at line 155 of file fader.h.

◆ get_node_name()

utils::Utf8String Fader::get_node_name ( ) const
overridevirtual

Returns a human friendly name of the node.

Implements zrythm::dsp::graph::IProcessable.

◆ get_solo_port()

ControlPort & Fader::get_solo_port ( ) const
inline

Definition at line 295 of file fader.h.

◆ get_soloed()

bool Fader::get_soloed ( ) const
inline

Returns if the track is soloed.

Definition at line 160 of file fader.h.

◆ get_stereo_in_left_id()

auto Fader::get_stereo_in_left_id ( ) const
inline

Definition at line 340 of file fader.h.

◆ get_stereo_in_ports()

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

Definition at line 311 of file fader.h.

◆ get_stereo_in_right_id()

auto Fader::get_stereo_in_right_id ( ) const
inline

Definition at line 349 of file fader.h.

◆ get_stereo_out_left_id()

auto Fader::get_stereo_out_left_id ( ) const
inline

Definition at line 358 of file fader.h.

◆ get_stereo_out_ports()

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

Definition at line 321 of file fader.h.

◆ get_stereo_out_right_id()

auto Fader::get_stereo_out_right_id ( ) const
inline

Definition at line 367 of file fader.h.

◆ get_swap_phase()

bool Fader::get_swap_phase ( ) const
inline

Gets whether mono compatibility is enabled.

Definition at line 211 of file fader.h.

◆ get_swap_phase_port()

ControlPort & Fader::get_swap_phase_port ( ) const
inline

Definition at line 307 of file fader.h.

◆ has_audio_ports()

bool Fader::has_audio_ports ( ) const
inline

Definition at line 272 of file fader.h.

◆ has_midi_ports()

bool Fader::has_midi_ports ( ) const
inline

Definition at line 278 of file fader.h.

◆ init_after_cloning()

void Fader::init_after_cloning ( const Fader & 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< Fader >.

◆ is_in_active_project()

bool Fader::is_in_active_project ( ) const
overridevirtual

Implements IPortOwner.

◆ on_control_change_event()

void Fader::on_control_change_event ( const 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.

◆ process_block()

void Fader::process_block ( EngineProcessTimeInfo time_nfo)
overridevirtual

Process the Fader.

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

◆ set_amp()

void Fader::set_amp ( float amp)

Sets the amplitude of the fader.

(0.0 to 2.0)

◆ set_amp_with_action()

void Fader::set_amp_with_action ( float amp_from,
float amp_to,
bool skip_if_equal )

Sets the amp value with an undoable action.

Parameters
skip_if_equalWhether to skip the action if the amp hasn't changed.

◆ set_port_metadata_from_owner()

void Fader::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 Fader::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

◆ from_json

void from_json ( const nlohmann::json & j,
Fader & fader )
friend

Definition at line 436 of file fader.h.

◆ to_json

void to_json ( nlohmann::json & j,
const Fader & fader )
friend

Definition at line 413 of file fader.h.

Field Documentation

◆ control_room_

ControlRoom* Fader::control_room_ = nullptr

Pointer to owner control room, if any.

Definition at line 548 of file fader.h.

◆ fade_in_samples_

std::atomic<int> Fader::fade_in_samples_ = 0

Number of samples left to fade in.

Definition at line 571 of file fader.h.

◆ fade_out_samples_

std::atomic<int> Fader::fade_out_samples_ = 0

Number of samples left to fade out.

This is atomic because it is used during processing (process()) and also checked in the main thread by Engine.wait_for_pause().

Definition at line 568 of file fader.h.

◆ fader_val_

float Fader::fader_val_ = 0.f

0.0 ~ 1.0 for widgets.

Definition at line 468 of file fader.h.

◆ fading_out_

std::atomic<bool> Fader::fading_out_ = false

Whether currently fading out.

When true, if fade_out_samples becomes 0 then the output will be silenced.

Definition at line 578 of file fader.h.

◆ implied_soloed_

bool Fader::implied_soloed_ = false

Definition at line 559 of file fader.h.

◆ is_project_

bool Fader::is_project_ = false

Definition at line 555 of file fader.h.

◆ l_port_db_

float Fader::l_port_db_ = 0.f

Current dBFS after processing each output port.

Transient variables only used by the GUI.

Definition at line 533 of file fader.h.

◆ last_cc_volume_

float Fader::last_cc_volume_ = 0.f

Value of amp during last processing.

Used when processing MIDI faders.

TODO

Definition at line 477 of file fader.h.

◆ magic_

int Fader::magic_ = FADER_MAGIC

Definition at line 553 of file fader.h.

◆ midi_mode_

MidiFaderMode Fader::midi_mode_ = (MidiFaderMode) 0

MIDI fader mode.

Definition at line 539 of file fader.h.

◆ passthrough_

bool Fader::passthrough_ = false

Whether this is a passthrough fader (like a prefader).

Definition at line 542 of file fader.h.

◆ phase_

float Fader::phase_ = 0.f

Used by the phase knob (0.0 ~ 360.0).

Definition at line 465 of file fader.h.

◆ port_registry_

OptionalRef<PortRegistry> Fader::port_registry_

Definition at line 583 of file fader.h.

◆ r_port_db_

float Fader::r_port_db_ = 0.f

Definition at line 534 of file fader.h.

◆ sample_processor_

SampleProcessor* Fader::sample_processor_ = nullptr

Pointer to owner sample processor, if any.

Definition at line 551 of file fader.h.

◆ soloed_

bool Fader::soloed_ = false

Definition at line 560 of file fader.h.

◆ track_

Track* Fader::track_ = nullptr

Pointer to owner track, if any.

Definition at line 545 of file fader.h.

◆ type_

Type Fader::type_ = (Type) 0

Definition at line 536 of file fader.h.

◆ volume_

float Fader::volume_ = 0.f

Volume in dBFS.

(-inf ~ +6)

Definition at line 462 of file fader.h.

◆ was_effectively_muted_

bool Fader::was_effectively_muted_ = false

Cache.

Definition at line 581 of file fader.h.


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