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

Base class for all objects in the arranger. More...

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

Inheritance diagram for ArrangerObject:
Collaboration diagram for ArrangerObject:

Public Types

enum class  ResizeType {
  Normal , Loop , Fade , Stretch ,
  StretchTempoChange
}
 Flag used in some functions. More...
 
enum class  Type {
  MidiRegion , AudioRegion , ChordRegion , AutomationRegion ,
  MidiNote , ChordObject , ScaleObject , Marker ,
  AutomationPoint
}
 The type of the object. More...
 
enum class  Flags { NonProject = 1 << 0 }
 Flags. More...
 
enum class  PositionType {
  Start , End , ClipStart , LoopStart ,
  LoopEnd , FadeIn , FadeOut
}
 
using SelectionStatusGetter = std::function<bool (const Uuid &)>
 
using Position = zrythm::dsp::Position
 
using ArrangerObjectPtr = ArrangerObject *
 

Public Member Functions

auto get_type () const
 
virtual utils::Utf8String gen_human_friendly_name () const
 Generates a human readable name for the object.
 
bool is_start_hit_by_range (const dsp::Position &start, const dsp::Position &end, bool range_start_inclusive=true, bool range_end_inclusive=false) const
 Returns whether the given object is hit by the given range.
 
bool is_start_hit_by_range (const signed_frame_t global_frames_start, const signed_frame_t global_frames_end, bool range_start_inclusive=true, bool range_end_inclusive=false) const
 
void set_parent_on_base_qproperties (QObject &derived)
 Set the parent on QObject's that are children of this class.
 
auto get_position () const
 Getter.
 
void position_setter_validated (const dsp::Position &pos, dsp::TicksPerFrame ticks_per_frame)
 The setter is for use in e.g.
 
void set_position_unvalidated (const dsp::Position &pos)
 
bool is_position_valid (const dsp::Position &pos, PositionType pos_type, dsp::TicksPerFrame ticks_per_frame) const
 Returns if the given Position is valid.
 
bool set_position (const dsp::Position &pos, PositionType pos_type, bool validate, dsp::TicksPerFrame ticks_per_frame)
 Sets the given position on the object, optionally attempting to validate before.
 
void move (double ticks, dsp::FramesPerTick frames_per_tick)
 Moves the object by the given amount of ticks.
 
void set_track_id (const TrackUuid &track_id)
 
void set_track_id (std::optional< TrackUuid > track_id)
 
void unset_track_id ()
 
void update_positions (bool from_ticks, bool bpm_change, dsp::FramesPerTick frames_per_tick)
 Updates the positions in each child recursively.
 
auto get_track () const
 Returns the Track this ArrangerObject is in.
 
std::optional< TrackUuidget_track_id () const
 
virtual bool validate (bool is_project, dsp::FramesPerTick frames_per_tick) const =0
 Validates the arranger object.
 
virtual ArrangerObjectPtrVariant add_clone_to_project (bool fire_events) const =0
 Appends the ArrangerObject to where it belongs in the project (eg, a Track), without taking into account its previous index (eg, before deletion if undoing).
 
virtual ArrangerObjectPtrVariant insert_clone_to_project () const =0
 Inserts the object where it belongs in the project (eg, a Track).
 
std::optional< ArrangerObjectPtrVariant > remove_from_project (bool free_obj, bool fire_events=false)
 Removes the object (which can be obtained from find_in_project()) from its parent in the project.
 
void set_selection_status_getter (SelectionStatusGetter getter)
 
void unset_selection_status_getter ()
 
virtual bool is_deletable () const
 Returns whether the given object is deletable or not (eg, start marker).
 
- Public Member Functions inherited from zrythm::utils::UuidIdentifiableObject< ArrangerObject >
 UuidIdentifiableObject (const Uuid &id)
 
 UuidIdentifiableObject (const UuidIdentifiableObject &other)=default
 
 UuidIdentifiableObject (UuidIdentifiableObject &&other)=default
 
UuidIdentifiableObjectoperator= (const UuidIdentifiableObject &other)=default
 
UuidIdentifiableObjectoperator= (UuidIdentifiableObject &&other)=default
 
auto get_uuid () const
 
void copy_members_from (const UuidIdentifiableObject &other)
 

Data Fields

Flags flags_ {}
 Track this object belongs to (cache to be set during graph calculation).
 

Static Public Attributes

static constexpr double DEFAULT_NUDGE_TICKS = 0.1
 

Protected Member Functions

 ArrangerObject (Type type, TrackResolver track_resolver) noexcept
 
void copy_members_from (const ArrangerObject &other, ObjectCloneType clone_type)
 
bool are_members_valid (bool is_project, dsp::FramesPerTick frames_per_tick) const
 To be called by validate() implementations.
 

Protected Attributes

TrackResolver track_resolver_
 
PositionProxypos_ = nullptr
 Position (or start Position if the object has length).
 
std::optional< TrackUuidtrack_id_
 ID of the track this object belongs to.
 
std::optional< SelectionStatusGetter > selection_status_getter_
 Whether part of an auditioner track.
 

Friends

bool operator== (const ArrangerObject &lhs, const ArrangerObject &rhs)
 
void to_json (nlohmann::json &j, const ArrangerObject &arranger_object)
 
void from_json (const nlohmann::json &j, ArrangerObject &arranger_object)
 

Detailed Description

Base class for all objects in the arranger.

The ArrangerObject class is the base class for all objects that can be placed in the arranger, such as regions, MIDI notes, chord objects, etc. It provides common functionality and properties shared by all these objects.

Definition at line 74 of file arranger_object.h.

Member Typedef Documentation

◆ ArrangerObjectPtr

◆ Position

◆ SelectionStatusGetter

using ArrangerObject::SelectionStatusGetter = std::function<bool (const Uuid &)>

Definition at line 79 of file arranger_object.h.

Member Enumeration Documentation

◆ Flags

enum class ArrangerObject::Flags
strong

Flags.

Enumerator
NonProject 

This object is not a project object, but an object used temporarily eg.

when undoing/ redoing.

Definition at line 120 of file arranger_object.h.

◆ PositionType

enum class ArrangerObject::PositionType
strong

Definition at line 130 of file arranger_object.h.

◆ ResizeType

enum class ArrangerObject::ResizeType
strong

Flag used in some functions.

Enumerator
StretchTempoChange 

Used when we want to resize to contents when BPM changes.

Note
Only applies to audio.

Definition at line 86 of file arranger_object.h.

◆ Type

enum class ArrangerObject::Type
strong

The type of the object.

Definition at line 104 of file arranger_object.h.

Member Function Documentation

◆ add_clone_to_project()

virtual ArrangerObjectPtrVariant ArrangerObject::add_clone_to_project ( bool fire_events) const
pure virtual

Appends the ArrangerObject to where it belongs in the project (eg, a Track), without taking into account its previous index (eg, before deletion if undoing).

Exceptions
ZrythmErroron failure.
Returns
A reference to the newly added clone.

Implemented in AutomationPoint, ChordObject, Marker, MidiNote, RegionImpl< RegionT >, RegionImpl< AudioRegion >, RegionImpl< AutomationRegion >, RegionImpl< ChordRegion >, RegionImpl< ChordRegion >, RegionImpl< MidiRegion >, and ScaleObject.

◆ gen_human_friendly_name()

virtual utils::Utf8String ArrangerObject::gen_human_friendly_name ( ) const
inlinevirtual

Generates a human readable name for the object.

If the object has a name, this returns a copy of the name, otherwise generates something appropriate.

Reimplemented in ChordObject, MidiNote, NamedObject, and ScaleObject.

Definition at line 156 of file arranger_object.h.

◆ get_position()

auto ArrangerObject::get_position ( ) const
inline

Getter.

Definition at line 211 of file arranger_object.h.

◆ get_track()

auto ArrangerObject::get_track ( ) const
inline

Returns the Track this ArrangerObject is in.

Definition at line 284 of file arranger_object.h.

◆ get_track_id()

std::optional< TrackUuid > ArrangerObject::get_track_id ( ) const
inline

Definition at line 290 of file arranger_object.h.

◆ get_type()

auto ArrangerObject::get_type ( ) const
inline

Definition at line 148 of file arranger_object.h.

◆ insert_clone_to_project()

virtual ArrangerObjectPtrVariant ArrangerObject::insert_clone_to_project ( ) const
pure virtual

Inserts the object where it belongs in the project (eg, a Track).

This function assumes that the object already knows the index where it should be inserted in its parent.

This is mostly used when undoing.

Exceptions
ZrythmExceptionon failure.
Returns
A reference to the newly inserted clone.

Implemented in AutomationPoint, ChordObject, Marker, MidiNote, RegionImpl< RegionT >, RegionImpl< AudioRegion >, RegionImpl< AutomationRegion >, RegionImpl< ChordRegion >, RegionImpl< ChordRegion >, RegionImpl< MidiRegion >, and ScaleObject.

◆ is_deletable()

virtual bool ArrangerObject::is_deletable ( ) const
inlinevirtual

Returns whether the given object is deletable or not (eg, start marker).

Reimplemented in Marker.

Definition at line 347 of file arranger_object.h.

◆ is_position_valid()

bool ArrangerObject::is_position_valid ( const dsp::Position & pos,
PositionType pos_type,
dsp::TicksPerFrame ticks_per_frame ) const

Returns if the given Position is valid.

Parameters
posThe position to set to.
pos_typeThe type of Position to set in the ArrangerObject.

◆ is_start_hit_by_range() [1/2]

bool ArrangerObject::is_start_hit_by_range ( const dsp::Position & start,
const dsp::Position & end,
bool range_start_inclusive = true,
bool range_end_inclusive = false ) const
inline

Returns whether the given object is hit by the given range.

Parameters
startStart position.
endEnd position.
range_start_inclusiveWhether pos_ == start is allowed. Can't imagine a case where this would be false, but kept an option just in case.
range_end_inclusiveWhether pos_ == end is allowed.

Definition at line 172 of file arranger_object.h.

◆ is_start_hit_by_range() [2/2]

bool ArrangerObject::is_start_hit_by_range ( const signed_frame_t global_frames_start,
const signed_frame_t global_frames_end,
bool range_start_inclusive = true,
bool range_end_inclusive = false ) const
inline
See also
is_start_hit_by_range().

Definition at line 185 of file arranger_object.h.

◆ position_setter_validated()

void ArrangerObject::position_setter_validated ( const dsp::Position & pos,
dsp::TicksPerFrame ticks_per_frame )

The setter is for use in e.g.

the digital meters whereas the set_pos func is used during arranger actions.

Note
This validates the position.

◆ remove_from_project()

std::optional< ArrangerObjectPtrVariant > ArrangerObject::remove_from_project ( bool free_obj,
bool fire_events = false )

Removes the object (which can be obtained from find_in_project()) from its parent in the project.

Returns
A pointer to the removed object (whose lifetime is now the responsibility of the caller).

◆ set_parent_on_base_qproperties()

void ArrangerObject::set_parent_on_base_qproperties ( QObject & derived)

Set the parent on QObject's that are children of this class.

This is needed because we can only inherit from QObject on final classes, and this is not a final class, so final classes deriving from this are expected to call this method to establish the parent-child relationship.

Parameters
derivedThe derived class instance.

◆ set_position()

bool ArrangerObject::set_position ( const dsp::Position & pos,
PositionType pos_type,
bool validate,
dsp::TicksPerFrame ticks_per_frame )

Sets the given position on the object, optionally attempting to validate before.

Parameters
posThe position to set to.
pos_typeThe type of Position to set in the ArrangerObject.
validateValidate the Position before setting it.
Returns
Whether the position was set (false if invalid).

◆ set_position_unvalidated()

void ArrangerObject::set_position_unvalidated ( const dsp::Position & pos)
inline

Definition at line 223 of file arranger_object.h.

◆ set_selection_status_getter()

void ArrangerObject::set_selection_status_getter ( SelectionStatusGetter getter)
inline

Definition at line 338 of file arranger_object.h.

◆ set_track_id() [1/2]

void ArrangerObject::set_track_id ( const TrackUuid & track_id)
inline

Definition at line 261 of file arranger_object.h.

◆ set_track_id() [2/2]

void ArrangerObject::set_track_id ( std::optional< TrackUuid > track_id)
inline

Definition at line 262 of file arranger_object.h.

◆ unset_selection_status_getter()

void ArrangerObject::unset_selection_status_getter ( )
inline

Definition at line 342 of file arranger_object.h.

◆ unset_track_id()

void ArrangerObject::unset_track_id ( )
inline

Definition at line 266 of file arranger_object.h.

◆ update_positions()

void ArrangerObject::update_positions ( bool from_ticks,
bool bpm_change,
dsp::FramesPerTick frames_per_tick )

Updates the positions in each child recursively.

Parameters
from_ticksWhether to update the positions based on ticks (true) or frames (false).
frames_per_tickThis will be used when doing position conversions via dependency injection instead of relying on the current project's transport.

◆ validate()

virtual bool ArrangerObject::validate ( bool is_project,
dsp::FramesPerTick frames_per_tick ) const
pure virtual

Validates the arranger object.

Parameters
frames_per_tickFrames per tick used when validating audio regions. Passing 0 will use the value from the current engine.
Returns
Whether valid.

Must only be implemented by final objects.

Implemented in AudioRegion, AutomationPoint, AutomationRegion, ChordObject, ChordRegion, Marker, MidiNote, MidiRegion, and ScaleObject.

Friends And Related Symbol Documentation

◆ from_json

void from_json ( const nlohmann::json & j,
ArrangerObject & arranger_object )
friend

Definition at line 379 of file arranger_object.h.

◆ operator==

bool operator== ( const ArrangerObject & lhs,
const ArrangerObject & rhs )
friend

Definition at line 349 of file arranger_object.h.

◆ to_json

void to_json ( nlohmann::json & j,
const ArrangerObject & arranger_object )
friend

Definition at line 370 of file arranger_object.h.

Field Documentation

◆ DEFAULT_NUDGE_TICKS

double ArrangerObject::DEFAULT_NUDGE_TICKS = 0.1
staticconstexpr

Definition at line 81 of file arranger_object.h.

◆ flags_

Flags ArrangerObject::flags_ {}

Track this object belongs to (cache to be set during graph calculation).

Whether deleted with delete tool.

This is used to simply hide these objects until the action finishes so that they can be cloned for the actions. Flags.

Definition at line 419 of file arranger_object.h.

◆ pos_

PositionProxy* ArrangerObject::pos_ = nullptr
protected

Position (or start Position if the object has length).

Definition at line 393 of file arranger_object.h.

◆ selection_status_getter_

std::optional<SelectionStatusGetter> ArrangerObject::selection_status_getter_
protected

Whether part of an auditioner track.

Definition at line 426 of file arranger_object.h.

◆ track_id_

std::optional<TrackUuid> ArrangerObject::track_id_
protected

ID of the track this object belongs to.

If this is null, then this object is not part of a track.

Definition at line 404 of file arranger_object.h.

◆ track_resolver_

TrackResolver ArrangerObject::track_resolver_
protected

Definition at line 388 of file arranger_object.h.


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