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

Snap/grid information. More...

#include <src/dsp/snap_grid.h>

Inheritance diagram for zrythm::dsp::SnapGrid:
Collaboration diagram for zrythm::dsp::SnapGrid:

Public Types

enum class  NoteLengthType { Link , LastObject , Custom }
using SnapEventCallback
using LastObjectLengthProvider = std::function<double ()>

Signals

void snapAdaptiveChanged ()
void snapToGridChanged ()
void snapToEventsChanged ()
void keepOffsetChanged ()
void sixteenthsVisibleChanged ()
void beatsVisibleChanged ()
void snapNoteLengthChanged ()
void snapNoteTypeChanged ()
void lengthTypeChanged ()
void snapChanged ()

Public Member Functions

 SnapGrid (const TempoMap &tempo_map, utils::NoteLength default_note_length, LastObjectLengthProvider last_object_length_provider, QObject *parent=nullptr)
bool snapAdaptive () const
void setSnapAdaptive (bool adaptive)
bool snapToGrid () const
void setSnapToGrid (bool snap)
bool snapToEvents () const
void setSnapToEvents (bool snap)
bool keepOffset () const
void setKeepOffset (bool keep)
bool sixteenthsVisible () const
void setSixteenthsVisible (bool visible)
bool beatsVisible () const
void setBeatsVisible (bool visible)
utils::NoteLength snapNoteLength () const
void setSnapNoteLength (utils::NoteLength length)
utils::NoteType snapNoteType () const
void setSnapNoteType (utils::NoteType type)
NoteLengthType lengthType () const
void setLengthType (NoteLengthType type)
QString snapString () const
Q_INVOKABLE double snapWithoutStartTicks (double ticks)
Q_INVOKABLE double snapWithStartTicks (double ticks, double startTicks)
Q_INVOKABLE double nextSnapPoint (double ticks) const
Q_INVOKABLE double prevSnapPoint (double ticks) const
Q_INVOKABLE double closestSnapPoint (double ticks) const
Q_INVOKABLE double snapTicks (int64_t ticks) const
Q_INVOKABLE double defaultTicks (int64_t ticks) const
units::precise_tick_t snap (units::precise_tick_t ticks, std::optional< units::precise_tick_t > start_ticks=std::nullopt) const
void set_event_callback (SnapEventCallback callback)
void set_last_object_length_callback (LastObjectLengthProvider callback)
void clear_callbacks ()

Static Public Member Functions

static constexpr int get_ticks_from_length_and_type (utils::NoteLength length, utils::NoteType type, int ticks_per_bar, int ticks_per_beat)
static QString stringize_length_and_type (utils::NoteLength note_length, utils::NoteType note_type)

Properties

bool snapAdaptive
bool snapToGrid
bool snapToEvents
bool keepOffset
bool sixteenthsVisible
bool beatsVisible
zrythm::utils::NoteLength snapNoteLength
zrythm::utils::NoteType snapNoteType
NoteLengthType lengthType
QString snapString

Friends

void to_json (nlohmann::json &j, const SnapGrid &p)
void from_json (const nlohmann::json &j, SnapGrid &p)

Detailed Description

Snap/grid information.

Definition at line 21 of file snap_grid.h.

Member Typedef Documentation

◆ LastObjectLengthProvider

using zrythm::dsp::SnapGrid::LastObjectLengthProvider = std::function<double ()>

Definition at line 54 of file snap_grid.h.

◆ SnapEventCallback

using zrythm::dsp::SnapGrid::SnapEventCallback
Initial value:
std::function<std::vector<double> (double start_ticks, double end_ticks)>

Definition at line 52 of file snap_grid.h.

Member Enumeration Documentation

◆ NoteLengthType

Enumerator
Link 

Link length with snap setting.

LastObject 

Use last created object's length.

Custom 

Custom length.

Definition at line 39 of file snap_grid.h.

Member Function Documentation

◆ beatsVisible()

bool zrythm::dsp::SnapGrid::beatsVisible ( ) const
inline

Definition at line 78 of file snap_grid.h.

◆ get_ticks_from_length_and_type()

constexpr int zrythm::dsp::SnapGrid::get_ticks_from_length_and_type ( utils::NoteLength length,
utils::NoteType type,
int ticks_per_bar,
int ticks_per_beat )
inlinestaticconstexpr

Definition at line 126 of file snap_grid.h.

◆ keepOffset()

bool zrythm::dsp::SnapGrid::keepOffset ( ) const
inline

Definition at line 72 of file snap_grid.h.

◆ lengthType()

NoteLengthType zrythm::dsp::SnapGrid::lengthType ( ) const
inline

Definition at line 87 of file snap_grid.h.

◆ set_last_object_length_callback()

void zrythm::dsp::SnapGrid::set_last_object_length_callback ( LastObjectLengthProvider callback)
inline

Definition at line 120 of file snap_grid.h.

◆ sixteenthsVisible()

bool zrythm::dsp::SnapGrid::sixteenthsVisible ( ) const
inline

Definition at line 75 of file snap_grid.h.

◆ snap()

units::precise_tick_t zrythm::dsp::SnapGrid::snap ( units::precise_tick_t ticks,
std::optional< units::precise_tick_t > start_ticks = std::nullopt ) const
Parameters
ticks
start_ticksUsed when "keep offset" is enabled.

◆ snapAdaptive()

bool zrythm::dsp::SnapGrid::snapAdaptive ( ) const
inline

Definition at line 63 of file snap_grid.h.

◆ snapNoteLength()

utils::NoteLength zrythm::dsp::SnapGrid::snapNoteLength ( ) const
inline

Definition at line 81 of file snap_grid.h.

◆ snapNoteType()

utils::NoteType zrythm::dsp::SnapGrid::snapNoteType ( ) const
inline

Definition at line 84 of file snap_grid.h.

◆ snapToEvents()

bool zrythm::dsp::SnapGrid::snapToEvents ( ) const
inline

Definition at line 69 of file snap_grid.h.

◆ snapToGrid()

bool zrythm::dsp::SnapGrid::snapToGrid ( ) const
inline

Definition at line 66 of file snap_grid.h.

◆ snapWithoutStartTicks()

Q_INVOKABLE double zrythm::dsp::SnapGrid::snapWithoutStartTicks ( double ticks)
inline

Definition at line 93 of file snap_grid.h.

◆ snapWithStartTicks()

Q_INVOKABLE double zrythm::dsp::SnapGrid::snapWithStartTicks ( double ticks,
double startTicks )
inline

Definition at line 97 of file snap_grid.h.

◆ from_json

void from_json ( const nlohmann::json & j,
SnapGrid & p )
friend

Definition at line 228 of file snap_grid.h.

◆ to_json

void to_json ( nlohmann::json & j,
const SnapGrid & p )
friend

Definition at line 216 of file snap_grid.h.

Property Documentation

◆ beatsVisible

bool zrythm::dsp::SnapGrid::beatsVisible
readwrite

Definition at line 29 of file snap_grid.h.

◆ keepOffset

bool zrythm::dsp::SnapGrid::keepOffset
readwrite

Definition at line 27 of file snap_grid.h.

◆ lengthType

NoteLengthType zrythm::dsp::SnapGrid::lengthType
readwrite

Definition at line 32 of file snap_grid.h.

◆ sixteenthsVisible

bool zrythm::dsp::SnapGrid::sixteenthsVisible
readwrite

Definition at line 28 of file snap_grid.h.

◆ snapAdaptive

bool zrythm::dsp::SnapGrid::snapAdaptive
readwrite

Definition at line 24 of file snap_grid.h.

◆ snapNoteLength

zrythm::utils::NoteLength zrythm::dsp::SnapGrid::snapNoteLength
readwrite

Definition at line 30 of file snap_grid.h.

◆ snapNoteType

zrythm::utils::NoteType zrythm::dsp::SnapGrid::snapNoteType
readwrite

Definition at line 31 of file snap_grid.h.

◆ snapString

QString zrythm::dsp::SnapGrid::snapString
read

Definition at line 33 of file snap_grid.h.

◆ snapToEvents

bool zrythm::dsp::SnapGrid::snapToEvents
readwrite

Definition at line 26 of file snap_grid.h.

◆ snapToGrid

bool zrythm::dsp::SnapGrid::snapToGrid
readwrite

Definition at line 25 of file snap_grid.h.


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