a highly automated and intuitive digital audio workstation
No Matches
position.h File Reference

Position struct and API. More...

#include "utils/types.h"
#include "utils/yaml.h"
Include dependency graph for position.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Position
 A Position is made up of bars.beats.sixteenths.ticks. More...


#define position_add_sixteenths(_pos, _s)    position_add_ticks ((_pos), (_s) * TICKS_PER_SIXTEENTH_NOTE)
#define position_add_beats(_pos, _b)
#define position_add_bars(_pos, _b)
#define position_snap_simple(pos, sg)   position_snap (NULL, pos, NULL, NULL, sg)
#define POSITION_MAX_BAR   160000
#define position_between_frames_excl2(pos, f1, f2)    ((pos)->frames >= f1 && (pos)->frames < f2)
 Whether the position starts on or after f1 and before f2.
#define position_compare_frames(p1, p2)   ((p1)->frames - (p2)->frames)
 Compares 2 positions based on their frames.
#define position_is_before(_pos, _cmp)    (position_compare_frames (_pos, _cmp) < 0)
 Checks if _pos is before _cmp.
#define position_is_before_or_equal(_pos, _cmp)    (position_compare_frames (_pos, _cmp) <= 0)
 Checks if _pos is before or equal to _cmp.
#define position_is_equal(_pos, _cmp)    (position_compare_frames (_pos, _cmp) == 0)
 Checks if _pos is equal to _cmp.
#define position_is_after(_pos, _cmp)   (position_compare_frames (_pos, _cmp) > 0)
 Checks if _pos is after _cmp.
#define position_is_after_or_equal(_pos, _cmp)    (position_compare_frames (_pos, _cmp) >= 0)
 Checks if _pos is after or equal to _cmp.
#define position_is_positive(pos)   ((pos)->frames >= 0 && (pos)->ticks >= 0)
#define position_compare_ticks(p1, p2)   ((p1)->ticks - (p2)->ticks)
 Compares 2 positions based on their total ticks.
#define position_is_equal_ticks(p1, p2)    (fabs (position_compare_ticks (p1, p2)) <= DBL_EPSILON)
#define position_is_between(_pos, _start, _end)    (position_is_after_or_equal (_pos, _start) && position_is_before (_pos, _end))
 Returns if _pos is after or equal to _start and before _end.
#define position_is_between_excl_start(_pos, _start, _end)    (position_is_after (_pos, _start) && position_is_before (_pos, _end))
 Returns if _pos is after _start and before _end.
#define position_min(p1, p2)   (position_compare_frames (p1, p2) < 0 ? p1 : p2)
 Returns minimum of p1 and p2.
#define position_max(p1, p2)   (position_compare_frames (p1, p2) > 0 ? p1 : p2)
 Returns maximum of p1 and p2.
#define POSITION_INIT_ON_STACK(name)   Position name = POSITION_START;
 Inits the default position on the stack.
#define position_init(__pos)   *(__pos) = POSITION_START
 Initializes given position.
#define position_set_to_pos(_pos, _target)   *(_pos) = *(_target)
 Sets position to target position.
#define position_to_frames(x)   ((x)->frames)
 Deprecated - added for compatibility.
#define position_to_ticks(x)   ((x)->ticks)


void position_set_to_bar (Position *self, int bar)
 Sets position to given bar.
void position_sort_array (Position *array, const size_t size)
 Sorts an array of Position's.
HOT void position_add_frames (Position *pos, const signed_frame_t frames)
 Adds the frames to the position and updates the rest of the fields, and makes sure the frames are still accurate.
void position_from_seconds (Position *position, double secs)
 Converts seconds to position and puts the result in the given Position.
HOT NONNULL void position_from_frames (Position *pos, const signed_frame_t frames)
HOT NONNULL void position_from_ticks (Position *pos, double ticks)
 Sets position to the given total tick count.
NONNULL void position_from_ms (Position *pos, const signed_ms_t ms)
NONNULL void position_from_bars (Position *pos, int bars)
HOT NONNULL void position_add_ticks (Position *self, double ticks)
signed_ms_t position_to_ms (const Position *pos)
 Returns the Position in milliseconds.
signed_frame_t position_ms_to_frames (const double ms)
double position_ms_to_ticks (const double ms)
void position_add_ms (Position *pos, const double ms)
void position_add_minutes (Position *pos, int mins)
void position_add_seconds (Position *pos, const signed_sec_t seconds)
void position_snap (const Position *start_pos, Position *pos, Track *track, Region *region, const SnapGrid *sg)
 Snaps position using given options.
void position_set_min_size (const Position *start_pos, Position *end_pos, SnapGrid *snap)
 Sets the end position to be 1 snap point away from the start pos.
HOT NONNULL void position_update_ticks_from_frames (Position *position, double ticks_per_frame)
 Updates ticks.
signed_frame_t position_get_frames_from_ticks (double ticks, double frames_per_tick)
 Converts ticks to frames.
HOT NONNULL void position_update_frames_from_ticks (Position *self, double frames_per_tick)
 Updates frames.
void position_get_midway_pos (Position *start_pos, Position *end_pos, Position *pos)
 Calculates the midway point between the two Positions and sets it on pos.
double position_get_ticks_diff (const Position *end_pos, const Position *start_pos, const SnapGrid *sg)
 Returns the difference in ticks between the two Position's, snapped based on the given SnapGrid (if any).
NONNULL char * position_to_string_alloc (const Position *pos)
 Creates a string in the form of "" from the given position.
NONNULL void position_to_string_full (const Position *pos, char *buf, int decimal_places)
NONNULL void position_to_string (const Position *pos, char *buf)
 Creates a string in the form of "" from the given position.
NONNULL WARN_UNUSED_RESULT bool position_parse (Position *pos, const char *str)
 Parses a position from the given string.
NONNULL void position_print (const Position *pos)
 Prints the Position in the "" form.
NONNULL void position_print_range (const Position *pos, const Position *pos2)
NONNULL int position_get_total_bars (const Position *pos, bool include_current)
 Returns the total number of beats.
NONNULL int position_get_total_beats (const Position *pos, bool include_current)
 Returns the total number of beats.
NONNULL int position_get_total_sixteenths (const Position *pos, bool include_current)
 Returns the total number of sixteenths not including the current one.
NONNULL void position_change_sign (Position *pos)
 Changes the sign of the position.
NONNULL int position_get_bars (const Position *pos, bool start_at_one)
 Gets the bars of the position.
NONNULL int position_get_beats (const Position *pos, bool start_at_one)
 Gets the beats of the position.
NONNULL int position_get_sixteenths (const Position *pos, bool start_at_one)
 Gets the sixteenths of the position.
NONNULL double position_get_ticks (const Position *pos)
 Gets the ticks of the position.
NONNULL bool position_validate (const Position *pos)

Detailed Description

Position struct and API.

Definition in file position.h.