From a36735b4585521218268da5fed2214ba239b4c2a Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 18 Nov 2013 14:40:41 +0000 Subject: simple lyrics script --- rotord/src/graph.cpp | 9 +++++++++ rotord/src/nodes_drawing.h | 2 +- rotord/src/rotor.h | 43 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) (limited to 'rotord/src') diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index ebfcece..cc624a8 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -344,6 +344,15 @@ bool Graph::parseJson(string &data,string &media_path){ } attr->init(vals); } + if (attr->type=="lyrics"){ + std::map > lyrics; + for (auto k:jnodes[i]["attributes"][m]["value"]){ + if (k.size()>2&&k[0].isString()&&k[1].isNumeric()&&k[2].isNumeric()) { + lyrics[k[1].asFloat()]=std::make_pair(k[0].asString(),k[2].asFloat()); + } + } + ((Lyrics_attribute*)attr)->init(lyrics); + } node->init_attribute(attribute); //cerr << "Rotor: setting attribute '"<type<<" to "<type<<" to "< &settings):Lyrics() { diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index a2c33d2..1c8e992 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -209,9 +209,24 @@ namespace Rotor { float get(const Time_spec& time); string type; }; + /* + tributes want to be extended beyond the original vision of a string that can be interpreted in different ways + could be a template? + typedef attribute intattribute; + could be a subclass ie + attributes=vector + class lyrics_attribute : public attribut + if((lyrics_attribute)attributes["lyrics"]) { + thislyric=(lyrics_attribute)attributes["lyrics"].findkey(1); + } + + 1) generic way to define and use attributes of different types + + */ class Attribute{ //description of a static attribute which can be an enumerated string array public: virtual ~Attribute(){}; + Attribute(){}; Attribute(const string &_desc,const string &_title,const string &_value,std::vector _vals={},std::string _type="string"): description(_desc),title(_title),value(_value),intVal(0),type(_type){ vals=_vals; init(_value); @@ -235,6 +250,27 @@ namespace Rotor { string type; std::vector vals; + }; + class Lyrics_attribute: public Attribute{ //description of a static attribute which can be an enumerated string array + public: + virtual ~Lyrics_attribute(){}; + Lyrics_attribute(const string &_desc,const string &_title){ + description=_desc; + title=_title; + type="lyrics"; + }; + void init(const std::map > _lyrics){ + lyrics=_lyrics; + for (auto l:lyrics){ + cerr< > lyrics; + }; class Node{ public: @@ -258,6 +294,11 @@ namespace Rotor { if (_vals.size()&&_type!="array") _type="enum"; //hack for incomplete attribute types attributes[_attr]=new Attribute(_desc,_title,_value,_vals,_type); }; + void create_empty_attribute(const string &_attr,const string &_desc,const string &_title,const string &_type="string") { + //initialiser without initialisation + if (_type=="lyrics") attributes[_attr]=new Lyrics_attribute(_desc,_title); + else attributes[_attr]=new Attribute(_desc,_title,"",{},_type); + }; void create_attribute(string *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector _vals={},std::string _type="string") { create_attribute(_attr,_desc,_title,_value,_vals,_type); alias=&(attributes[_attr]->value); @@ -396,7 +437,7 @@ namespace Rotor { Video_cycler(){ create_image_input("Image input","Image input"); create_signal_input("Selector","Selector input"); - create_attribute("mode","Cycling mode {cut|mix}","Mode","cut",{"cut","mix"}); + create_attribute("mode","Cycling mode","Mode","cut",{"cut","mix"}); create_attribute("length_mode","Transition length mode","Length mode","seconds",{"seconds","fraction"}); create_attribute("time_mode","Time mode","time mode","absolute",{"absolute","relative"}); create_parameter("transition_length","number","transition length","Transition length",-1.0f,0.0f,0.0f); -- cgit v1.2.3