audio/position.h file

Position struct and API.

Classes

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

Typedefs

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

Functions

void position_set_to_bar(Position* position, int bar_no)
Sets position to given bar.
void position_set_tick(Position* position, long tick)
Sets the tick of the Position.
void position_sort_array(Position* array, const size_t size)
Sorts an array of Position's.
void position_add_frames(Position* pos, const long frames)
Adds the frames to the position and updates the rest of the fields, and makes sure the frames are still accurate.
auto position_to_frames(const Position* position) -> long
Converts position bars/beats/quarter beats/ticks to frames.
void position_from_seconds(Position* position, double secs)
Converts seconds to position and puts the result in the given Position.
auto position_to_ms(const Position* pos) -> long
Returns the Position in milliseconds.
void position_from_ticks(Position* pos, long ticks)
Sets position to the given total tick count.
void position_snap(const Position* prev_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.
void position_update_frames(Position* position)
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.
auto position_get_ticks_diff(const Position* end_pos, const Position* start_pos, const SnapGrid* sg) -> long
Returns the difference in ticks between the two Position's, snapped based on the given SnapGrid (if any).
auto position_stringize_allocate(const Position* pos) -> char*
Creates a string in the form of "0.0.0.0" from the given position.
void position_stringize(const Position* pos, char* buf)
Creates a string in the form of "0.0.0.0" from the given position.
void position_print(const Position* pos)
Prints the Position in the "0.0.0.0" form.
auto position_get_total_bars(const Position* pos) -> int
Returns the total number of bars not including the current one.
auto position_get_total_beats(const Position* pos) -> int
Returns the total number of beats not including the current one.

Variables

static const Position POSITION_START_POS
Default start position to be used for setting structs equal (i.e., new_pos = POSITION_START_POS), and calculations.

Defines

#define position_compare(p1, p2)
Compares 2 positions based on their frames.
#define position_is_before(_pos, _cmp)
Checks if _pos is before _cmp.
#define position_is_before_or_equal(_pos, _cmp)
Checks if _pos is before or equal to _cmp.
#define position_is_equal(_pos, _cmp)
Checks if _pos is equal to _cmp.
#define position_is_after(_pos, _cmp)
Checks if _pos is after _cmp.
#define position_is_after_or_equal(_pos, _cmp)
Checks if _pos is after or equal to _cmp.
#define position_is_between(_pos, _start, _end)
Returns if _pos is after or equal to _start and before _end.
#define DEFINE_START_POS
Start Position to be used in calculations.
#define POSITION_INIT_ON_STACK(name)
Inits the default position on the stack.
#define position_init(__pos)
Initializes given position.
#define POSITION_MOVE_BY_TICKS(_tmp_pos, _use_cached, _obj, _pos_name, _ticks, _update_flag)
Moves the Position of an object only has a start position defined by the argument pos_name and a cache position named cache_##pos_name by the given amount of ticks.
#define POSITION_MOVE_BY_TICKS_W_LENGTH(_tmp_pos, _use_cached, _obj, _ticks, _update_flag)
Moves the Position of an object that has a start and end position named start_pos and end_pos and cached positions named cache_start_pos and cache_end_pos by given amount of ticks.
#define position_set_to_pos(_pos, _target)
Sets position to target position.

Define documentation

#define position_compare(p1, p2)

Compares 2 positions based on their frames.

negative = p1 is earlier 0 = equal positive = p2 is earlier

#define position_init(__pos)

Initializes given position.

Assumes the given argument is a Pointer *.

#define POSITION_MOVE_BY_TICKS(_tmp_pos, _use_cached, _obj, _pos_name, _ticks, _update_flag)

Moves the Position of an object only has a start position defined by the argument pos_name and a cache position named cache_##pos_name by the given amount of ticks.

Parameters
_tmp_pos A Position variable to use for calculations so we don't create one in the macro.
_use_cached An int variable set to 1 for using the cached positions or 0 for moving the normal positions.
_obj The object.
_pos_name The name of the position.
_ticks The number of ticks to move by.
_update_flag

This also assumes that there is a SET_POS defined. See audio/chord_object.c for an example.

This doesn't allow the start position to be less than 1.1.1.0.

#define POSITION_MOVE_BY_TICKS_W_LENGTH(_tmp_pos, _use_cached, _obj, _ticks, _update_flag)

Moves the Position of an object that has a start and end position named start_pos and end_pos and cached positions named cache_start_pos and cache_end_pos by given amount of ticks.

Parameters
_tmp_pos A Position variable to use for calculations so we don't create one in the macro.
_use_cached An int variable set to 1 for using the cached positions or 0 for moving the normal positions.
_obj The object.
_ticks The number of ticks to move by.
_update_flag ArrangerObjectUpdateFlag.

This also assumes that there is a SET_POS defined. See audio/region.c for an example.

This doesn't allow the start position to be less than 1.1.1.0.

#define position_set_to_pos(_pos, _target)

Sets position to target position.

Assumes each position is Position *.