summaryrefslogtreecommitdiff
path: root/rotord/src/nodes_drawing.h
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-08-20 23:50:56 +0100
committerComment <tim@gray.(none)>2013-08-20 23:50:56 +0100
commit88a96ed5ba26296f9a9a19951ad453ebd0b1196e (patch)
tree1880fe7b97bf3fd104bc0fe43c03aaab0381b261 /rotord/src/nodes_drawing.h
parent95295030238e63890b6ea3113a2741b843e0b8c1 (diff)
listnode request in API
Diffstat (limited to 'rotord/src/nodes_drawing.h')
-rw-r--r--rotord/src/nodes_drawing.h46
1 files changed, 38 insertions, 8 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;
};
}