@@ -16,8 +16,6 @@ plugins: libs | |||
$(MAKE) all -C plugins/Meters | |||
$(MAKE) all -C plugins/Parameters | |||
$(MAKE) all -C plugins/States | |||
#$(MAKE) all -C plugins/openav-ducka | |||
#$(MAKE) all -C plugins/openav-roomy | |||
gen: plugins dpf/utils/lv2_ttl_generator | |||
@$(CURDIR)/dpf/utils/generate-ttl.sh | |||
@@ -37,8 +35,6 @@ clean: | |||
$(MAKE) clean -C plugins/Meters | |||
$(MAKE) clean -C plugins/Parameters | |||
$(MAKE) clean -C plugins/States | |||
#$(MAKE) clean -C plugins/openav-ducka | |||
#$(MAKE) clean -C plugins/openav-roomy | |||
# -------------------------------------------------------------- | |||
@@ -1,7 +0,0 @@ | |||
AVTK : | |||
These files are AVTK widgets. | |||
They're included in this repo for convinience. | |||
Details on www.openavproductions.com/avtk |
@@ -1,349 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_DELAY_GRAPH_H | |||
#define AVTK_DELAY_GRAPH_H | |||
#include <FL/Fl_Widget.H> | |||
#include <FL/Fl_Slider.H> | |||
#include <FL/Fl_Menu_Item.H> | |||
#include <valarray> | |||
#include <string> | |||
namespace Avtk | |||
{ | |||
class Delaygraph : public Fl_Slider | |||
{ | |||
public: | |||
Delaygraph(int _x, int _y, int _w, int _h, const char *_label = 0): | |||
Fl_Slider(_x, _y, _w, _h, _label) | |||
{ | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
label = _label; | |||
mouseClickedX = 0; | |||
mouseClickedY = 0; | |||
mouseClicked = false; | |||
active = true; | |||
highlight = false; | |||
volume = 0.5; | |||
waveshapeType = 0.f; | |||
feedback = 0.0; | |||
} | |||
/// holds the preset: used from callback() to write value | |||
float waveshapeType; | |||
void type(float t) {waveshapeType = t; redraw();} | |||
bool active; | |||
bool highlight; | |||
int x, y, w, h; | |||
const char* label; | |||
int mouseClickedX; | |||
int mouseClickedY; | |||
bool mouseClicked; | |||
bool mouseRightClicked; | |||
float feedback; | |||
float volume; | |||
void setFeedback(float f) | |||
{ | |||
feedback = f; | |||
redraw(); | |||
} | |||
void setVolume(float e) | |||
{ | |||
volume = e; | |||
redraw(); | |||
} | |||
float getVolume() | |||
{ | |||
return volume; | |||
} | |||
void setActive(bool a) | |||
{ | |||
active = a; | |||
redraw(); | |||
} | |||
bool getActive() | |||
{ | |||
return active; | |||
} | |||
void draw() | |||
{ | |||
if (damage() & FL_DAMAGE_ALL) | |||
{ | |||
cairo_t *cr = Fl::cairo_cc(); | |||
cairo_save( cr ); | |||
cairo_set_line_width(cr, 1.5); | |||
// fill background | |||
cairo_rectangle( cr, x, y, w, h); | |||
cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f ); | |||
cairo_fill_preserve( cr ); | |||
cairo_clip( cr ); | |||
// set up dashed lines, 1 px off, 1 px on | |||
double dashes[1]; | |||
dashes[0] = 2.0; | |||
cairo_set_dash ( cr, dashes, 1, 0.0); | |||
cairo_set_line_width( cr, 1.0); | |||
// loop over each 2nd line, drawing dots | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_set_source_rgb(cr, 0.4,0.4,0.4); | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x + ((w / 4.f)*i), y ); | |||
cairo_line_to( cr, x + ((w / 4.f)*i), y + h ); | |||
} | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x , y + ((h / 4.f)*i) ); | |||
cairo_line_to( cr, x + w, y + ((h / 4.f)*i) ); | |||
} | |||
cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 ); | |||
cairo_stroke(cr); | |||
cairo_set_dash ( cr, dashes, 0, 0.0); | |||
// curved waveshape | |||
/* | |||
float distort = value(); | |||
cairo_move_to( cr, x , y + h ); | |||
cairo_curve_to( cr, x + w * distort, y+h, // control point 1 | |||
x + w - (w * distort), y, // control point 2 | |||
x + w, y ); // end of curve 1, start curve 2 | |||
cairo_line_to ( cr, x + w, y + h ); | |||
cairo_close_path(cr); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve(cr); | |||
cairo_set_line_width(cr, 2.0); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_stroke(cr); | |||
*/ | |||
float delay = 0; | |||
int delTimeQuantized = int(value() * 3.99f); | |||
switch( delTimeQuantized ) | |||
{ | |||
case 0: | |||
delay = 0.125; | |||
break; | |||
case 1: | |||
delay = 0.25; | |||
break; | |||
case 2: | |||
delay = 0.5; | |||
break; | |||
case 3: | |||
delay = 1; | |||
break; | |||
} | |||
// Actual audio bar | |||
cairo_move_to( cr, x + w/4, y + h - 2 ); | |||
cairo_line_to( cr, x + w/4, y + h - h * 0.75 ); | |||
cairo_set_line_width(cr, 18); | |||
cairo_set_line_cap( cr, CAIRO_LINE_CAP_ROUND ); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
//cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_stroke(cr); | |||
// feedback pointer | |||
cairo_move_to( cr, x + w/4 + w/2*delay, y + h * 3.5 / 4 ); | |||
cairo_line_to( cr, x + w*3.5/4 , y + h * 3.5 / 4 ); | |||
cairo_line_to( cr, x + w*3.5/4 , y + h * 1.0 / 4 ); | |||
cairo_line_to( cr, x + w*3.5/4 - ((w/2.)*feedback), y + h * 1.0 / 4 ); | |||
cairo_set_source_rgba( cr, 255 / 255.f, 0 / 255.f , 0 / 255.f , 1 ); | |||
cairo_set_line_width(cr, 1.5); | |||
cairo_stroke( cr ); | |||
cairo_line_to( cr, x + w*3.5/4 - ((w/2)*feedback)-10, y + h * 1.0 / 4 ); | |||
cairo_line_to( cr, x + w*3.5/4 - ((w/2)*feedback)-2 , (y + h * 1.0 / 4)+8 ); | |||
cairo_line_to( cr, x + w*3.5/4 - ((w/2)*feedback)-2 , (y + h * 1.0 / 4)-8 ); | |||
cairo_close_path( cr ); | |||
cairo_fill( cr ); | |||
// changing delay bar | |||
cairo_move_to( cr, x + w/4 + w/2*delay, y + h - 2 ); | |||
cairo_line_to( cr, x + w/4 + w/2*delay, y + h*7/8 - (h*1.5/3.0 * volume) ); | |||
cairo_set_line_cap( cr, CAIRO_LINE_CAP_ROUND ); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve(cr); | |||
cairo_set_line_width(cr, 18); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_stroke(cr); | |||
// stroke outline | |||
cairo_rectangle(cr, x+1, y+1, w-2, h-2); | |||
cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 ); | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_stroke( cr ); | |||
if ( !active ) | |||
{ | |||
// big grey X | |||
cairo_set_line_width(cr, 20.0); | |||
cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7); | |||
cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT); | |||
cairo_stroke( cr ); | |||
} | |||
cairo_restore( cr ); | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Widget::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
switch(event) | |||
{ | |||
case FL_PUSH: | |||
highlight = 0; | |||
mouseRightClicked = false; | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
if ( Fl::event_button() == FL_RIGHT_MOUSE ) | |||
{ | |||
active = !active; | |||
redraw(); | |||
mouseRightClicked = true; | |||
do_callback(); | |||
} | |||
return 1; | |||
case FL_DRAG: | |||
{ | |||
if ( Fl::event_state(FL_BUTTON1) ) | |||
{ | |||
if ( mouseClicked == false ) // catch the "click" event | |||
{ | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
mouseClicked = true; | |||
} | |||
float deltaX = mouseClickedX - Fl::event_x(); | |||
float deltaY = mouseClickedY - Fl::event_y(); | |||
float valX = value() ; | |||
valX -= deltaX / 100.f; | |||
float valY = volume; | |||
valY += deltaY / 100.f; | |||
if ( valX > 1.0 ) valX = 1.0; | |||
if ( valX < 0.0 ) valX = 0.0; | |||
if ( valY > 1.0 ) valY = 1.0; | |||
if ( valY < 0.0 ) valY = 0.0; | |||
//handle_drag( value + deltaY ); | |||
set_value( valX ); | |||
volume = valY; | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
redraw(); | |||
do_callback(); | |||
} | |||
} | |||
return 1; | |||
case FL_RELEASE: | |||
mouseRightClicked = false; | |||
if (highlight) { | |||
highlight = 0; | |||
redraw(); | |||
do_callback(); | |||
} | |||
mouseClicked = false; | |||
return 1; | |||
case FL_SHORTCUT: | |||
if ( test_shortcut() ) | |||
{ | |||
do_callback(); | |||
return 1; | |||
} | |||
return 0; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
return 0; | |||
} | |||
private: | |||
}; | |||
} // Avtk | |||
#endif // AVTK_DELAY_GRAPH_H |
@@ -1,183 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_DIAL_H | |||
#define AVTK_DIAL_H | |||
#include <FL/Fl_Dial.H> | |||
#include <FL/Fl_Slider.H> | |||
namespace Avtk | |||
{ | |||
class Dial : public Fl_Slider | |||
{ | |||
public: | |||
Dial(int _x, int _y, int _w, int _h, const char* _label=0): | |||
Fl_Slider(_x, _y, _w, _h, _label) | |||
{ | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
// * 0.9 for line width to remain inside redraw area | |||
if ( w > h ) | |||
radius = (h / 2.f)*0.9; | |||
else | |||
radius = (w / 2.f)*0.9; | |||
lineWidth = 1.4 + radius / 12.f; | |||
mouseClickedY = 0; | |||
mouseClicked = false; | |||
highlight = false; | |||
label = _label; | |||
} | |||
bool highlight; | |||
int x, y, w, h; | |||
const char* label; | |||
bool drawLab; | |||
void drawLabel(bool b){drawLab = b; redraw();} | |||
float radius; | |||
float lineWidth; | |||
int mouseClickedY; | |||
bool mouseClicked; | |||
void draw() | |||
{ | |||
if (damage() & FL_DAMAGE_ALL) | |||
{ | |||
cairo_t *cr = Fl::cairo_cc(); | |||
cairo_save( cr ); | |||
// label behind value | |||
draw_label(); | |||
cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); | |||
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); | |||
cairo_set_line_width(cr, lineWidth-0.2); | |||
cairo_move_to( cr, x+w/2,y+h/2); | |||
cairo_line_to( cr, x+w/2,y+h/2); | |||
cairo_set_source_rgba(cr, 0.5, 0.5, 0.5, 0.4 ); | |||
// draw dash guide | |||
double dashes[2]; | |||
cairo_set_line_width(cr, 1.7); | |||
dashes[0] = 3.0; | |||
dashes[1] = 3.0; | |||
cairo_set_dash ( cr, dashes, 2, 0.0); | |||
cairo_stroke(cr); | |||
cairo_arc(cr, x+w/2,y+h/2, radius, 2.46, 0.75 ); | |||
//cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.4 ); | |||
cairo_stroke(cr); | |||
cairo_set_dash ( cr, dashes, 0, 0.0); | |||
float angle = 2.46 + ( 4.54 * value() ); | |||
cairo_set_line_width(cr, lineWidth); | |||
cairo_arc(cr, x+w/2,y+h/2, radius, 2.46, angle ); | |||
cairo_line_to(cr, x+w/2,y+h/2); | |||
cairo_set_source_rgba(cr, 1.0, 0.48, 0, 1.0); | |||
cairo_stroke(cr); | |||
cairo_restore( cr ); | |||
if ( drawLab ) | |||
{ | |||
//draw_label(); | |||
} | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Slider::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
//cout << "handle event type = " << event << " value = " << value() << endl; | |||
//Fl_Slider::handle( event ); | |||
switch(event) { | |||
case FL_PUSH: | |||
highlight = 1; | |||
redraw(); | |||
return 1; | |||
case FL_DRAG: | |||
{ | |||
if ( Fl::event_state(FL_BUTTON1) ) | |||
{ | |||
if ( mouseClicked == false ) // catch the "click" event | |||
{ | |||
mouseClickedY = Fl::event_y(); | |||
mouseClicked = true; | |||
} | |||
float deltaY = mouseClickedY - Fl::event_y(); | |||
float val = value(); | |||
val += deltaY / 100.f; | |||
if ( val > 1.0 ) val = 1.0; | |||
if ( val < 0.0 ) val = 0.0; | |||
set_value( val ); | |||
mouseClickedY = Fl::event_y(); | |||
redraw(); | |||
do_callback(); // makes FLTK call "extra" code entered in FLUID | |||
} | |||
} | |||
return 1; | |||
case FL_RELEASE: | |||
if (highlight) { | |||
highlight = 0; | |||
redraw(); | |||
// never do anything after a callback, as the callback | |||
// may delete the widget! | |||
} | |||
mouseClicked = false; | |||
return 1; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
} | |||
}; | |||
} // Avtk | |||
#endif // AVTK_DIAL_H |
@@ -1,356 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_FILTERGRAPH_H | |||
#define AVTK_FILTERGRAPH_H | |||
#include <FL/Fl_Widget.H> | |||
#include <FL/Fl_Slider.H> | |||
#include <valarray> | |||
#include <string> | |||
namespace Avtk | |||
{ | |||
class Filtergraph : public Fl_Slider | |||
{ | |||
public: | |||
enum Type { | |||
FILTER_LOWPASS = 0, | |||
FILTER_HIGHPASS, | |||
FILTER_FLAT, | |||
}; | |||
Filtergraph(int _x, int _y, int _w, int _h, const char *_label = 0, Type _type = FILTER_LOWPASS): | |||
Fl_Slider(_x, _y, _w, _h, _label) | |||
{ | |||
graphType = _type; | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
label = _label; | |||
mouseClickedX = 0; | |||
mouseClickedY = 0; | |||
mouseClicked = false; | |||
active = true; | |||
highlight = false; | |||
value( 0.5 ); | |||
freq = value(); | |||
gain = 0; | |||
bandwidth = 0; | |||
} | |||
void setGain(float g) {gain = g; redraw();} | |||
void setBandwidth(float b) {bandwidth = b; redraw();} | |||
float getGain() {return gain;} | |||
float getBandwidth() {return bandwidth;} | |||
void setType(Type t) | |||
{ | |||
graphType = t; | |||
redraw(); | |||
} | |||
void setActive(bool a) | |||
{ | |||
active = a; | |||
redraw(); | |||
} | |||
bool getActive() | |||
{ | |||
return active; | |||
} | |||
Type graphType; | |||
bool active; | |||
bool highlight; | |||
int x, y, w, h; | |||
const char* label; | |||
int mouseClickedX; | |||
int mouseClickedY; | |||
bool mouseClicked; | |||
float freq; | |||
float gain; | |||
float bandwidth; | |||
void draw() | |||
{ | |||
if (damage() & FL_DAMAGE_ALL) | |||
{ | |||
cairo_t *cr = Fl::cairo_cc(); | |||
cairo_save( cr ); | |||
cairo_set_line_width(cr, 1.5); | |||
// fill background | |||
cairo_rectangle( cr, x, y, w, h); | |||
cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f ); | |||
cairo_fill( cr ); | |||
// set up dashed lines, 1 px off, 1 px on | |||
double dashes[1]; | |||
dashes[0] = 2.0; | |||
cairo_set_dash ( cr, dashes, 1, 0.0); | |||
cairo_set_line_width( cr, 1.0); | |||
// loop over each 2nd line, drawing dots | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_set_source_rgb(cr, 0.4,0.4,0.4); | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x + ((w / 4.f)*i), y ); | |||
cairo_line_to( cr, x + ((w / 4.f)*i), y + h ); | |||
} | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x , y + ((h / 4.f)*i) ); | |||
cairo_line_to( cr, x + w, y + ((h / 4.f)*i) ); | |||
} | |||
cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 ); | |||
cairo_stroke(cr); | |||
cairo_set_dash ( cr, dashes, 0, 0.0); | |||
// change filter type (low|high) based on value: | |||
// 0 to < 0.5 = lowpass | |||
// 0.5 == no change | |||
// 0.5 < 1.0 == highpass | |||
if ( value() < 0.45 ) | |||
{ | |||
graphType = FILTER_LOWPASS; | |||
freq = value()*2.f; | |||
} | |||
else if ( value() > 0.55 ) | |||
{ | |||
graphType = FILTER_HIGHPASS; | |||
freq = (value()-0.5)*2.f; | |||
} | |||
else | |||
{ | |||
graphType = FILTER_FLAT; | |||
} | |||
switch( graphType ) | |||
{ | |||
case FILTER_LOWPASS : drawLowpass(cr); break; | |||
case FILTER_HIGHPASS: drawHighpass(cr); break; | |||
case FILTER_FLAT : drawFlat(cr); break; | |||
default: | |||
cout << "Filtergraph: unknown filter type selected!" << endl; | |||
} | |||
// stroke outline | |||
cairo_rectangle(cr, x, y, w, h); | |||
cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 ); | |||
cairo_set_line_width(cr, 1.9); | |||
cairo_stroke( cr ); | |||
if ( !active ) | |||
{ | |||
// big grey X | |||
cairo_set_line_width(cr, 20.0); | |||
cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7); | |||
cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT); | |||
cairo_stroke( cr ); | |||
} | |||
cairo_restore( cr ); | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Widget::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
switch(event) | |||
{ | |||
case FL_PUSH: | |||
highlight = 0; | |||
if ( Fl::event_button() == FL_RIGHT_MOUSE ) | |||
{ | |||
active = !active; | |||
redraw(); | |||
do_callback(); | |||
} | |||
redraw(); | |||
return 1; | |||
case FL_DRAG: | |||
{ | |||
if ( Fl::event_state(FL_BUTTON1) ) | |||
{ | |||
if ( mouseClicked == false ) // catch the "click" event | |||
{ | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
mouseClicked = true; | |||
} | |||
float deltaX = mouseClickedX - Fl::event_x(); | |||
float deltaY = mouseClickedY - Fl::event_y(); | |||
float valX = value(); | |||
valX -= deltaX / 100.f; | |||
float valY = gain; | |||
valY += deltaY / 100.f; | |||
if ( valX > 1.0 ) valX = 1.0; | |||
if ( valX < 0.0 ) valX = 0.0; | |||
if ( valY > 1.0 ) valY = 1.0; | |||
if ( valY < 0.0 ) valY = 0.0; | |||
//handle_drag( value + deltaY ); | |||
set_value( valX ); | |||
gain = valY; | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
redraw(); | |||
do_callback(); | |||
} | |||
} | |||
return 1; | |||
case FL_RELEASE: | |||
if (highlight) { | |||
highlight = 0; | |||
redraw(); | |||
do_callback(); | |||
} | |||
mouseClicked = false; | |||
return 1; | |||
case FL_SHORTCUT: | |||
if ( test_shortcut() ) | |||
{ | |||
do_callback(); | |||
return 1; | |||
} | |||
return 0; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
} | |||
private: | |||
void drawLowpass(cairo_t* cr) | |||
{ | |||
// draw the cutoff line: | |||
// move to bottom left, draw line to middle left | |||
cairo_move_to( cr, x , y + h ); | |||
cairo_line_to( cr, x , y + (h*0.47)); | |||
float cutoff = 0.1 + freq * 0.85; | |||
// Curve | |||
cairo_curve_to( cr, x + w * cutoff , y+(h*0.5) , // control point 1 | |||
x + w * cutoff , y+(h * 0.3), // control point 2 | |||
x + w * cutoff + 5, y+ h ); // end of curve 1 | |||
cairo_close_path(cr); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve(cr); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_set_line_width(cr, 1.5); | |||
cairo_set_line_join( cr, CAIRO_LINE_JOIN_ROUND); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND); | |||
cairo_stroke( cr ); | |||
} | |||
void drawHighpass(cairo_t* cr) | |||
{ | |||
// draw the cutoff line: | |||
float cutoff = 0.95 - (freq*0.8); | |||
// move to bottom right | |||
cairo_move_to( cr, x + w, y + h ); | |||
cairo_line_to( cr, x + w, y + (h*0.47)); | |||
// Curve | |||
cairo_curve_to( cr, x + w - (w*cutoff) , y+(h*0.5) , // control point 1 | |||
x + w - (w*cutoff) , y+(h * 0.3), // control point 2 | |||
x + w - (w*cutoff) - 5, y+ h ); // end of curve 1 | |||
cairo_close_path(cr); | |||
// stroke | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve(cr); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_set_line_width(cr, 1.5); | |||
cairo_set_line_join( cr, CAIRO_LINE_JOIN_ROUND); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND); | |||
cairo_stroke( cr ); | |||
} | |||
void drawFlat(cairo_t* cr) | |||
{ | |||
// move to bottom right | |||
cairo_move_to( cr, x + w, y + h ); | |||
cairo_line_to( cr, x + w, y + (h*0.47)); | |||
cairo_line_to( cr, x , y + (h*0.47)); | |||
cairo_line_to( cr, x , y + h ); | |||
cairo_close_path(cr); | |||
// stroke | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve(cr); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_set_line_width(cr, 1.5); | |||
cairo_set_line_join( cr, CAIRO_LINE_JOIN_ROUND); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND); | |||
cairo_stroke( cr ); | |||
} | |||
}; | |||
} // Avtk | |||
#endif // AVTK_FILTERGRAPH_H |
@@ -1,113 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_IMAGE_H | |||
#define AVTK_IMAGE_H | |||
#include <FL/Fl_Widget.H> | |||
#include <vector> | |||
#include <string> | |||
#include <iostream> | |||
#include <stdio.h> | |||
#include <FL/fl_draw.H> | |||
using namespace std; | |||
namespace Avtk | |||
{ | |||
class Image : public Fl_Widget | |||
{ | |||
public: | |||
Image(int _x, int _y, int _w, int _h, const char *_label=0 ): | |||
Fl_Widget(_x, _y, _w, _h, _label) | |||
{ | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
label = _label; | |||
bits = -1; | |||
imageDataPtr = 0; | |||
} | |||
void setPixbuf(const unsigned char* data, int b ) | |||
{ | |||
bits = b; | |||
imageDataPtr = data; | |||
} | |||
int x, y, w, h; | |||
const char* label; | |||
int bits; | |||
const unsigned char* imageDataPtr; | |||
void draw() | |||
{ | |||
if ( damage() & FL_DAMAGE_ALL && imageDataPtr != 0 ) | |||
{ | |||
fl_draw_image((const uchar*)imageDataPtr, x, y, w, h, bits, w*bits); | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Widget::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
switch(event) | |||
{ | |||
case FL_PUSH: | |||
do_callback(); | |||
return 1; | |||
case FL_DRAG: | |||
return 1; | |||
case FL_RELEASE: | |||
return 1; | |||
case FL_SHORTCUT: | |||
if ( test_shortcut() ) | |||
{ | |||
do_callback(); | |||
return 1; | |||
} | |||
return 0; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
} | |||
}; | |||
} // Avtk | |||
#endif | |||
@@ -1,253 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_MASHER_H | |||
#define AVTK_MASHER_H | |||
#include <FL/Fl_Slider.H> | |||
namespace Avtk | |||
{ | |||
class Masher : public Fl_Slider | |||
{ | |||
public: | |||
Masher(int _x, int _y, int _w, int _h, const char *_label =0): | |||
Fl_Slider(_x, _y, _w, _h, _label) | |||
{ | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
_duration = 0.5; | |||
_volume = 1.0; | |||
_replace = 1.0; | |||
active = true; | |||
label = _label; | |||
highlight = false; | |||
mouseOver = false; | |||
} | |||
void volume(float v){ _volume = v; redraw(); } | |||
void replace(float r){ _replace = r; redraw(); } | |||
void duration(float d){ _duration = d; redraw(); } | |||
bool getActive(){return active;} | |||
void setActive(bool a){active = a; redraw();} | |||
float _volume; | |||
float _duration; | |||
float _replace; | |||
bool active; | |||
bool mouseOver; | |||
bool highlight; | |||
int x, y, w, h; | |||
const char* label; | |||
void draw() | |||
{ | |||
if (damage() & FL_DAMAGE_ALL) | |||
{ | |||
cairo_t *cr = Fl::cairo_cc(); | |||
cairo_save( cr ); | |||
// graph | |||
cairo_rectangle( cr, x, y, w, h ); | |||
cairo_set_source_rgb( cr,28 / 255.f, 28 / 255.f , 28 / 255.f ); | |||
cairo_fill(cr); | |||
// set up dashed lines, 1 px off, 1 px on | |||
double dashes[1]; | |||
dashes[0] = 2.0; | |||
cairo_set_dash ( cr, dashes, 1, 0.0); | |||
// loop over each 2nd line, drawing dots | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_set_source_rgb(cr, 0.4,0.4,0.4); | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x + ((w / 4.f)*i), y ); | |||
cairo_line_to( cr, x + ((w / 4.f)*i), y + h ); | |||
} | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x , y + ((h / 4.f)*i) ); | |||
cairo_line_to( cr, x + w, y + ((h / 4.f)*i) ); | |||
} | |||
cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 ); | |||
cairo_stroke(cr); | |||
cairo_set_dash ( cr, dashes, 0, 0.0); | |||
// check that its a new "segment" to redraw | |||
int newAngle = ( _duration * 4.9f); | |||
int xc = (w) / 2.f; | |||
int yc = (h) / 2.f; | |||
float angle = 0.f; | |||
if ( newAngle == 0 ) | |||
angle = 0.06; | |||
else if ( newAngle == 1 ) | |||
angle = 0.125; | |||
else if ( newAngle <= 2 ) | |||
angle = 0.25; | |||
else if ( newAngle <= 3 ) | |||
angle = 0.5; | |||
else | |||
angle = 1; | |||
// replace: middle arc | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND ); | |||
cairo_arc( cr, x + xc, y + yc, xc * 6.5 / 14, -(3.1415/2), _replace * 6.28 - (3.1415/2) ); | |||
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8 ); | |||
cairo_set_line_width(cr, 9); | |||
cairo_stroke(cr); | |||
if ( newAngle == 0 ) | |||
cairo_set_source_rgba (cr, 1.0, 0.0 , 0.0, 1 ); | |||
else if ( newAngle == 1 ) | |||
cairo_set_source_rgba (cr, 1.0, 0.48, 0.0, 1 ); | |||
else if ( newAngle <= 2 ) | |||
cairo_set_source_rgba (cr, 0.0, 1.0 , 0.0, 0.8 ); | |||
else if ( newAngle <= 3 ) | |||
cairo_set_source_rgba (cr, 0.0, 0.48, 1.0, 1 ); | |||
else | |||
cairo_set_source_rgba (cr, 1.0, 0.0, 1.0, 0.7 ); | |||
// duration : outside arc | |||
cairo_arc( cr, x + xc, y + yc, xc * 9.5 / 14, -(3.1415/2), angle * 6.28 - (3.1415/2) ); | |||
cairo_set_line_width(cr, 11); | |||
cairo_stroke(cr); | |||
// volume: inside circle | |||
cairo_set_source_rgba(cr,0.3,0.3,0.3, 0.5); | |||
cairo_arc(cr, x + xc, y + yc, 25 * _volume, 0, 2 * 3.1415); | |||
cairo_set_line_width(cr, 4.2); | |||
cairo_fill_preserve(cr); | |||
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8 ); | |||
cairo_set_line_width(cr, 2); | |||
cairo_stroke(cr); | |||
// stroke rim | |||
cairo_rectangle(cr, x, y, w, h); | |||
//cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 ); | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_stroke( cr ); | |||
if ( !active ) | |||
{ | |||
// big grey X | |||
cairo_set_line_width(cr, 20.0); | |||
cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7); | |||
cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT); | |||
cairo_stroke( cr ); | |||
} | |||
cairo_restore( cr ); | |||
draw_label(); | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Widget::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
switch(event) { | |||
case FL_PUSH: | |||
highlight = 1; | |||
if ( Fl::event_button() == FL_RIGHT_MOUSE ) | |||
{ | |||
active = !active; | |||
redraw(); | |||
do_callback(); | |||
} | |||
return 1; | |||
case FL_DRAG: { | |||
int t = Fl::event_inside(this); | |||
if (t != highlight) { | |||
highlight = t; | |||
redraw(); | |||
} | |||
} | |||
return 1; | |||
case FL_ENTER: | |||
mouseOver = true; | |||
redraw(); | |||
return 1; | |||
case FL_LEAVE: | |||
mouseOver = false; | |||
redraw(); | |||
return 1; | |||
case FL_RELEASE: | |||
if (highlight) { | |||
highlight = 0; | |||
redraw(); | |||
} | |||
return 1; | |||
case FL_SHORTCUT: | |||
if ( test_shortcut() ) | |||
{ | |||
do_callback(); | |||
return 1; | |||
} | |||
return 0; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
} | |||
}; | |||
} // Avtk | |||
#endif // AVTK_ADSR_H | |||
@@ -1,284 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2014 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_PARAMETERIC_H | |||
#define AVTK_PARAMETERIC_H | |||
#include <FL/Fl_Widget.H> | |||
#include <FL/Fl_Slider.H> | |||
#include <FL/Fl_Menu_Item.H> | |||
#include <valarray> | |||
#include <string> | |||
namespace Avtk | |||
{ | |||
class Parameteric : public Fl_Slider | |||
{ | |||
public: | |||
Parameteric(int _x, int _y, int _w, int _h, const char *_label = 0): | |||
Fl_Slider(_x, _y, _w, _h, _label) | |||
{ | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
label = _label; | |||
mouseClickedX = 0; | |||
mouseClickedY = 0; | |||
mouseClicked = false; | |||
active = true; | |||
highlight = false; | |||
gains[0] = 0.f; | |||
gains[1] = 0.f; | |||
gains[2] = 0.f; | |||
gains[3] = 0.f; | |||
gains[4] = 0.f; | |||
} | |||
bool active; | |||
bool highlight; | |||
int x, y, w, h; | |||
const char* label; | |||
int mouseClickedX; | |||
int mouseClickedY; | |||
bool mouseClicked; | |||
bool mouseRightClicked; | |||
float gains[5]; | |||
void setGain( int s, float g) | |||
{ | |||
gains[s] = g; | |||
redraw(); | |||
} | |||
float getVolume() | |||
{ | |||
return gains[0]; | |||
} | |||
void setActive(bool a) | |||
{ | |||
active = a; | |||
redraw(); | |||
} | |||
bool getActive() | |||
{ | |||
return active; | |||
} | |||
void draw() | |||
{ | |||
if (damage() & FL_DAMAGE_ALL) | |||
{ | |||
cairo_t *cr = Fl::cairo_cc(); | |||
cairo_save( cr ); | |||
cairo_set_line_width(cr, 1.5); | |||
// fill background | |||
cairo_rectangle( cr, x, y, w, h); | |||
cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f ); | |||
cairo_fill_preserve( cr ); | |||
cairo_clip( cr ); | |||
// set up dashed lines, 1 px off, 1 px on | |||
double dashes[1]; | |||
dashes[0] = 2.0; | |||
cairo_set_dash ( cr, dashes, 1, 0.0); | |||
cairo_set_line_width( cr, 1.0); | |||
// loop over each 2nd line, drawing dots | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_set_source_rgb(cr, 0.4,0.4,0.4); | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x + ((w / 4.f)*i), y ); | |||
cairo_line_to( cr, x + ((w / 4.f)*i), y + h ); | |||
} | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x , y + ((h / 4.f)*i) ); | |||
cairo_line_to( cr, x + w, y + ((h / 4.f)*i) ); | |||
} | |||
cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 ); | |||
cairo_stroke(cr); | |||
cairo_set_dash ( cr, dashes, 0, 0.0); | |||
// draw frequency/amplitude rectangles | |||
for(int i = 0; i < 4; i ++) | |||
{ | |||
int startY = y + h/2; | |||
int heightY = h/4 * ( ( (1-gains[i+1])*2)-1 ); | |||
cairo_rectangle( cr, x + (w/4)*i, startY, w/4, heightY ); | |||
} | |||
cairo_set_line_cap( cr, CAIRO_LINE_CAP_ROUND ); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve(cr); | |||
cairo_set_line_width(cr, 1.8); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_stroke(cr); | |||
// draw "master gain line | |||
cairo_move_to( cr, x , y + h/2 + (h/4 *-(gains[0]*2-1)) ); | |||
cairo_line_to( cr, x+w, y + h/2 + (h/4 *-(gains[0]*2-1)) ); | |||
cairo_set_line_width(cr, 2.1); | |||
cairo_set_source_rgba( cr, 255 / 255.f, 0 / 255.f , 0 / 255.f , 1 ); | |||
cairo_stroke(cr); | |||
// stroke outline | |||
cairo_rectangle(cr, x+1, y+1, w-2, h-2); | |||
cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 ); | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_stroke( cr ); | |||
if ( !active ) | |||
{ | |||
// big grey X | |||
cairo_set_line_width(cr, 20.0); | |||
cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7); | |||
cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT); | |||
cairo_stroke( cr ); | |||
} | |||
cairo_restore( cr ); | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Widget::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
switch(event) | |||
{ | |||
case FL_PUSH: | |||
highlight = 0; | |||
mouseRightClicked = false; | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
if ( Fl::event_button() == FL_RIGHT_MOUSE ) | |||
{ | |||
active = !active; | |||
redraw(); | |||
mouseRightClicked = true; | |||
do_callback(); | |||
} | |||
return 1; | |||
case FL_DRAG: | |||
{ | |||
if ( Fl::event_state(FL_BUTTON1) ) | |||
{ | |||
if ( mouseClicked == false ) // catch the "click" event | |||
{ | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
mouseClicked = true; | |||
} | |||
//float deltaX = mouseClickedX - Fl::event_x(); | |||
float deltaY = mouseClickedY - Fl::event_y(); | |||
//float valX = value() ; | |||
//valX -= deltaX / 100.f; | |||
float valY = gains[0]; | |||
valY += deltaY / 100.f; | |||
//if ( valX > 1.0 ) valX = 1.0; | |||
//if ( valX < 0.0 ) valX = 0.0; | |||
if ( valY > 1.0 ) valY = 1.0; | |||
if ( valY < 0.0 ) valY = 0.0; | |||
//handle_drag( value + deltaY ); | |||
//set_value( valX ); | |||
gains[0] = valY; | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
redraw(); | |||
do_callback(); | |||
} | |||
} | |||
return 1; | |||
case FL_RELEASE: | |||
mouseRightClicked = false; | |||
if (highlight) { | |||
highlight = 0; | |||
redraw(); | |||
do_callback(); | |||
} | |||
mouseClicked = false; | |||
return 1; | |||
case FL_SHORTCUT: | |||
if ( test_shortcut() ) | |||
{ | |||
do_callback(); | |||
return 1; | |||
} | |||
return 0; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
return 0; | |||
} | |||
private: | |||
}; | |||
} // Avtk | |||
#endif // AVTK_WAVESHAPER_H |
@@ -1,221 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_REVERB_H | |||
#define AVTK_REVERB_H | |||
#include <FL/Fl_Slider.H> | |||
namespace Avtk | |||
{ | |||
class Reverb : public Fl_Slider | |||
{ | |||
public: | |||
Reverb(int _x, int _y, int _w, int _h, const char *_label =0): | |||
Fl_Slider(_x, _y, _w, _h, _label) | |||
{ | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
amp = 0.5; | |||
s = 0.5; | |||
damp= 0.5; | |||
active = true; | |||
label = _label; | |||
highlight = false; | |||
mouseOver = false; | |||
} | |||
void size(float v) { s = v; redraw(); } | |||
void wet(float v) { amp = v; redraw(); } | |||
void damping(float v){damp = v; redraw();} | |||
bool getActive(){return active;} | |||
void setActive(bool a){active = a; redraw();} | |||
float s; | |||
float amp; | |||
float damp; | |||
bool active; | |||
bool mouseOver; | |||
bool highlight; | |||
int x, y, w, h; | |||
const char* label; | |||
void draw() | |||
{ | |||
if (damage() & FL_DAMAGE_ALL) | |||
{ | |||
cairo_t *cr = Fl::cairo_cc(); | |||
cairo_save( cr ); | |||
// graph | |||
cairo_rectangle( cr, x, y, w, h ); | |||
cairo_set_source_rgb( cr,28 / 255.f, 28 / 255.f , 28 / 255.f ); | |||
cairo_fill(cr); | |||
// set up dashed lines, 1 px off, 1 px on | |||
double dashes[1]; | |||
dashes[0] = 2.0; | |||
cairo_set_dash ( cr, dashes, 1, 0.0); | |||
// loop over each 2nd line, drawing dots | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_set_source_rgb(cr, 0.4,0.4,0.4); | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x + ((w / 4.f)*i), y ); | |||
cairo_line_to( cr, x + ((w / 4.f)*i), y + h ); | |||
} | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x , y + ((h / 4.f)*i) ); | |||
cairo_line_to( cr, x + w, y + ((h / 4.f)*i) ); | |||
} | |||
cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 ); | |||
cairo_stroke(cr); | |||
cairo_set_dash ( cr, dashes, 0, 0.0); | |||
// draw "damping" control | |||
cairo_move_to( cr, x+w*0.1 , y + h*0.85 - (h*0.7*amp)); | |||
cairo_line_to( cr, x+w*0.1 + (w-20)*damp, y + h*0.85 - (h*0.7*amp)); | |||
cairo_set_source_rgba(cr, 1.0, 0.48, 0, 1); | |||
cairo_set_line_join( cr, CAIRO_LINE_JOIN_ROUND); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND); | |||
cairo_set_line_width(cr, 1.9); | |||
cairo_stroke( cr ); | |||
// draw reverb triangle | |||
cairo_move_to( cr, x , y + h*0.99 ); | |||
cairo_line_to( cr, x + w*0.1, y + h*0.85 - (h*0.7*amp)); | |||
cairo_line_to( cr, x + w*0.3+w*0.7*s, y + (h*0.99)); | |||
// stroke | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve(cr); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_set_line_width(cr, 1.5); | |||
cairo_stroke( cr ); | |||
// stroke rim | |||
cairo_rectangle(cr, x+1, y+1, w-2, h-2); | |||
//cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 ); | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_stroke( cr ); | |||
if ( !active ) | |||
{ | |||
// big grey X | |||
cairo_set_line_width(cr, 20.0); | |||
cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7); | |||
cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT); | |||
cairo_stroke( cr ); | |||
} | |||
cairo_restore( cr ); | |||
draw_label(); | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Widget::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
switch(event) { | |||
case FL_PUSH: | |||
highlight = 1; | |||
/* | |||
if ( Fl::event_button() == FL_RIGHT_MOUSE ) | |||
{ | |||
active = !active; | |||
redraw(); | |||
do_callback(); | |||
} | |||
*/ | |||
return 1; | |||
case FL_DRAG: { | |||
int t = Fl::event_inside(this); | |||
if (t != highlight) { | |||
highlight = t; | |||
redraw(); | |||
} | |||
} | |||
return 1; | |||
case FL_ENTER: | |||
mouseOver = true; | |||
redraw(); | |||
return 1; | |||
case FL_LEAVE: | |||
mouseOver = false; | |||
redraw(); | |||
return 1; | |||
case FL_RELEASE: | |||
if (highlight) { | |||
highlight = 0; | |||
redraw(); | |||
} | |||
return 1; | |||
case FL_SHORTCUT: | |||
if ( test_shortcut() ) | |||
{ | |||
do_callback(); | |||
return 1; | |||
} | |||
return 0; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
} | |||
}; | |||
} // Avtk | |||
#endif // AVTK_ADSR_H | |||
@@ -1,286 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_SIDECHAIN_GAIN_H | |||
#define AVTK_SIDECHAIN_GAIN_H | |||
#include <FL/Fl_Widget.H> | |||
#include <FL/Fl_Slider.H> | |||
#include <valarray> | |||
#include <string> | |||
namespace Avtk | |||
{ | |||
class SidechainGain : public Fl_Slider | |||
{ | |||
public: | |||
SidechainGain(int _x, int _y, int _w, int _h, const char *_label = 0): | |||
Fl_Slider(_x, _y, _w, _h, _label) | |||
{ | |||
x = _x; | |||
y = _y; | |||
w = _w; | |||
h = _h; | |||
label = _label; | |||
mouseClickedX = 0; | |||
mouseClickedY = 0; | |||
mouseClicked = false; | |||
active = true; | |||
highlight = false; | |||
_threshold = 1.0; | |||
_target = 1.f; | |||
_reduce = 1.f; | |||
_release = 0.5; | |||
_sidechainAmp = 0; | |||
} | |||
void threshold(float t) {_threshold = t; redraw();} | |||
void reduce (float r) {_reduce = r; redraw();} | |||
void release (float r) {_release = r; redraw();} | |||
/// sets the sidechain amplitude | |||
void sidechain(float s) {_sidechainAmp = s; redraw();} | |||
bool active; | |||
bool highlight; | |||
int x, y, w, h; | |||
const char* label; | |||
int mouseClickedX; | |||
int mouseClickedY; | |||
bool mouseClicked; | |||
bool mouseRightClicked; | |||
float _threshold; | |||
float _target; | |||
float _reduce; | |||
float _release; | |||
float _sidechainAmp; | |||
void set_active(bool a) | |||
{ | |||
active = a; | |||
redraw(); | |||
} | |||
void draw() | |||
{ | |||
if (damage() & FL_DAMAGE_ALL) | |||
{ | |||
cairo_t *cr = Fl::cairo_cc(); | |||
cairo_save( cr ); | |||
cairo_set_line_width(cr, 1.5); | |||
// fill background | |||
cairo_rectangle( cr, x, y, w, h); | |||
cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f ); | |||
cairo_fill_preserve( cr ); | |||
cairo_clip( cr ); | |||
// set up dashed lines, 1 px off, 1 px on | |||
double dashes[1]; | |||
dashes[0] = 2.0; | |||
cairo_set_dash ( cr, dashes, 1, 0.0); | |||
cairo_set_line_width( cr, 1.0); | |||
// loop over each 2nd line, drawing dots | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_set_source_rgb(cr, 0.4,0.4,0.4); | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x + ((w / 4.f)*i), y ); | |||
cairo_line_to( cr, x + ((w / 4.f)*i), y + h ); | |||
} | |||
for ( int i = 0; i < 4; i++ ) | |||
{ | |||
cairo_move_to( cr, x , y + ((h / 4.f)*i) ); | |||
cairo_line_to( cr, x + w, y + ((h / 4.f)*i) ); | |||
} | |||
cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 ); | |||
cairo_stroke(cr); | |||
cairo_set_dash ( cr, dashes, 0, 0.0); | |||
// draw threshold / ducked line | |||
cairo_move_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)), y ); | |||
cairo_line_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)) + _sidechainAmp* _reduce*( w * 0.5 ), y + h / 2 ); | |||
cairo_line_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)), y + h ); | |||
cairo_line_to( cr, x + w , y + h ); | |||
cairo_line_to( cr, x + w , y ); | |||
cairo_close_path( cr ); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 ); | |||
cairo_fill_preserve( cr ); | |||
cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 ); | |||
cairo_stroke( cr ); | |||
// _sidechainAmp => arrow | |||
cairo_move_to( cr, x + w * 0.00 * _sidechainAmp, y + h * 0.4 - (h*0.1*_sidechainAmp) ); | |||
cairo_line_to( cr, x + w * 0.65 * _sidechainAmp, y + h * 0.4 ); | |||
cairo_line_to( cr, x + w * 0.1 + w * 0.65 * _sidechainAmp, y + h * 0.5 ); | |||
cairo_line_to( cr, x + w * 0.65 * _sidechainAmp, y + h * 0.6 ); | |||
cairo_line_to( cr, x + w * 0.00 * _sidechainAmp, y + h * 0.6 + (h*0.1*_sidechainAmp) ); | |||
cairo_close_path( cr ); | |||
cairo_set_source_rgba( cr, 1.0, 0.48, 0.f , 0.21 ); | |||
cairo_fill_preserve( cr ); | |||
cairo_set_source_rgba( cr, 1.0, 0.48, 0.f , 1 ); | |||
cairo_stroke( cr ); | |||
// _release horizontal line | |||
cairo_move_to( cr, x , y + h * 0.25 + h/2 * _release ); | |||
cairo_line_to( cr, x + w, y + h * 0.25 + h/2 * _release ); | |||
cairo_set_source_rgba( cr, 1.0, 0.0, 0.f , 1 ); | |||
cairo_stroke( cr ); | |||
// stroke outline | |||
cairo_rectangle(cr, x+1, y+1, w-2, h-2); | |||
cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 ); | |||
cairo_set_line_width(cr, 1.0); | |||
cairo_stroke( cr ); | |||
if ( !active ) | |||
{ | |||
// big grey X | |||
cairo_set_line_width(cr, 20.0); | |||
cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7); | |||
cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) ); | |||
cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) ); | |||
cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT); | |||
cairo_stroke( cr ); | |||
} | |||
cairo_restore( cr ); | |||
} | |||
} | |||
void resize(int X, int Y, int W, int H) | |||
{ | |||
Fl_Widget::resize(X,Y,W,H); | |||
x = X; | |||
y = Y; | |||
w = W; | |||
h = H; | |||
redraw(); | |||
} | |||
int handle(int event) | |||
{ | |||
/* | |||
switch(event) | |||
{ | |||
case FL_PUSH: | |||
highlight = 0; | |||
mouseRightClicked = false; | |||
if ( Fl::event_button() == FL_RIGHT_MOUSE ) | |||
{ | |||
active = !active; | |||
redraw(); | |||
mouseRightClicked = true; | |||
do_callback(); | |||
} | |||
return 1; | |||
case FL_DRAG: | |||
{ | |||
if ( Fl::event_state(FL_BUTTON1) ) | |||
{ | |||
if ( mouseClicked == false ) // catch the "click" event | |||
{ | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
mouseClicked = true; | |||
} | |||
float deltaX = mouseClickedX - Fl::event_x(); | |||
float deltaY = mouseClickedY - Fl::event_y(); | |||
float valX = value(); | |||
valX -= deltaX / 100.f; | |||
float valY = makeupGain; | |||
valY += deltaY / 100.f; | |||
if ( valX > 1.0 ) valX = 1.0; | |||
if ( valX < 0.0 ) valX = 0.0; | |||
if ( valY > 1.0 ) valY = 1.0; | |||
if ( valY < 0.0 ) valY = 0.0; | |||
//handle_drag( value + deltaY ); | |||
set_value( valX ); | |||
makeupGain = valY; | |||
mouseClickedX = Fl::event_x(); | |||
mouseClickedY = Fl::event_y(); | |||
redraw(); | |||
do_callback(); | |||
} | |||
} | |||
return 1; | |||
case FL_RELEASE: | |||
mouseRightClicked = false; | |||
if (highlight) { | |||
highlight = 0; | |||
redraw(); | |||
do_callback(); | |||
} | |||
mouseClicked = false; | |||
return 1; | |||
case FL_SHORTCUT: | |||
if ( test_shortcut() ) | |||
{ | |||
do_callback(); | |||
return 1; | |||
} | |||
return 0; | |||
default: | |||
return Fl_Widget::handle(event); | |||
} | |||
*/ | |||
return 0; | |||
} | |||
private: | |||
}; | |||
} // Avtk | |||
#endif // AVTK_SIDECHAIN_GAIN_H |
@@ -1,296 +0,0 @@ | |||
/* | |||
* Author: Harry van Haaren 2013 | |||
* harryhaaren@gmail.com | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |||
* MA 02110-1301, USA. | |||
* | |||
*/ | |||
#ifndef AVTK_WAVESHAPER_H | |||
#define AVTK_WAVESHAPER_H | |||
#include <FL/Fl_Widget.H> | |||
#include <FL/Fl_Slider.H> | |||
#include <FL/Fl_Menu_Item.H> | |||
#include <valarray> | |||
#include <string> | |||
namespace Avtk | |||
{ | |||
class Waveshaper : public Fl_Slider | |||
{ | |||
public: | |||
Waveshaper(int _x, int _y, int _w, int _h, const char *_label = 0): | |||
Fl_Slider(_x, _y, _w, _h, _label) |