summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-08-21 12:33:25 +0100
committerTim Redfern <tim@eclectronics.org>2013-08-21 12:33:25 +0100
commit393c70c5fc67fff87d189e77dffc5a22ed94a628 (patch)
tree059a3cdc54c87b698573fe69d22761025929933d
parentc53cf523b108845d074ea68d7fac592ec85e5a60 (diff)
waves finished
-rw-r--r--rotord/src/nodes_drawing.h33
-rw-r--r--rotord/src/nodes_maths.h2
-rwxr-xr-xrotord/src/rotor.h10
3 files changed, 26 insertions, 19 deletions
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h
index ad5bc8c..497fa25 100644
--- a/rotord/src/nodes_drawing.h
+++ b/rotord/src/nodes_drawing.h
@@ -151,9 +151,10 @@ namespace Rotor {
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_attribute("channel","Channel to draw","Channel","left",{"left","right"});
+ create_parameter("width","number","Line width","Width",1.0f,0.0f,25.0f);
create_parameter("scale","number","Scale","Scale",1.0f);
+ create_parameter("alpha","number","Alpha blend","Alpha",1.0f,0.0f,1.0f);
}
Waves(map<string,string> &settings):Waves() {
base_settings(settings);
@@ -163,28 +164,34 @@ namespace Rotor {
~Waves(){};
Waves* clone(map<string,string> &_settings) { return new Waves(_settings);};
void vector_audio_output(cairo_t * cr,const Frame_spec &frame){
+ int channel=attributes["channel"]->intVal-1;
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, 0);
- //cairo_line_to(cr, 0, frame.h/2);
+ cairo_set_source_rgba(cr, fill.Rfloat(),fill.Gfloat(),fill.Bfloat(),parameters["alpha"]->value);
+ cairo_save(cr);
+ cairo_translate(cr, 0, frame.h/2);
+ cairo_scale(cr,1.0f,parameters["scale"]->value);
+ cairo_line_to(cr, 0, 0);
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,i,(((int16_t)frame.audio->samples[i*frame.audio->channels]+channel)*frame.h)>>16);
}
cairo_line_to(cr, frame.w, 0);
+
cairo_close_path(cr);
- cairo_restore (cr); //not really even necessary?
+ cairo_restore (cr);
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, 0);
+ cairo_set_source_rgba(cr, stroke.Rfloat(),stroke.Gfloat(),stroke.Bfloat(),parameters["alpha"]->value);
+ cairo_save(cr);
+ cairo_translate(cr, 0, frame.h/2);
+ cairo_scale(cr,1.0f,parameters["scale"]->value);
+ cairo_set_line_width (cr, parameters["width"]->value);
+ cairo_line_to(cr, 0, 0);
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,i,(((int16_t)frame.audio->samples[i*frame.audio->channels+channel])*frame.h)>>16);
}
cairo_line_to(cr, frame.w, 0);
- cairo_restore (cr); //not really even necessary?
+ cairo_restore (cr);
cairo_stroke(cr);
}
}
diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h
index b1e20ca..617ca76 100644
--- a/rotord/src/nodes_maths.h
+++ b/rotord/src/nodes_maths.h
@@ -214,7 +214,7 @@ namespace Rotor {
create_signal_input("signal","Signal");
create_parameter("seed","number","Seed value","Seed",1.0f);
};
- Noise(map<string,string> &settings) {
+ Noise(map<string,string> &settings):Noise() {
base_settings(settings);
seed=find_setting(settings,"seed",0);
};
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 67445e9..069e908 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -883,7 +883,6 @@ namespace Rotor {
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);
@@ -946,13 +945,14 @@ namespace Rotor {
j++;
}
XML.popTag();
- }
}
void list_nodes(xmlIO XML){
int i=0;
- for (auto& type: type_map) { //c++11
- list_node(type,XML,i);
- i++;
+ for (auto& type: type_map) {
+ if (type.second->description!="") { //blank description = internal/ testing node
+ list_node(type,XML,i);
+ i++;
+ }
}
}
private: