Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::structure::arrangement::BoundedObject Class Reference

Base class for all objects in the arranger that have a length. More...

#include <src/structure/arrangement/bounded_object.h>

Inheritance diagram for zrythm::structure::arrangement::BoundedObject:
Collaboration diagram for zrythm::structure::arrangement::BoundedObject:

Public Member Functions

auto get_end_position () const
 Getter.
 
void parent_base_qproperties (QObject &derived)
 
void end_position_setter_validated (const dsp::Position &pos, dsp::TicksPerFrame ticks_per_frame)
 The setter is for use in e.g.
 
void set_end_position_unvalidated (const dsp::Position &pos)
 
auto get_length_in_ticks () const
 Returns the length in ticks.
 
auto get_length_in_frames () const
 Returns the length in frames.
 
void resize (bool left, ResizeType type, double ticks, bool during_ui_action)
 Resizes the object on the left side or right side by given amount of ticks, for objects that do not have loops (currently none?
 
template<typename SelfT>
requires (FinalArrangerObjectSubclass<SelfT>)
void set_start_pos_full_size (this SelfT &self, const Position &pos, dsp::FramesPerTick frames_per_tick)
 Sets the end position of the ArrangerObject and also sets the loop end and fade out (if object supports those) so that they are at the end.
 
template<typename SelfT>
requires (FinalArrangerObjectSubclass<SelfT>)
void set_end_pos_full_size (this SelfT &self, const dsp::Position &pos, dsp::FramesPerTick frames_per_tick)
 Sets the end position of the ArrangerObject and also sets the loop end and fade out (if object supports those) to that position.
 
bool is_hit (const dsp::Position &pos, bool object_end_pos_inclusive=false) const
 Returns whether the object is hit by the given position (local position if non-timeline object).
 
bool is_hit (const signed_frame_t frames, bool object_end_pos_inclusive=false) const
 
bool is_hit_by_range (const dsp::Position &start, const dsp::Position &end, bool range_start_inclusive=true, bool range_end_inclusive=false, bool object_end_pos_inclusive=false) const
 Returns whether the given object is hit by the given range.
 
bool is_hit_by_range (signed_frame_t global_frames_start, signed_frame_t global_frames_end, bool range_start_inclusive=true, bool range_end_inclusive=false, bool object_end_pos_inclusive=false) const
 
virtual bool is_inside_range (const dsp::Position &start, const dsp::Position &end) const
 Checks if any part of the object is hit by the given range.
 
- Public Member Functions inherited from zrythm::structure::arrangement::ArrangerObject
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
 

Data Fields

utils::QObjectUniquePtr< PositionProxyend_pos_
 End Position, if the object has one.
 
- Data Fields inherited from zrythm::structure::arrangement::ArrangerObject
Flags flags_ {}
 Flags.
 

Protected Member Functions

bool are_members_valid (bool is_project, dsp::FramesPerTick frames_per_tick) const
 
- Protected Member Functions inherited from zrythm::structure::arrangement::ArrangerObject
 ArrangerObject (Type type, TrackResolver track_resolver) noexcept
 
bool are_members_valid (bool is_project, dsp::FramesPerTick frames_per_tick) const
 To be called by validate() implementations.
 

Friends

void init_from (BoundedObject &obj, const BoundedObject &other, utils::ObjectCloneType clone_type)
 
auto to_json (nlohmann::json &j, const BoundedObject &object)
 
auto from_json (const nlohmann::json &j, BoundedObject &object)
 

Additional Inherited Members

- Public Types inherited from zrythm::structure::arrangement::ArrangerObject
enum class  ResizeType : basic_enum_base_type_t {
  Normal , Loop , Fade , Stretch ,
  StretchTempoChange
}
 Flag used in some functions. More...
 
enum class  Type : basic_enum_base_type_t {
  MidiRegion , AudioRegion , ChordRegion , AutomationRegion ,
  MidiNote , ChordObject , ScaleObject , Marker ,
  AutomationPoint
}
 The type of the object. More...
 
enum class  Flags : basic_enum_base_type_t { NonProject = 1 << 0 }
 Flags. More...
 
enum class  PositionType : basic_enum_base_type_t {
  Start , End , ClipStart , LoopStart ,
  LoopEnd , FadeIn , FadeOut
}
 
using SelectionStatusGetter = std::function<bool (const Uuid &)>
 
using TrackUuid = structure::tracks::TrackUuid
 
using Track = structure::tracks::Track
 
using TrackResolver = structure::tracks::TrackResolver
 
using TrackPtrVariant = structure::tracks::TrackPtrVariant
 
using Position = zrythm::dsp::Position
 
using ArrangerObjectPtr = ArrangerObject *
 
- Static Public Attributes inherited from zrythm::structure::arrangement::ArrangerObject
static constexpr double DEFAULT_NUDGE_TICKS = 0.1
 
- Protected Attributes inherited from zrythm::structure::arrangement::ArrangerObject
TrackResolver track_resolver_
 
utils::QObjectUniquePtr< PositionProxypos_
 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_
 

Detailed Description

Base class for all objects in the arranger that have a length.

The BoundedObject class is the base class for all objects that have a length, such as regions, MIDI notes, etc. It provides common functionality and properties shared by all these objects, such as start and end positions, and methods to resize and check if the object is hit by a position or range.

BoundedObject inherits from ArrangerObject and extends it with length-related functionality.

Definition at line 36 of file bounded_object.h.

Member Function Documentation

◆ end_position_setter_validated()

void zrythm::structure::arrangement::BoundedObject::end_position_setter_validated ( const dsp::Position & pos,
dsp::TicksPerFrame ticks_per_frame )
inline

The setter is for use in e.g.

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

Definition at line 57 of file bounded_object.h.

◆ get_end_position()

auto zrythm::structure::arrangement::BoundedObject::get_end_position ( ) const
inline

Getter.

Definition at line 46 of file bounded_object.h.

◆ get_length_in_frames()

auto zrythm::structure::arrangement::BoundedObject::get_length_in_frames ( ) const
inline

Returns the length in frames.

(End Position - start Position).

Definition at line 85 of file bounded_object.h.

◆ get_length_in_ticks()

auto zrythm::structure::arrangement::BoundedObject::get_length_in_ticks ( ) const
inline

Returns the length in ticks.

(End Position - start Position).

Definition at line 75 of file bounded_object.h.

◆ is_hit() [1/2]

bool zrythm::structure::arrangement::BoundedObject::is_hit ( const dsp::Position & pos,
bool object_end_pos_inclusive = false ) const
inline

Returns whether the object is hit by the given position (local position if non-timeline object).

Parameters
posPosition to check.
obj_end_pos_inclusiveWhether end_pos_ is considered as part of the object. This is probably always false.

Definition at line 146 of file bounded_object.h.

◆ is_hit() [2/2]

bool zrythm::structure::arrangement::BoundedObject::is_hit ( const signed_frame_t frames,
bool object_end_pos_inclusive = false ) const
inline
Parameters
framesLocal position if non-timeline object.
object_end_pos_inclusive

Definition at line 158 of file bounded_object.h.

◆ is_hit_by_range() [1/2]

bool zrythm::structure::arrangement::BoundedObject::is_hit_by_range ( const dsp::Position & start,
const dsp::Position & end,
bool range_start_inclusive = true,
bool range_end_inclusive = false,
bool object_end_pos_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.
obj_end_pos_inclusiveWhether end_pos_ is considered as part of the object. This is probably always false.

Definition at line 179 of file bounded_object.h.

◆ is_hit_by_range() [2/2]

bool zrythm::structure::arrangement::BoundedObject::is_hit_by_range ( signed_frame_t global_frames_start,
signed_frame_t global_frames_end,
bool range_start_inclusive = true,
bool range_end_inclusive = false,
bool object_end_pos_inclusive = false ) const
inline

Definition at line 189 of file bounded_object.h.

◆ is_inside_range()

virtual bool zrythm::structure::arrangement::BoundedObject::is_inside_range ( const dsp::Position & start,
const dsp::Position & end ) const
inlinevirtual

Checks if any part of the object is hit by the given range.

Definition at line 244 of file bounded_object.h.

◆ resize()

void zrythm::structure::arrangement::BoundedObject::resize ( bool left,
ResizeType type,
double ticks,
bool during_ui_action )

Resizes the object on the left side or right side by given amount of ticks, for objects that do not have loops (currently none?

keep it as reference).

Parameters
left1 to resize left side, 0 to resize right side.
ticksNumber of ticks to resize.
during_ui_actionWhether this is called during a UI action (not at the end).
Exceptions
ZrythmExceptionon failure.

◆ set_end_pos_full_size()

template<typename SelfT>
requires (FinalArrangerObjectSubclass<SelfT>)
void zrythm::structure::arrangement::BoundedObject::set_end_pos_full_size ( this SelfT & self,
const dsp::Position & pos,
dsp::FramesPerTick frames_per_tick )
inline

Sets the end position of the ArrangerObject and also sets the loop end and fade out (if object supports those) to that position.

Definition at line 125 of file bounded_object.h.

◆ set_end_position_unvalidated()

void zrythm::structure::arrangement::BoundedObject::set_end_position_unvalidated ( const dsp::Position & pos)
inline

Definition at line 64 of file bounded_object.h.

◆ set_start_pos_full_size()

template<typename SelfT>
requires (FinalArrangerObjectSubclass<SelfT>)
void zrythm::structure::arrangement::BoundedObject::set_start_pos_full_size ( this SelfT & self,
const Position & pos,
dsp::FramesPerTick frames_per_tick )
inline

Sets the end position of the ArrangerObject and also sets the loop end and fade out (if object supports those) so that they are at the end.

Definition at line 108 of file bounded_object.h.

Friends And Related Symbol Documentation

◆ from_json

auto from_json ( const nlohmann::json & j,
BoundedObject & object )
friend

Definition at line 288 of file bounded_object.h.

◆ to_json

auto to_json ( nlohmann::json & j,
const BoundedObject & object )
friend

Definition at line 284 of file bounded_object.h.

Field Documentation

◆ end_pos_

utils::QObjectUniquePtr<PositionProxy> zrythm::structure::arrangement::BoundedObject::end_pos_

End Position, if the object has one.

This is exclusive of the material, i.e., the data at this position is not counted (for audio regions at least, TODO check for others).

Definition at line 300 of file bounded_object.h.


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