diff options
| author | Comment <tim@gray.(none)> | 2013-08-20 23:50:56 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-08-20 23:50:56 +0100 |
| commit | 88a96ed5ba26296f9a9a19951ad453ebd0b1196e (patch) | |
| tree | 1880fe7b97bf3fd104bc0fe43c03aaab0381b261 /rotord | |
| parent | 95295030238e63890b6ea3113a2741b843e0b8c1 (diff) | |
listnode request in API
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/nodes_drawing.h | 46 | ||||
| -rwxr-xr-x | rotord/src/rotor.h | 138 | ||||
| -rwxr-xr-x | rotord/src/rotord.cpp | 7 |
3 files changed, 120 insertions, 71 deletions
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h index 3c26c9f..375ab03 100644 --- a/rotord/src/nodes_drawing.h +++ b/rotord/src/nodes_drawing.h @@ -137,28 +137,58 @@ namespace Rotor { private: bool audioactive; }; + #define WAVES_line 1; + #define WAVES_fill 2; + #define WAVES_both 3; + #define WAVES_mix 4; + #define WAVES_left 5; + #define WAVES_right 6; class Waves: public Audio_viz { public: Waves(){ title="Waves"; description="Draws audio waveforms"; + create_attribute("stroke","Colour of line stroke","Stroke","FFFFFF"); + create_attribute("fill","Colour of line fill","Fill","11AA11"); + create_attribute("mode","Drawing mode","Mode","line",{"line","fill","both"}); + create_attribute("channel","Channel to draw","Channel","left",{"mix","left","right"}); + create_parameter("width","number","Line width","Width",1.0f); + create_parameter("scale","number","Scale","Scale",1.0f); } Waves(map<string,string> &settings):Waves() { base_settings(settings); + stroke=Colour(attributes["stroke"]->value); + fill=Colour(attributes["fill"]->value); }; ~Waves(){}; Waves* clone(map<string,string> &_settings) { return new Waves(_settings);}; void vector_audio_output(cairo_t * cr,const Frame_spec &frame){ - cairo_set_source_rgb(cr, 1.0,1.0,1.0); - cairo_save(cr); //not really even necessary? - cairo_translate(cr, 0, frame.h/2); - for (int i=0;i<frame.w;i++){ - cairo_line_to(cr,i,(((int16_t)frame.audio->samples[i*frame.audio->channels])*frame.h)>>16); - } - cairo_restore (cr); //not really even necessary? - cairo_stroke(cr); + if (attributes["mode"]->value=="fill"||attributes["mode"]->value=="both") { + cairo_set_source_rgb(cr, fill.Rfloat(),fill.Gfloat(),fill.Bfloat()); + cairo_save(cr); //not really even necessary? + cairo_translate(cr, 0, frame.h/2); + for (int i=0;i<frame.w;i++){ + cairo_line_to(cr,i,(((int16_t)frame.audio->samples[i*frame.audio->channels])*frame.h)>>16); + } + cairo_line_to(cr, frame.w, frame.h/2); + cairo_close_path(cr); + cairo_restore (cr); //not really even necessary? + cairo_fill(cr); + } + if (attributes["mode"]->value=="line"||attributes["mode"]->value=="both") { + cairo_set_source_rgb(cr, stroke.Rfloat(),stroke.Gfloat(),stroke.Bfloat()); + cairo_save(cr); //not really even necessary? + cairo_translate(cr, 0, frame.h/2); + for (int i=0;i<frame.w;i++){ + cairo_line_to(cr,i,(((int16_t)frame.audio->samples[i*frame.audio->channels])*frame.h)>>16); + } + cairo_restore (cr); //not really even necessary? + cairo_stroke(cr); + } } private: + Colour stroke; + Colour fill; }; } diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 84a42e3..67445e9 100755 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -873,74 +873,86 @@ namespace Rotor { } return NULL; }; - void list_nodes(xmlIO XML){ - int i=0; - for (auto& type: type_map) { //c++11 - if (type.second->description!="") { //blank description = internal/ testing node - XML.addTag("node"); - XML.addAttribute("node","type",type.first,i); - XML.addAttribute("node","inputs",type.second->duplicate_inputs?"expandable":"fixed",i); - XML.addAttribute("node","title",type.second->title,i); - XML.addAttribute("node","description",type.second->description,i); - if (dynamic_cast<Signal_node*> (type.second)!=nullptr) XML.addAttribute("node","output","signal",i); - if (dynamic_cast<Image_node*> (type.second)!=nullptr) XML.addAttribute("node","output","image",i); - XML.pushTag("node",i); - //if (type.second->description!="") { - // XML.addTag("description"); - // XML.setValue("description",type.second->description,0); - //} - int j=0; - for (auto& input: type.second->inputs) { - XML.addTag("signal_input"); - XML.addAttribute("signal_input","title",input->title,j); - XML.addAttribute("signal_input","description",input->description,j); - j++; - } - j=0; - if (dynamic_cast<Image_node*> (type.second)!=nullptr) { - for (auto& input: (dynamic_cast<Image_node*>(type.second))->image_inputs) { - XML.addTag("image_input"); - XML.addAttribute("image_input","title",input->title,j); - XML.addAttribute("image_input","description",input->description,j); - j++; - } - } - j=0; - for (auto& parameter: type.second->parameters) { - XML.addTag("parameter"); - XML.addAttribute("parameter","name",parameter.first,j); - XML.addAttribute("parameter","type",parameter.second->type,j); - XML.addAttribute("parameter","title",parameter.second->title,j); - XML.addAttribute("parameter","description",parameter.second->description,j); - XML.addAttribute("parameter","value",parameter.second->value,j); - XML.addAttribute("parameter","min",parameter.second->min,j); - XML.addAttribute("parameter","max",parameter.second->max,j); + bool list_node(const string &t,xmlIO XML){ + for (auto& type: type_map) { + if (type.first==t) { + list_node(type,XML); + return true; + } + } + XML.addValue("error","Node /"+t+"/ not found"); + }; + void list_node(std::pair<const std::basic_string<char>, Rotor::Node*> &type,xmlIO XML,int i=0){ + if (type.second->description!="") { //blank description = internal/ testing node + XML.addTag("node"); + XML.addAttribute("node","type",type.first,i); + XML.addAttribute("node","inputs",type.second->duplicate_inputs?"expandable":"fixed",i); + XML.addAttribute("node","title",type.second->title,i); + XML.addAttribute("node","description",type.second->description,i); + if (dynamic_cast<Signal_node*> (type.second)!=nullptr) XML.addAttribute("node","output","signal",i); + if (dynamic_cast<Image_node*> (type.second)!=nullptr) XML.addAttribute("node","output","image",i); + XML.pushTag("node",i); + //if (type.second->description!="") { + // XML.addTag("description"); + // XML.setValue("description",type.second->description,0); + //} + int j=0; + for (auto& input: type.second->inputs) { + XML.addTag("signal_input"); + XML.addAttribute("signal_input","title",input->title,j); + XML.addAttribute("signal_input","description",input->description,j); + j++; + } + j=0; + if (dynamic_cast<Image_node*> (type.second)!=nullptr) { + for (auto& input: (dynamic_cast<Image_node*>(type.second))->image_inputs) { + XML.addTag("image_input"); + XML.addAttribute("image_input","title",input->title,j); + XML.addAttribute("image_input","description",input->description,j); j++; } - j=0; - for (auto& attribute: type.second->attributes) { - XML.addTag("attribute"); - XML.addAttribute("attribute","name",attribute.first,j); - XML.addAttribute("attribute","title",attribute.second->title,j); - XML.addAttribute("attribute","description",attribute.second->description,j); - XML.addAttribute("attribute","value",attribute.second->value,j); - if (attribute.second->vals.size()){ //document attribute enumeration - XML.addAttribute("attribute","type","enum",j); - XML.pushTag("attribute",j); - int k=0; - for (auto val: attribute.second->vals){ - XML.addTag("option"); - XML.addAttribute("option","value",val,k); - k++; - } - XML.popTag(); + } + j=0; + for (auto& parameter: type.second->parameters) { + XML.addTag("parameter"); + XML.addAttribute("parameter","name",parameter.first,j); + XML.addAttribute("parameter","type",parameter.second->type,j); + XML.addAttribute("parameter","title",parameter.second->title,j); + XML.addAttribute("parameter","description",parameter.second->description,j); + XML.addAttribute("parameter","value",parameter.second->value,j); + XML.addAttribute("parameter","min",parameter.second->min,j); + XML.addAttribute("parameter","max",parameter.second->max,j); + j++; + } + j=0; + for (auto& attribute: type.second->attributes) { + XML.addTag("attribute"); + XML.addAttribute("attribute","name",attribute.first,j); + XML.addAttribute("attribute","title",attribute.second->title,j); + XML.addAttribute("attribute","description",attribute.second->description,j); + XML.addAttribute("attribute","value",attribute.second->value,j); + if (attribute.second->vals.size()){ //document attribute enumeration + XML.addAttribute("attribute","type","enum",j); + XML.pushTag("attribute",j); + int k=0; + for (auto val: attribute.second->vals){ + XML.addTag("option"); + XML.addAttribute("option","value",val,k); + k++; } - else XML.addAttribute("attribute","type","string",j); - j++; + XML.popTag(); } - XML.popTag(); - i++; + else XML.addAttribute("attribute","type","string",j); + j++; } + XML.popTag(); + } + } + void list_nodes(xmlIO XML){ + int i=0; + for (auto& type: type_map) { //c++11 + list_node(type,XML,i); + i++; } } private: diff --git a/rotord/src/rotord.cpp b/rotord/src/rotord.cpp index 6130cfc..64d59cd 100755 --- a/rotord/src/rotord.cpp +++ b/rotord/src/rotord.cpp @@ -108,6 +108,13 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS status=HTTPResponse::HTTP_OK; } } + else if (command[0]=="listnode") { + XML.pushTag("rotor"); + if (request.getMethod()=="GET") { + Node_factory factory; + if (factory.list_node(body,XML)) status=HTTPResponse::HTTP_OK; + } + } else if (command[0]=="listrenders") { XML.pushTag("rotor"); if (request.getMethod()=="GET") { |
