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* self, int bar)
Sets position to given bar.
void position_sort_array(Position* array, const size_t size)
Sorts an array of Position's.
auto __attribute__((access(read_write, 1))) void position_add_frames(Position *pos -> HOT
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.
auto position_from_ticks(Position* pos, double ticks) -> HOT NONNULL void
Sets position to the given total tick count.
auto position_to_ms(const Position* pos) -> long
Returns the Position in milliseconds.
void position_snap(Position* start_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.
auto position_update_ticks_from_frames(Position* position) -> HOT NONNULL void
Updates ticks.
auto position_update_frames_from_ticks(Position* position) -> HOT NONNULL void
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_to_string_alloc(const Position* pos) -> NONNULL char*
Creates a string in the form of "0.0.0.0" from the given position.
auto position_to_string(const Position* pos, char* buf) -> NONNULL void
Creates a string in the form of "0.0.0.0" from the given position.
auto position_print(const Position* pos) -> NONNULL void
Prints the Position in the "0.0.0.0" form.
auto position_get_total_bars(const Position* pos, bool include_current) -> NONNULL int
Returns the total number of beats.
auto position_get_total_beats(const Position* pos, bool include_current) -> NONNULL int
Returns the total number of beats.
auto position_get_total_sixteenths(const Position* pos, bool include_current) -> NONNULL int
Returns the total number of sixteenths not including the current one.
auto position_change_sign(Position* pos) -> NONNULL void
Changes the sign of the position.
auto position_get_bars(const Position* pos, bool start_at_one) -> NONNULL int
Gets the bars of the position.
auto position_get_beats(const Position* pos, bool start_at_one) -> NONNULL int
Gets the beats of the position.
auto position_get_sixteenths(const Position* pos, bool start_at_one) -> NONNULL int
Gets the sixteenths of the position.
auto position_get_ticks(const Position* pos) -> NONNULL double
Gets the ticks of the position.

Variables

static const Position POSITION_START
Start Position to be used in calculations.

Defines

#define position_between_frames_excl2(pos, f1, f2)
Whether the position starts on or after f1 and before f2.
#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_compare_ticks(p1, p2)
Compares 2 positions based on their total ticks.
#define position_is_between(_pos, _start, _end)
Returns if _pos is after or equal to _start and before _end.
#define position_is_between_excl_start(_pos, _start, _end)
Returns if _pos is after _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 position_to_frames(x)
Deprecated - added for compatibility.

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_compare_ticks(p1, p2)

Compares 2 positions based on their total ticks.

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 *.