summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-11-18 15:29:40 +0000
committerTim Redfern <tim@eclectronics.org>2013-11-18 15:29:40 +0000
commitb46286b8262cd5a4b96ac318a6d85d3db39e09e5 (patch)
tree61e6e2de8d22193f3f066100648de30dc28fa349 /rotord
parenta36735b4585521218268da5fed2214ba239b4c2a (diff)
lyrics rough version
Diffstat (limited to 'rotord')
-rw-r--r--rotord/src/nodes_drawing.h2
-rw-r--r--rotord/src/rotor.h12
2 files changed, 10 insertions, 4 deletions
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: