diff options
Diffstat (limited to 'NT/src/rotor.h')
| -rw-r--r-- | NT/src/rotor.h | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h index d2d7d00..8fbba7d 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -88,7 +88,8 @@ namespace Rotor { class Enum{ //enumerated string type for menus public: - Enum(std::initializer_list<std::string> init) : labels(init){}; + Enum(std::initializer_list<std::string> init={},int def=0) : labels(init), value(def){}; + int get_value(){return value;}; private: std::vector<std::string> labels; int value; @@ -105,10 +106,11 @@ namespace Rotor { int channels,numsamples; }; class Frame_parameters{ + //chosen to be used as a struct: less overhead etc public: - Frame_parameters(double _time,double _framerate,double _duration,int _w,int _h,Audio_frame *_audio=nullptr) + Frame_parameters(double _time=0.0,double _framerate=25.0,double _duration=20.0,int _w=640,int _h=360,Audio_frame *_audio=nullptr) { time=_time; framerate=_framerate; duration=_duration; w=_w; h=_h;audio=_audio;}; - Frame_parameters(int _frame,double _framerate,double _duration,int _w,int _h,Audio_frame *_audio=nullptr) + Frame_parameters(int _frame,double _framerate=25.0,double _duration=20.0,int _w=640,int _h=360,Audio_frame *_audio=nullptr) { time=((double)_frame)/_framerate; framerate=_framerate; duration=_duration; w=_w; h=_h;audio=_audio;}; int h,w; Frame_parameters lastframe() const{ @@ -117,13 +119,10 @@ namespace Rotor { Frame_parameters nextframe() const{ return Frame_parameters(time+(1.0/framerate),framerate,duration,w,h); } - double get_time() const{ - return time; - } - private: double time; //num/denom ? double framerate; double duration; + private: Audio_frame *audio; }; class Variable { //pure virtual base type for variable pointers @@ -149,9 +148,8 @@ namespace Rotor { }; template <class T> class Variable_type : public Variable { public: - Variable_type(std::string _name="",std::string _input="",bool _connectable=true){ - name=_name; - input=_input; + Variable_type(std::string _name="",std::string _description="",std::string _title="",bool _connectable=true){ + Variable(_name,_description,_title); connectable=_connectable; }; void init(Json::Value s){ @@ -182,12 +180,12 @@ namespace Rotor { } return false; } - const T& get(const Frame_parameters &frame){ + const T& get(const Frame_parameters &frame=Frame_parameters()){ //if (connection) std::cerr<<"still connected to '"<<(dynamic_cast<Node_type<T>*>(connection))->get_type()<<"'"<<std::endl; //else std::cerr<<"connection disappeared"<<std::endl; if (connection){ //std::cerr<<"retreiving value from '"<<(dynamic_cast<Node_type<T>*>(connection))->get_type()<<"' node ("<<get_type()<<"):"<<(dynamic_cast<Node_type<T>*>(connection))->get_output(frame)<<std::endl; - return (dynamic_cast<Node_type<T>*>(connection))->get_output(frame); + value=(dynamic_cast<Node_type<T>*>(connection))->get_output(frame); } //else std::cerr<<"variable: returning default"<<std::endl; return value; @@ -321,16 +319,16 @@ namespace Rotor { if (!settings["log_id"].empty()) log_id=settings["log_id"].asString(); } std::string get_output_type(){return TypeName<NT>::Get();}; - template <class IT> Variable_type<IT>* create_inlet(std::string name){ - vars[name]=new Variable_type<IT>(name,"",true); + template <class IT> Variable_type<IT>* create_inlet(std::string name="",std::string description="",std::string title="",IT _default=IT()){ + vars[name]=new Variable_type<IT>(name,description,title,true); return (dynamic_cast<Variable_type<IT>*>(vars[name])); } template <class IT> Variable_type<IT>* create_attribute(std::string name="",std::string description="",std::string title="",IT _default=IT()){ - vars[name]=new Variable_type<IT>(name,"",false); + vars[name]=new Variable_type<IT>(name,description,title,false); return (dynamic_cast<Variable_type<IT>*>(vars[name])); } - template <class IT> Variable_array_type<IT>* create_array(std::string name){ - vars[name]=new Variable_array_type<IT>(name); + template <class IT> Variable_array_type<IT>* create_array(std::string name="",std::string description="",std::string title="",IT _default=IT()){ + vars[name]=new Variable_array_type<IT>(name,description,title); return (dynamic_cast<Variable_array_type<IT>*>(vars[name])); } //enum will require specialisation |
