Created
January 22, 2016 12:09
-
-
Save nariakiiwatani/f0c09fe133a3cace9696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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