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, double 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, double ticks)
Sets position to the given total tick count.
void position_snap(const Position* prev_pos, Position* pos, Track* track, ZRegion* 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_ticks_and_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) -> double
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.
void position_change_sign(Position* pos)
Changes the sign of the position.

Variables

static const Position POSITION_START
Start Position to be used in 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 POSITION_INIT_ON_STACK(name)
Inits the default position on the stack.
#define position_init(__pos)
Initializes given position.
#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_set_to_pos(_pos, _target)

Sets position to target position.

Assumes each position is Position *.