abletonlink
===========

Lightweight Lua wrapper of the Ableton Link C API ([abl_link][abl_link]).

API
---

The module follows the C API very closely.
See the [`abl_link.h`][abl_link.h] for comments for the various methods.

The module table has three members:

- `abletonlink._VERSION`: a string like `"1.0.0"`
- `abletonlink.create(number bpm)`: creates an `abl_link` instance
- `abletonlink.create_session_state()`: creates an `abl_link_session_state` instance

`abl_link` instances have the following methods:

- `link:is_enabled() -> bool`
- `link:enable(bool?)` (defaults to true)
- `link:is_start_stop_sync_enabled() -> bool`
- `link:enable_start_stop_sync(bool?)` (defaults to true)
- `link:num_peers() -> int`
- `link:clock_micros() -> int`
- `link:capture_audio_session_state(session_state output)`
- `link:commit_audio_session_state(session_state input)`
- `link:capture_app_session_state(session_state output)`
- `link:commit_app_session_state(session_state input)`
- `link:destroy()`:
   Destroys this instance.
   Calling any other method on a destroyed instance causes an error.
   This is automatically called in __gc.
- `link:set_*_callback` are not currently implemented.

`abl_link_session_state` instances have the following methods:

- `session_state:tempo() -> number`
- `session_state:set_tempo(number bpm, int at_time)`
- `session_state:beat_at_time(int time, number quantum) -> number`
- `session_state:phase_at_time(int time, number quantum) -> number`
- `session_state:time_at_beat(number beat, number quantum) -> int`
- `session_state:request_beat_at_time(number beat, int time, number quantum)`
- `session_state:force_beat_at_time(number beat, int time, number quantum)`
- `session_state:set_is_playing(bool, int at_time)`
- `session_state:is_playing() -> bool`
- `session_state:time_for_is_playing() -> int`
- `session_state:request_beat_at_start_playing_time(number beat, number quantum)`
- `session_state:set_is_playing_and_request_beat_at_time(bool, int time, number beat, number quantum)`
- `session_state:destroy()`:
   Destroys this instance.
   Calling any other method on a destroyed instance causes an error.
   This is automatically called in __gc.

[abl_link]: https://github.com/Ableton/link/tree/master/extensions/abl_link
[abl_link.h]: https://github.com/Ableton/link/blob/master/extensions/abl_link/include/abl_link.h
