From 086ac9c59ff0554ca34db17e51f3f9302a656b40 Mon Sep 17 00:00:00 2001 From: Comment Date: Mon, 3 Feb 2014 08:48:44 +0000 Subject: NT refactoring audio analysis --- NT/src/rotor.h | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'NT/src/rotor.h') diff --git a/NT/src/rotor.h b/NT/src/rotor.h index f2e19b5..038334b 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -90,14 +90,21 @@ namespace Rotor { public: Enum(std::initializer_list init={},int def=0) : labels(init), value(def){}; int get_value(){return value;}; - operator int () const { + operator int () const { //overload C style cast to int return value; } + friend istream& operator>> (istream &in, Enum &en); private: std::vector labels; int value; }; - + + istream& operator>> (istream &in, Enum &en) + { + in >> en.value; + return in; + } + class Audio_frame{ public: Audio_frame(uint16_t *_samples,int _channels,int _numsamples){ @@ -212,9 +219,7 @@ namespace Rotor { void init(Json::Value s){ name=s["name"].asString(); if (!s["input"].empty()){ - for (uint32_t i=0;i &nodes){ @@ -229,17 +234,17 @@ namespace Rotor { } Json::Value to_json(); std::string get_type(){ - return TypeName::Get(); + return TypeName::Get(); } bool connect(Node* target){ //array does not connect this way return false; } - void add(std::string _name,std::string _input,bool _connectable=true){ - values.push_back(Variable_type(_name,_input,_connectable)); + void add(std::string _name="",std::string _description="",std::string _title="",bool _connectable=true){ + values.push_back(Variable_type(_name,_description,_title,_connectable)); } - void add(std::string _name="",bool _connectable=true,int num=1){ - for (int i=0;i(_name,"",_connectable)); + void add(int num,std::string _name="",std::string _description="",std::string _title="",bool _connectable=true){ + for (int i=0;i(_name,_description,_title,_connectable)); } bool connect(uint32_t which,Node* target){ if (values.size()>which){ @@ -261,16 +266,7 @@ namespace Rotor { std::vector> values; T value; }; - //don't forget the dupliicate inlets - //it needs to be a property of a var - //vars need to be: - //std::unordered_map>> - //?? - //or could it be that a var has properties - //var needs to be a class? - //or multi var could be a subclass of var? - //with an extra accessor const T& get(int which,const Frame_parameters &frame) - //in Node we could have create_multi_inlet() and add_multi_inlet() + //could specialise a variable type operator double() etc to allow direct cast class Node { //base type for node pointers public: Node(){type="";type_id="";id="";description="";}; -- cgit v1.2.3