diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-01-22 14:28:34 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-01-22 14:28:34 +0000 |
| commit | a879f37ff944cd7bf502f4e3520b7da3d8faf39b (patch) | |
| tree | 630ee0e87764e5982a00524f045b51d486f3292a /NT/src | |
| parent | c10e756720fe30ad2ffdcb54d83737aaad77190b (diff) | |
variable arrays working correctly
Diffstat (limited to 'NT/src')
| -rw-r--r-- | NT/src/graph.cpp | 3 | ||||
| -rw-r--r-- | NT/src/graph.h | 35 | ||||
| -rw-r--r-- | NT/src/nodes.h | 10 | ||||
| -rw-r--r-- | NT/src/rotor.h | 19 |
4 files changed, 40 insertions, 27 deletions
diff --git a/NT/src/graph.cpp b/NT/src/graph.cpp index 65bd6c8..f774528 100644 --- a/NT/src/graph.cpp +++ b/NT/src/graph.cpp @@ -68,9 +68,8 @@ bool Graph::parse_json(string &data,string &media_path){ // //node.create_links(nodes) //will allow the nodes to be passed into each member of a variable array + node->create_connections(nodes); nodes[node_id]=node; - nodes[node_id]->create_connections(nodes); - } else cerr << "ERROR: duplicate node '"<<node_id<<"' "<< endl; } diff --git a/NT/src/graph.h b/NT/src/graph.h index 76a4c1c..9213d71 100644 --- a/NT/src/graph.h +++ b/NT/src/graph.h @@ -1,10 +1,10 @@ #ifndef GRAPH_H #define GRAPH_H -/* -Graph object manages a collection of nodes and provides the interface for rendering frames - +/* +Represents a graph of rotor nodes and includes methods to manipulate nodes +TJR Jan 2014 */ #include "rotor.h" @@ -29,7 +29,7 @@ namespace Rotor { audio_loaded=false; cancelled=false; //audio_thumb=new Audio_thumbnailer(); - Log_name=""; + //Log_name=""; }; ~Graph(){ clear(); @@ -46,33 +46,34 @@ namespace Rotor { //think video_render should be part of render context //graph should just encapsulate the manipulation of the graph //specific nodes can be created as output targets - std::string uid; - std::string description; - std::unordered_map<std::string,Node*> nodes; + std::vector<Node*> find_nodes(const std::string &type); Node* find_node(const std::string &type); - Json::Value signal_render(const std::string &node,const double framerate); - bool video_render(const std::string &output_filename,const double framerate,int start, int end); + //--context// Json::Value signal_render(const std::string &node,const double framerate); + //--context// bool video_render(const std::string &output_filename,const double framerate,int start, int end); bool load_file(std::string filename,std::string media_path); bool parse_json(std::string &data,std::string &media_path); - Json::Value preview(std::string &node ,std::string &format,int frame,int w,int h); + //--context// Json::Value preview(std::string &node ,std::string &format,int frame,int w,int h); bool check_audio (std::string audio ,std::string path); - Json::Value print_features (std::string &node); + //--context// Json::Value print_features (std::string &node); //bool load_audio(const std::string &filename, std::vector<Audio_processor*> processors); - bool load_video(const std::string &node_id,const std::string &filename); + //bool load_video(const std::string &node_id,const std::string &filename); + //load audio and video should be methods of the nodes themselves? bool loaded; bool audio_loaded; std::string audio_filename; bool cancelled; double progress; - void set_log_name (std::string _Log_name){ - Log_name=_Log_name; - } + //void set_log_name (std::string _Log_name){ + //log name should be the same as the graph uid + //Log_name=_Log_name; + //} //Audio_thumbnailer *audio_thumb; private: - int analysis_seed; - std::string Log_name; + std::string uid; + std::string description; + std::unordered_map<std::string,Node*> nodes; }; } diff --git a/NT/src/nodes.h b/NT/src/nodes.h index 0f885da..21b1fc4 100644 --- a/NT/src/nodes.h +++ b/NT/src/nodes.h @@ -45,9 +45,13 @@ namespace Rotor{ }; const double &get_output(const Frame_parameters &frame){ result=1.0f; - for (auto val:factors->get_values()) { - std::cerr<<"got value: "<<val.get(frame)<<std::endl; - result*=val.get(frame); + //for (auto val:factors->get_values()) { + // result*=val.get(frame); + //} + //std::cerr<<"multiplying "<<factors->get_number()<<" factors"<<std::endl; + for (uint32_t i=0;i<factors->get_number();i++){ + //std::cerr<<"result from input "<<i<<": "<<factors->get(i,frame)<<std::endl; + result*=factors->get(i,frame); } return result; } diff --git a/NT/src/rotor.h b/NT/src/rotor.h index 96a89ef..68473af 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -126,9 +126,10 @@ namespace Rotor { for (auto node:nodes){ if (node.first==input){ if (connect(node.second)) { - std::cerr<<"connecting '"<<TypeName<T>::Get()<<"' input to '"<<input<<"'"<<std::endl; + if (connection) std::cerr<<"connected '"<<TypeName<T>::Get()<<"' input to '"<<(dynamic_cast<Node_type<T>*>(connection))->get_type()<<"' "<<input<<std::endl; + //else std::cerr<<"connection disappeared"<<std::endl; } - else std::cerr<<"could not connect '"<<TypeName<T>::Get()<<"'' input to '"<<input<<"'"<<std::endl; + //else std::cerr<<"could not connect '"<<TypeName<T>::Get()<<"'' input to '"<<input<<"'"<<std::endl; } } } @@ -147,9 +148,13 @@ namespace Rotor { return false; } const T& get(const Frame_parameters &frame){ + //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); } + //else std::cerr<<"variable: returning default"<<std::endl; return value; } protected: @@ -173,9 +178,10 @@ namespace Rotor { } } void create_connection(std::unordered_map<std::string,Node*> &nodes){ - for (auto v:values){ - v.create_connection(nodes); - } + //for (auto v:values){ //weirdly does not work even though it seems to! maybe it returns a copy of of the object? + // v.create_connection(nodes); + //} + for (uint32_t i=0;i<values.size();i++) values[i].create_connection(nodes); } Json::Value to_json(); std::string get_type(){ @@ -199,11 +205,14 @@ namespace Rotor { } const T& get(uint32_t which,const Frame_parameters &frame){ if (values.size()>which){ + //std::cerr<<"array: requested value "<<which<<":"<<values[which].get(frame)<<std::endl; return values[which].get(frame); } + //else std::cerr<<"array: returning default"<<std::endl; return value; } const std::vector<Variable_type<T>>& get_values(){return values;}; + uint32_t get_number(){return values.size();}; protected: std::vector<Variable_type<T>> values; T value; |
