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

Track span that offers helper methods on a range of tracks. More...

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

Inheritance diagram for ArrangerObjectSpan:
Collaboration diagram for ArrangerObjectSpan:

Public Types

using Base = utils::UuidIdentifiableObjectView<ArrangerObjectRegistry>
 
using VariantType = typename Base::VariantType
 
using ArrangerObjectUuid = typename Base::UuidType
 
using Position = dsp::Position
 
- Public Types inherited from zrythm::utils::UuidIdentifiableObjectView< ArrangerObjectRegistry >
using UuidType
 
using VariantType
 
using UuidRefType
 

Public Member Functions

void init_loaded (bool project, dsp::FramesPerTick frames_per_tick)
 Inits the selections after loading a project.
 
std::vector< VariantType > create_snapshots (const auto &object_factory, QObject &owner) const
 
auto create_new_identities (const auto &object_factory) const -> std::vector< ArrangerObjectUuidReference >
 
std::vector< VariantType > sort_by_indices (bool desc)
 Sorts the selections by their indices (eg, for regions, their track indices, then the lane indices, then the index in the lane).
 
auto get_first_object_and_pos (bool global) const -> std::pair< VariantType, Position >
 Gets first object of the given type (if any, otherwise matches all types) and its start position.
 
auto get_last_object_and_pos (bool global, bool ends_last) const -> std::pair< VariantType, Position >
 Gets last object of the given type (if any, otherwise matches all types) and its end (if applicable, otherwise start) position.
 
std::pair< TrackPtrVariant, TrackPtrVariant > get_first_and_last_track () const
 Gets the highest track in the selections.
 
std::pair< MidiNote *, MidiNote * > get_first_and_last_note () const
 
void paste_to_pos (const Position &pos, bool undoable)
 Pastes the given selections to the given Position.
 
void post_deserialize (dsp::FramesPerTick frames_per_tick)
 Code to run after deserializing a span of objects.
 
bool validate () const
 Used for debugging.
 
bool contains_undeletable_object () const
 Returns if the selections contain an undeletable object (such as the start marker).
 
bool contains_unclonable_object () const
 Returns if the selections contain an unclonable object (such as the start marker).
 
bool contains_unrenamable_object () const
 Whether the selections contain an unrenameable object (such as the start marker).
 
auto merge (dsp::FramesPerTick frames_per_tick) const -> ArrangerObjectUuidReference
 Checks whether an object matches the given parameters.
 
bool can_be_pasted () const
 Returns if the selections can be pasted at the current place/playhead.
 
bool all_on_same_lane () const
 
bool can_be_pasted_at (Position pos, int idx=-1) const
 Returns if the selections can be pasted at the given position/region.
 
bool contains_looped () const
 
bool can_be_merged () const
 
double get_length_in_ticks () const
 
bool contains_clip (const AudioClip &clip) const
 Whether the selections contain the given clip.
 
bool can_split_at_pos (Position pos) const
 
std::optional< VariantType > get_bounded_object_at_pos (dsp::Position pos, bool include_region_end=false) const
 Returns the region at the given position, or NULL.
 
void unlisten_note_diff (const ArrangerObjectSpan &prev) const
 Sets the listen status of notes on and off based on changes in the previous selections and the current selections.
 
- Public Member Functions inherited from zrythm::utils::UuidIdentifiableObjectView< ArrangerObjectRegistry >
 UuidIdentifiableObjectView (std::span< const VariantType > objects)
 Constructor for direct object range.
 
 UuidIdentifiableObjectView (std::span< const UuidRefType > refs)
 Constructor for UuidReference range.
 
 UuidIdentifiableObjectView (const ArrangerObjectRegistry &registry, std::span< const UuidType > uuids)
 Constructor for Uuid + Registry.
 
 UuidIdentifiableObjectView (const VariantType &obj)
 Single object constructor.
 
Iterator begin () const
 
Iterator end () const
 
VariantType operator[] (size_t index) const
 
VariantType front () const
 
VariantType back () const
 
VariantType at (size_t index) const
 
size_t size () const
 
bool empty () const
 
auto get_elements_by_type () const
 
auto as_base_type () const
 
bool contains_type () const
 
auto as_type () const
 
auto get_elements_derived_from () const
 

Static Public Member Functions

static auto name_projection (const VariantType &obj_var)
 
static Position position_projection (const VariantType &obj_var)
 
static Position end_position_with_start_position_fallback_projection (const VariantType &obj_var)
 
static auto midi_note_pitch_projection (const VariantType &obj_var)
 
static auto looped_projection (const VariantType &obj_var)
 
static auto is_timeline_object_projection (const VariantType &obj_var)
 
static auto is_editor_object_projection (const VariantType &obj_var)
 
static auto track_projection (const VariantType &obj_var)
 
static auto selected_projection (const VariantType &obj_var)
 
static auto deletable_projection (const VariantType &obj_var)
 
static auto cloneable_projection (const VariantType &obj_var)
 
static auto renameable_projection (const VariantType &obj_var)
 
template<FinalBoundedObjectSubclass BoundedObjectT>
static auto split_bounded_object (const BoundedObjectT &self, const auto &factory, const Position &global_pos, dsp::FramesPerTick frames_per_tick) -> std::pair< ArrangerObjectUuidReference, ArrangerObjectUuidReference >
 Splits the given object at the given position and returns a pair of newly-created objects (with unique identities).
 
static void copy_arranger_object_identifier (const VariantType &dest, const VariantType &src)
 Copies identifier values from src to this object.
 
- Static Public Member Functions inherited from zrythm::utils::UuidIdentifiableObjectView< ArrangerObjectRegistry >
static UuidType uuid_projection (const VariantType &var)
 
static ArrangerObjectRegistry::BaseType * base_projection (const VariantType &var)
 
static auto type_projection (const VariantType &var)
 
static auto derived_from_type_projection (const VariantType &var)
 
static auto type_transformation (const VariantType &var)
 
static auto derived_from_type_transformation (const VariantType &var)
 

Detailed Description

Track span that offers helper methods on a range of tracks.

Definition at line 13 of file arranger_object_span.h.

Member Typedef Documentation

◆ ArrangerObjectUuid

using ArrangerObjectSpan::ArrangerObjectUuid = typename Base::UuidType

Definition at line 19 of file arranger_object_span.h.

◆ Base

◆ Position

◆ VariantType

using ArrangerObjectSpan::VariantType = typename Base::VariantType

Definition at line 18 of file arranger_object_span.h.

Member Function Documentation

◆ can_be_pasted_at()

bool ArrangerObjectSpan::can_be_pasted_at ( Position pos,
int idx = -1 ) const

Returns if the selections can be pasted at the given position/region.

Parameters
posPosition to paste to.
idxTrack index to start pasting to, if applicable.

◆ cloneable_projection()

static auto ArrangerObjectSpan::cloneable_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 103 of file arranger_object_span.h.

◆ contains_clip()

bool ArrangerObjectSpan::contains_clip ( const AudioClip & clip) const
inline

Whether the selections contain the given clip.

Definition at line 307 of file arranger_object_span.h.

◆ contains_looped()

bool ArrangerObjectSpan::contains_looped ( ) const
inline

Definition at line 292 of file arranger_object_span.h.

◆ contains_unclonable_object()

bool ArrangerObjectSpan::contains_unclonable_object ( ) const
inline

Returns if the selections contain an unclonable object (such as the start marker).

Definition at line 249 of file arranger_object_span.h.

◆ contains_undeletable_object()

bool ArrangerObjectSpan::contains_undeletable_object ( ) const
inline

Returns if the selections contain an undeletable object (such as the start marker).

Definition at line 240 of file arranger_object_span.h.

◆ contains_unrenamable_object()

bool ArrangerObjectSpan::contains_unrenamable_object ( ) const
inline

Whether the selections contain an unrenameable object (such as the start marker).

Definition at line 256 of file arranger_object_span.h.

◆ copy_arranger_object_identifier()

static void ArrangerObjectSpan::copy_arranger_object_identifier ( const VariantType & dest,
const VariantType & src )
static

Copies identifier values from src to this object.

Used by UndoableActions where only partial copies that identify the original objects are needed.

Need to rethink this as it's not easily maintainable.

◆ create_new_identities()

auto ArrangerObjectSpan::create_new_identities ( const auto & object_factory) const -> std::vector<ArrangerObjectUuidReference>
inline

Definition at line 135 of file arranger_object_span.h.

◆ create_snapshots()

std::vector< VariantType > ArrangerObjectSpan::create_snapshots ( const auto & object_factory,
QObject & owner ) const
inline

Definition at line 123 of file arranger_object_span.h.

◆ deletable_projection()

static auto ArrangerObjectSpan::deletable_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 98 of file arranger_object_span.h.

◆ end_position_with_start_position_fallback_projection()

static Position ArrangerObjectSpan::end_position_with_start_position_fallback_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 46 of file arranger_object_span.h.

◆ get_bounded_object_at_pos()

std::optional< VariantType > ArrangerObjectSpan::get_bounded_object_at_pos ( dsp::Position pos,
bool include_region_end = false ) const
inline

Returns the region at the given position, or NULL.

Parameters
include_region_endWhether to include the region's end in the calculation.

Definition at line 326 of file arranger_object_span.h.

◆ get_first_and_last_note()

std::pair< MidiNote *, MidiNote * > ArrangerObjectSpan::get_first_and_last_note ( ) const
inline

Definition at line 187 of file arranger_object_span.h.

◆ get_first_object_and_pos()

auto ArrangerObjectSpan::get_first_object_and_pos ( bool global) const -> std::pair< VariantType, Position >

Gets first object of the given type (if any, otherwise matches all types) and its start position.

Parameters
globalFor non-timeline selections, whether to return the global position (local + region start).

◆ get_last_object_and_pos()

auto ArrangerObjectSpan::get_last_object_and_pos ( bool global,
bool ends_last ) const -> std::pair< VariantType, Position >

Gets last object of the given type (if any, otherwise matches all types) and its end (if applicable, otherwise start) position.

Parameters
ends_lastWhether to get the object that ends last, otherwise the object that starts last.
globalFor non-timeline selections, whether to return the global position (local + region start).

◆ get_length_in_ticks()

double ArrangerObjectSpan::get_length_in_ticks ( ) const
inline

Definition at line 299 of file arranger_object_span.h.

◆ init_loaded()

void ArrangerObjectSpan::init_loaded ( bool project,
dsp::FramesPerTick frames_per_tick )

Inits the selections after loading a project.

Parameters
projectWhether these are project selections (as opposed to clones).
frames_per_tickFrames per tick to use in position conversions.

◆ is_editor_object_projection()

static auto ArrangerObjectSpan::is_editor_object_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 85 of file arranger_object_span.h.

◆ is_timeline_object_projection()

static auto ArrangerObjectSpan::is_timeline_object_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 81 of file arranger_object_span.h.

◆ looped_projection()

static auto ArrangerObjectSpan::looped_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 67 of file arranger_object_span.h.

◆ merge()

auto ArrangerObjectSpan::merge ( dsp::FramesPerTick frames_per_tick) const -> ArrangerObjectUuidReference

Checks whether an object matches the given parameters.

If a parameter should be checked, the has_* argument must be true and the corresponding argument must have the value to be checked against. Merges the objects into one.

Note
All selections must be on the same lane.

◆ midi_note_pitch_projection()

static auto ArrangerObjectSpan::midi_note_pitch_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 63 of file arranger_object_span.h.

◆ name_projection()

static auto ArrangerObjectSpan::name_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 24 of file arranger_object_span.h.

◆ position_projection()

static Position ArrangerObjectSpan::position_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 41 of file arranger_object_span.h.

◆ post_deserialize()

void ArrangerObjectSpan::post_deserialize ( dsp::FramesPerTick frames_per_tick)
inline

Code to run after deserializing a span of objects.

Definition at line 205 of file arranger_object_span.h.

◆ renameable_projection()

static auto ArrangerObjectSpan::renameable_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 107 of file arranger_object_span.h.

◆ selected_projection()

static auto ArrangerObjectSpan::selected_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 93 of file arranger_object_span.h.

◆ sort_by_indices()

std::vector< VariantType > ArrangerObjectSpan::sort_by_indices ( bool desc)

Sorts the selections by their indices (eg, for regions, their track indices, then the lane indices, then the index in the lane).

Note
Only works for objects whose tracks exist.
Parameters
descDescending or not.

◆ split_bounded_object()

template<FinalBoundedObjectSubclass BoundedObjectT>
static auto ArrangerObjectSpan::split_bounded_object ( const BoundedObjectT & self,
const auto & factory,
const Position & global_pos,
dsp::FramesPerTick frames_per_tick ) -> std::pair<ArrangerObjectUuidReference, ArrangerObjectUuidReference>
inlinestatic

Splits the given object at the given position and returns a pair of newly-created objects (with unique identities).

Parameters
object_varThe object to split.
global_posThe position to split at (global).
Returns
A pair of the new objects created.
Note
This doesn't modify anything inside the project. The caller is responsible removing/adding objects to/from the project.

Definition at line 375 of file arranger_object_span.h.

◆ track_projection()

static auto ArrangerObjectSpan::track_projection ( const VariantType & obj_var)
inlinestatic

Definition at line 89 of file arranger_object_span.h.

◆ unlisten_note_diff()

void ArrangerObjectSpan::unlisten_note_diff ( const ArrangerObjectSpan & prev) const
inline

Sets the listen status of notes on and off based on changes in the previous selections and the current selections.

Definition at line 346 of file arranger_object_span.h.


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