diff options
| -rwxr-xr-x | lyricstimer/timelyrics | 8 | ||||
| -rw-r--r-- | rotord/src/nodes_drawing.h | 2 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 12 |
3 files changed, 14 insertions, 8 deletions
diff --git a/lyricstimer/timelyrics b/lyricstimer/timelyrics index 2d6e071..7b50d0e 100755 --- a/lyricstimer/timelyrics +++ b/lyricstimer/timelyrics @@ -34,15 +34,15 @@ enable_echo( sys.stdin.fileno(),False) start=0.0 down=0.0 +printeddown=0.0 state="up" -count=0 def handle_up (event): - global start,down,state,count - if count>0: + global start,down,state,printeddown + if printeddown!=down: print "[",down,",",time()-(start+down),"]" + printeddown=down state="up" - count+=1 def handle_down (event): global start,down,state diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h index 914f064..77a74cb 100644 --- a/rotord/src/nodes_drawing.h +++ b/rotord/src/nodes_drawing.h @@ -125,7 +125,7 @@ namespace Rotor { ~Lyrics(){}; Lyrics* clone(map<string,string> &_settings) { return new Lyrics(_settings);}; string select_text(const Frame_spec &frame){ - return "Hello, world!"; + return ((Lyrics_attribute*)attributes["lyrics"])->get_lyric((Time_spec)frame); } private: }; diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 1c8e992..0833096 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -264,13 +264,19 @@ namespace Rotor { for (auto l:lyrics){ cerr<<l.first<<":"<<l.second.first<<" ("<<l.second.second<<")"<<endl; } + lyrics[-1.0f]=make_pair("",0.0f); //start with an empty entry } const string &get_lyric(const Time_spec &time){ - + if (lyrics.size()) { + auto l=lyrics.upper_bound(time.time); + l--; + //cerr<<(time.time)<<" "<<l->second.first<<","<<(l->first)<<" ("<<(l->second.second)<<")"<<endl; + if ((time.time>l->first)&&((time.time-l->first) < l->second.second)) return l->second.first; + } + return ""; } private: - std::map<float,std::pair<string,float> > lyrics; - + std::map<float,std::pair<string,float> > lyrics; //lyrics[startime]=pair<lyric,endtime> }; class Node{ public: |
