Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ableton link clock module #1032

Merged
merged 19 commits into from Mar 25, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

add clock.get_tempo

  • Loading branch information
artfwo committed Mar 22, 2020
commit fb5716ea3ca297b8528769fa9918e4002d0f94c5
@@ -97,4 +97,9 @@ clock.get_time_beats = function()
return _norns.clock_get_time_beats()
end

clock.get_tempo = function()
return _norns.clock_get_tempo()
end


return clock
@@ -113,6 +113,16 @@ double clock_gettime_beats() {
return this_beat;
}

double clock_get_tempo() {
pthread_mutex_lock(&reference.lock);

double tempo = 60.0 / reference.beat_duration;

pthread_mutex_unlock(&reference.lock);

return tempo;
}

bool clock_schedule_resume_sync(int coro_id, double beats) {
double zero_beat_time;
double this_beat;
@@ -18,6 +18,7 @@ void clock_cancel_all();

double clock_gettime_beats();
double clock_gettime_secondsf();
double clock_get_tempo();

void clock_cancel(int);
void clock_cancel_coro(int);
@@ -223,6 +223,7 @@ static int _clock_cancel(lua_State *l);
static int _clock_internal_set_tempo(lua_State *l);
static int _clock_set_source(lua_State *l);
static int _clock_get_time_beats(lua_State *l);
static int _clock_get_tempo(lua_State *l);

// boilerplate: push a function to the stack, from field in global 'norns'
static inline void
@@ -419,6 +420,7 @@ void w_init(void) {
lua_register_norns("clock_internal_set_tempo", &_clock_internal_set_tempo);
lua_register_norns("clock_set_source", &_clock_set_source);
lua_register_norns("clock_get_time_beats", &_clock_get_time_beats);
lua_register_norns("clock_get_tempo", &_clock_get_tempo);

// name global extern table
lua_setglobal(lvm, "_norns");
@@ -1426,6 +1428,11 @@ int _clock_get_time_beats(lua_State *l) {
return 1;
}

int _clock_get_tempo(lua_State *l) {
lua_pushnumber(l, clock_get_tempo());
return 1;
}

void w_handle_monome_add(void *mdev) {
struct dev_monome *md = (struct dev_monome *)mdev;
int id = md->dev.id;
ProTip! Use n and p to navigate between commits in a pull request.