From 393c70c5fc67fff87d189e77dffc5a22ed94a628 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 21 Aug 2013 12:33:25 +0100 Subject: waves finished --- rotord/src/nodes_drawing.h | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'rotord/src/nodes_drawing.h') 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 &settings):Waves() { base_settings(settings); @@ -163,28 +164,34 @@ namespace Rotor { ~Waves(){}; Waves* clone(map &_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;isamples[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;isamples[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); } } -- cgit v1.2.3