Skip to content

Instantly share code, notes, and snippets.

@nariakiiwatani
Created January 22, 2016 12:09
Show Gist options
  • Save nariakiiwatani/f0c09fe133a3cace9696 to your computer and use it in GitHub Desktop.
Save nariakiiwatani/f0c09fe133a3cace9696 to your computer and use it in GitHub Desktop.
#pragma once
class TapTempo
{
public:
void tap() {
float time = ofGetSystemTime();
interval_ = mark_-time;
mark_ = time;
}
float getPosition() {
return ofWrap(ofMap(ofGetSystemTime(), mark_, mark_+interval_, 0, 1),0,1);
}
private:
float mark_=0;
float interval_=0;
};
class SecondsTap : public TapTempo
{
public:
void update() {
int sec = ofGetSeconds();
if(prev_sec_ != sec) {
tap();
prev_sec_ = sec;
}
}
private:
int prev_sec_ = 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment