Move Mixer into its own branch until it's ready.

pull/3/head
Jonathan Moore Liles 2008-05-26 11:29:35 -05:00
parent 318144baed
commit b8b9a3b029
9 changed files with 6 additions and 1045 deletions

View File

@ -9,7 +9,7 @@
VERSION := 0.5.0
all: make.conf FL Timeline Mixer
all: make.conf FL Timeline
make.conf: configure
@ ./configure
@ -26,11 +26,10 @@ else
endif
CXXFLAGS += $(SNDFILE_CFLAGS) $(LASH_CFLAGS) $(FLTK_CFLAGS) -DINSTALL_PREFIX="\"$(prefix)\"" -DVERSION=\"$(VERSION)\"
INCLUDES := -Iutil
INCLUDES := -I. -Iutil -IFL
include scripts/colors
.C.o:
@ echo "Compiling: $(BOLD)$(YELLOW)$<$(SGR0)"
@ $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
@ -42,10 +41,9 @@ DONE := $(BOLD)$(GREEN)done$(SGR0)
include FL/makefile.inc
include Timeline/makefile.inc
include Mixer/makefile.inc
SRCS:=$(Timeline_SRCS) $(FL_SRCS) $(Mixer_SRCS)
OBJS:=$(FL_OBJS) $(Timeline_OBJS) $(Mixer_OBJS)
SRCS:=$(Timeline_SRCS) $(FL_SRCS)
OBJS:=$(FL_OBJS) $(Timeline_OBJS)
# FIXME: isn't there a better way?
$(OBJS): make.conf
@ -55,12 +53,12 @@ TAGS: $(SRCS)
.deps: make.conf $(SRCS)
@ echo -n Calculating dependencies...
@ makedepend -f- -- $(CXXFLAGS) -I. -IFL -ITimeline -IMixer -- $(SRCS) > .deps 2>/dev/null && echo $(DONE)
@ makedepend -f- -- $(CXXFLAGS) $(INCLUDES) -- $(SRCS) > .deps 2>/dev/null && echo $(DONE)
depend: .deps
.PHONEY: clean config depend
clean: FL_clean Timeline_clean Mixer_clean
clean: FL_clean Timeline_clean
-include .deps

View File

@ -1,137 +0,0 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
/* a Digital Peak Meter, either horizontal or vertical. Color is a
gradient from min_color() to max_color(). box() is used to draw the
individual 'lights'. division() controls how many 'lights' there
are. value() is volume in dBFS */
#include "DPM.H"
/* we cache the gradient for (probably excessive) speed */
float DPM::_dim;
Fl_Color DPM::_gradient[128] = { (Fl_Color)-1 };
Fl_Color DPM::_dim_gradient[128];
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Group.H>
#include <math.h>
#include <stdio.h>
DPM::DPM ( int X, int Y, int W, int H, const char *L ) :
Meter( X, Y, W, H, L )
{
segments( 64 );
type( FL_VERTICAL );
dim( 0.70f );
/* initialize gradients */
if ( DPM::_gradient[ 0 ] == -1 )
DPM::blend( FL_GREEN, FL_RED );
box( FL_ROUNDED_BOX );
}
/* which marks to draw beside meter */
const int marks [] = { -70, -50, -40, -30, -20, -10, -3, 0, 4 };
void
DPM::draw_label ( void )
{
/* dirty hack */
if ( parent()->child( 0 ) == this )
{
fl_font( FL_TIMES, 8 );
fl_color( FL_WHITE );
/* draw marks */
for ( int i = sizeof( marks ) / sizeof( marks[0] ); i-- ; )
{
char pat[5];
sprintf( pat, "%d", marks[ i ] );
int v = h() * deflection( (float)marks[ i ] );
fl_draw( pat, x() - 20, (y() + h() - 8) - v, 19, 8, (Fl_Align) (FL_ALIGN_RIGHT | FL_ALIGN_TOP) );
}
}
}
void
DPM::draw ( void )
{
int v = pos( value() );
int pv = pos( peak() );
int bh = h() / _segments;
int bw = w() / _segments;
if ( damage() == FL_DAMAGE_ALL )
draw_label();
const int active = active_r();
int hi, lo;
/* only draw as many segments as necessary */
if ( damage() == FL_DAMAGE_USER1 )
{
if ( old_value() > value() )
{
hi = pos( old_value() );
lo = v;
}
else
{
hi = v;
lo = pos( old_value() );
}
}
else
{
lo = 0;
hi = _segments;
}
for ( int p = hi; p > lo; p-- )
{
Fl_Color c = DPM::div_color( p );
if ( p > v && p != pv )
c = dim_div_color( p );
if ( ! active )
c = fl_inactive( c );
if ( type() == FL_HORIZONTAL )
fl_draw_box( box(), x() + (p * bw), y(), bw, h(), c );
else
fl_draw_box( box(), x(), y() + h() - (p * bh), w(), bh, c );
/* fl_color( c ); */
/* fl_rectf( x(), y() + h() - (p * bh), w(), bh ); */
/* fl_color( FL_BLACK ); */
/* fl_rect( x(), y() + h() - (p * bh), w(), bh ); */
}
}

View File

@ -1,81 +0,0 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#pragma once
#include <FL/Fl_Valuator.H> // for FL_HORIZONTAL and FL_VERTICAL
#include "Meter.H"
class DPM : public Meter
{
int _segments;
int pos ( float v )
{
return deflection( v ) * _segments;
}
static float _dim;
static Fl_Color _gradient[];
static Fl_Color _dim_gradient[];
Fl_Color
div_color ( int i )
{
return _gradient[ i * 127 / _segments ];
}
Fl_Color
dim_div_color ( int i )
{
return _dim_gradient[ i * 127 / _segments ];
}
protected:
virtual void draw_label ( void );
virtual void draw ( void );
public:
DPM ( int X, int Y, int W, int H, const char *L = 0 );
// void value ( float v ) { if ( pos( v ) != pos( value() ) ) redraw(); Meter::value( v ) }
bool segments ( void ) const { return _segments; }
void segments ( int v ) { _segments = v; }
float dim ( void ) const { return _dim; }
void dim ( float v ) { _dim = v; redraw(); }
static
void
blend ( Fl_Color min, Fl_Color max )
{
for ( int i = 128; i-- ; )
_gradient[ i ] = fl_color_average( max, min, i / (float)128 );
for ( int i = 128; i-- ; )
_dim_gradient[ i ] = fl_color_average( FL_BLACK, _gradient[ i ], _dim );
}
};

View File

@ -1,136 +0,0 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
/* Base class for all meters */
#include <FL/Fl.H>
#include <FL/Fl_Widget.H>
class Meter : public Fl_Widget
{
float _peak;
float _old_value;
float _value;
protected:
virtual void draw ( void ) = 0;
virtual int handle ( int m )
{
if ( m == FL_PUSH )
{
// if ( Fl::event_button3() )
// hide();
// else
reset();
}
return 0;
}
float
deflection ( float db )
{
float def = 0.0f;
if ( db < -70.0f )
def = 0.0f;
else if ( db < -60.0f )
def = ( db + 70.0f ) * 0.25f;
else if ( db < -50.0f )
def = ( db + 60.0f ) * 0.5f + 2.5f;
else if ( db < -40.0f )
def = ( db + 50.0f ) * 0.75f + 7.5f;
else if ( db < -30.0f )
def = ( db + 40.0f ) * 1.5f + 15.0f;
else if ( db < -20.0f )
def = ( db + 30.0f ) * 2.0f + 30.0f;
else if ( db < 6.0f )
def = ( db + 20.0f ) * 2.5f + 50.0f;
else
def = 115.0f;
return def / 115.0f;
}
float old_value ( void ) const { return _old_value; }
public:
Meter ( int X, int Y, int W, int H, const char *L = 0 ) :
Fl_Widget( X, Y, W, H, L )
{
_peak = _value = -80.0f;
_old_value = 4.0f;
}
virtual ~Meter ( ) { }
void value ( float v )
{
if ( _value != v )
{
damage( FL_DAMAGE_USER1 );
_old_value = _value;
_value = v;
if ( _value > _peak )
_peak = _value;
}
}
float value ( void ) const { return _value; }
float peak ( void ) const { return _peak; }
void reset ( void ) { _peak = -80.0f; redraw(); }
};
#include <FL/Fl_Group.H>
#include <stdio.h>
/* ... Extension methods for any group containing only meters. Access
* via a cast to (Meter_Pack *) */
class Meter_Pack : public Fl_Group
{
public:
/** return a pointer to the meter for channel /c/ in group of meters /g/ */
Meter *
channel ( int c )
{
if ( c > children() )
{
fprintf( stderr, "no such channel\n" );
return NULL;
}
return (Meter *)child( c );
}
int
channels ( void ) const { return children(); }
};

View File

@ -1,97 +0,0 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#include <FL/Fl.H>
#include <FL/Fl_Single_Window.H>
#include <FL/Fl_Single_Window.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Pack.H>
#include "Mixer_Strip.H"
#include <stdlib.h>
#include <unistd.h>
#include "DPM.H"
Fl_Single_Window *main_window;
#include <FL/Boxtypes.H>
int
main ( int argc, char **argv )
{
Fl::get_system_colors();
Fl::scheme( "plastic" );
init_boxtypes();
Fl_Pack * mixer_strips;
Fl_Single_Window *o = main_window = new Fl_Single_Window( 1024, 768 );
{
Fl_Scroll *o = new Fl_Scroll( 0, 0, main_window->w(), main_window->h() );
main_window->resizable( o );
{
Fl_Pack *o = mixer_strips = new Fl_Pack( 0, 0, 1, main_window->h() );
o->type( Fl_Pack::HORIZONTAL );
{
for ( int i = 16; i-- ; )
new Mixer_Strip( 0, 0, 120, main_window->h() + 150 );
}
o->end();
}
o->end();
}
o->end();
o->show( argc, argv );
while ( 1 )
{
for ( int i = mixer_strips->children(); i--; )
{
Meter_Pack *mp = (Meter_Pack*)((Mixer_Strip*) mixer_strips->child( i ))->meters_pack;
for ( int j = mp->channels(); j-- ; )
{
Meter *o = mp->channel( j );
float v = o->value();
float r = ((rand() / (float)RAND_MAX) - 0.5f) * 10.0f;
v += r;
if ( v > 4.0f ) v = 0.0f;
if ( v < -80.0f ) v = 0.0f;
o->value( v );
}
}
Fl::wait( 0.02f );
/* Fl::check(); */
/* usleep( 50000 ); */
}
// Fl::run();
}

View File

@ -1,110 +0,0 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0108
header_name {.H}
code_name {.C}
decl {\#include "DPM.H"} {public global
}
decl {\#include "Panner.H"} {public global
}
decl {\#include <FL/Fl_Scalepack.H>} {public global
}
decl {\#include <FL/Fl_Flip_Button.H>} {public global
}
decl {\#include <FL/Fl_Arc_Dial.H>} {public global
}
decl {\#include <FL/Boxtypes.H>} {selected public global
}
widget_class Mixer_Strip {open
xywh {1051 42 124 878} type Double box UP_FRAME color 32 selection_color 63 resizable
code0 {size( 120, h() );} visible
} {
Fl_Box {} {
label {<track name>}
xywh {7 7 110 19} box RSHADOW_BOX color 95 labelcolor 32
}
Fl_Box {} {
label {<Oscilloscope>}
xywh {7 33 110 104} box UP_FRAME hide
}
Fl_Group {} {open
xywh {7 143 110 25}
} {
Fl_Button {} {
label {@circle}
private xywh {7 143 35 25} type Toggle box THIN_UP_BOX labelsize 10
}
Fl_Button {} {
label m
private xywh {46 143 32 25} type Toggle box THIN_UP_BOX
}
Fl_Button {} {
label s
private xywh {82 143 35 25} type Toggle box THIN_UP_BOX
}
}
Fl_Button {} {
label {post/pre}
xywh {61 183 45 22} type Toggle box ROUNDED_BOX color 106 selection_color 65 align 64
class Fl_Flip_Button
}
Fl_Group {} {open
xywh {8 208 103 471} resizable
} {
Fl_Value_Slider gain {
label Gain
callback {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );}
xywh {9 208 33 448} type {Vert Knob} color 32 selection_color 1 minimum 1.5 maximum 0 step 0.01 value 1 textsize 14
}
Fl_Pack meters_pack {
label meters open
xywh {56 208 55 471} type HORIZONTAL labeltype NO_LABEL align 0
class Fl_Scalepack
} {
Fl_Box {} {
label DPM
xywh {56 208 24 459} box ROUNDED_BOX selection_color 88
class DPM
}
Fl_Box {} {
label DPM
xywh {81 208 30 459} box ROUNDED_BOX selection_color 88
class DPM
}
}
}
Fl_Box {} {
label Pan
xywh {6 693 110 90} box THIN_UP_BOX color 32 labelsize 11 align 1
class Panner
}
Fl_Dial {} {
xywh {10 36 41 39} box OVAL_FRAME color 52 selection_color 55
code0 {o->box( FL_BURNISHED_OVAL_BOX );}
class Fl_Arc_Dial
}
Fl_Dial {} {
xywh {10 80 41 39} selection_color 55
code0 {o->box( FL_BURNISHED_OVAL_BOX );}
class Fl_Arc_Dial
}
Fl_Dial {} {
xywh {73 36 41 39} box OVAL_FRAME color 52 selection_color 55
code0 {o->box( FL_BURNISHED_OVAL_BOX );}
class Fl_Arc_Dial
}
Fl_Dial {} {
xywh {73 80 41 39} box OVAL_FRAME color 52 selection_color 55
code0 {o->box( FL_BURNISHED_OVAL_BOX );}
class Fl_Arc_Dial
}
Fl_Counter intputs_counter {
label {Mix Ins}
xywh {60 788 58 20} type Simple align 4 minimum 1 maximum 4 step 1 value 1
}
}

View File

@ -1,278 +0,0 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#include "Panner.H"
#include <math.h>
/* 2D Panner widget. Supports various multichannel configurations. */
/* multichannel layouts, in degrees */
int Panner::_configs[][12] =
{
/* none, error condition? */
{ NONE },
/* mono, panner disabled */
{ NONE },
/* stereo */
{ L, R },
/* stereo + mono */
{ L, R, C },
/* quad */
{ FL, FR, RL, RR },
/* 5.1 */
{ FL, FR, RL, RR, C },
/* no such config */
{ NONE },
/* 7.1 */
{ FL, FR, RL, RR, C, L, R },
};
/* speaker symbol */
#define BP fl_begin_polygon()
#define EP fl_end_polygon()
#define BCP fl_begin_complex_polygon()
#define ECP fl_end_complex_polygon()
#define BL fl_begin_line()
#define EL fl_end_line()
#define BC fl_begin_loop()
#define EC fl_end_loop()
#define vv(x,y) fl_vertex(x,y)
static void draw_speaker ( Fl_Color col )
{
fl_color(col);
BP; vv(0.2,0.4); vv(0.6,0.4); vv(0.6,-0.4); vv(0.2,-0.4); EP;
BP; vv(-0.6,0.8); vv(0.2,0.0); vv(-0.6,-0.8); EP;
fl_color( fl_darker( col ) );
BC; vv(0.2,0.4); vv(0.6,0.4); vv(0.6,-0.4); vv(0.2,-0.4); EC;
BC; vv(-0.6,0.8); vv(0.2,0.0); vv(-0.6,-0.8); EC;
}
/** set X, Y, W, and H to the bounding box of point /p/ in screen coords */
void
Panner::point_bbox ( const Point *p, int *X, int *Y, int *W, int *H ) const
{
int tx, ty, tw, th;
bbox( tx, ty, tw, th );
tw -= pw();
th -= ph();
float px, py;
p->axes( &px, &py );
*X = tx + ((tw / 2) * px + (tw / 2));
*Y = ty + ((th / 2) * py + (th / 2));
*W = pw();
*H = ph();
}
Panner::Point *
Panner::event_point ( void )
{
for ( int i = _ins; i--; )
{
int px, py, pw, ph;
Point *p = &_points[ i ];
point_bbox( p, &px, &py, &pw, &ph );
// printf( "%d, %d -- %d %d %d %d\n", Fl::event_x(), Fl::event_y(), px, py, pw, ph );
if ( Fl::event_inside( px, py, pw, ph ) )
return p;
}
return NULL;
}
void
Panner::draw ( void )
{
draw_box();
// draw_box( FL_FLAT_BOX, x(), y(), w(), h(), FL_BLACK );
draw_label();
if ( _bypassed )
{
fl_color( 0 );
fl_font( FL_HELVETICA, 12 );
fl_draw( "(bypass)", x(), y(), w(), h(), FL_ALIGN_CENTER );
return;
}
int tw, th, tx, ty;
bbox( tx, ty, tw, th );
fl_push_clip( tx, ty, tw, th );
fl_color( FL_WHITE );
const int b = 10;
tx += b;
ty += b;
tw -= b * 2;
th -= b * 2;
fl_arc( tx, ty, tw, th, 0, 360 );
if ( _configs[ _outs ][0] >= 0 )
{
for ( int i = _outs; i--; )
{
int a = _configs[ _outs ][ i ];
Point p( 1.2f, (float)a );
float px, py;
p.axes( &px, &py );
fl_push_matrix();
const int bx = tx + ((tw / 2) * px + (tw / 2));
const int by = ty + ((th / 2) * py + (th / 2));
fl_translate( bx, by );
fl_scale( 5, 5 );
a = 90 - a;
fl_rotate( a );
draw_speaker( FL_WHITE );
fl_rotate( -a );
fl_pop_matrix();
}
}
/* ensure that points are drawn *inside* the circle */
for ( int i = _ins; i--; )
{
Point *p = &_points[ i ];
Fl_Color c = (Fl_Color)(10 + i);
int px, py, pw, ph;
point_bbox( p, &px, &py, &pw, &ph );
/* draw point */
fl_color( c );
fl_pie( px, py, pw, ph, 0, 360 );
/* draw echo */
fl_color( c = fl_darker( c ) );
fl_arc( px - 5, py - 5, pw + 10, ph + 10, 0, 360 );
fl_color( c = fl_darker( c ) );
fl_arc( px - 10, py - 10, pw + 20, ph + 20, 0, 360 );
fl_color( c = fl_darker( c ) );
fl_arc( px - 30, py - 30, pw + 60, ph + 60, 0, 360 );
/* draw number */
char pat[4];
snprintf( pat, 4, "%d", i + 1 );
fl_color( FL_BLACK );
fl_font( FL_HELVETICA, ph + 2 );
fl_draw( pat, px + 1, py + 1, pw - 1, ph - 1, FL_ALIGN_CENTER );
/* draw line */
/* fl_color( FL_WHITE ); */
/* fl_line( bx + pw() / 2, by + ph() / 2, tx + (tw / 2), ty + (th / 2) ); */
}
fl_pop_clip();
}
/* return the current gain setting for the path in/out */
Panner::Point
Panner::point( int i )
{
return _points[ i ];
}
int
Panner::handle ( int m )
{
static Point *drag;
switch ( m )
{
case FL_PUSH:
if ( Fl::event_button2() )
{
_bypassed = ! _bypassed;
redraw();
return 0;
}
else if ( Fl::event_button1() && ( drag = event_point() ) )
return 1;
else
return 0;
case FL_RELEASE:
drag = NULL;
return 1;
case FL_DRAG:
{
float X = Fl::event_x() - x();
float Y = Fl::event_y() - y();
int tx, ty, tw, th;
bbox( tx, ty, tw, th );
/* if ( _outs < 3 ) */
/* drag->angle( (float)(X / (tw / 2)) - 1.0f, 0.0f ); */
/* else */
drag->angle( (float)(X / (tw / 2)) - 1.0f, (float)(Y / (th / 2)) - 1.0f );
printf( "%f %f\n", drag->a, drag->d );
redraw();
return 1;
}
}
return 0;
}

View File

@ -1,171 +0,0 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#pragma once
#include <FL/Fl_Widget.H>
#include <FL/fl_draw.H>
#include <FL/Fl.H>
#include <math.h>
#include <vector>
using namespace std;
class Panner : public Fl_Widget
{
struct Point
{
/* axes */
/* distance from center (from 0 to 1) */
float d;
/* angle */
float a;
Point ( ) : d( 0.0f ), a( 0.0f ) { }
Point ( float D, float A ) : d( D ), a( A ) { }
/** translate angle /a/ into x/y coords and place the result in /X/ and /Y/ */
void
axes ( float *X, float *Y ) const
{
/* rotate */
float A = ( 270 - a ) * ( M_PI / 180 );
*X = -d * cosf( A );
*Y = d * sinf( A );
}
void
angle ( float X1, float Y1 )
{
float X2, Y2;
Y2 = X2 = 0;
float t;
t = atan2( X2 - X1, Y2 - Y1 );
a = t * (180 / M_PI);
if ( a < 0 )
a = 360 + a;
a = 360 - a;
/* standard distance calculation */
d = sqrt( pow( X2 - X1, 2 ) + pow( Y2 - Y1, 2 ) );
if ( d > 1.0f )
d = 1.0f;
}
/** return the distance between the point and that referenced by /p/ */
float
distance ( const Point &p )
{
/* first, transform point coords */
float x1, y1, x2, y2;
axes( &x1, &y1 );
p.axes( &x2, &y2 );
/* standard distance calculation */
return sqrt( pow( x1 - x2, 2 ) + pow( y1 - y2, 2 ) );
}
};
/* channel configuration */
int _ins,
_outs;
bool _bypassed;
vector <Point> _points;
static int pw ( void ) { return 12; }
static int ph ( void ) { return 12; }
static int _configs[][12];
void bbox ( int &X, int &Y, int &W, int &H ) const
{
W = w() - Fl::box_dw( box() );
H = h() - Fl::box_dh( box() );
X = x() + Fl::box_dx( box() );
Y = y() + Fl::box_dy( box() );
}
void point_bbox ( const Point *p, int *X, int *Y, int *W, int *H ) const;
Point * event_point ( void );
Point angle_to_axes ( float a );
enum {
NONE = -1,
R = 90,
L = 270,
C = 0,
FL = 315,
FR = 45,
RL = 225,
RR = 135,
};
protected:
virtual void draw ( void );
virtual int handle ( int );
public:
Panner ( int X, int Y, int W, int H, const char *L = 0 ) :
Fl_Widget( X, Y, W, H, L )
{
_bypassed = false;
_ins = 1;
_outs = 1;
// _ins = _outs = 4;
_points.push_back( Point( 1, FL ) );
/* _points.push_back( Point( 1, FR ) ); */
/* _points.push_back( Point( 1, RL ) ); */
/* _points.push_back( Point( 1, RR ) ); */
}
virtual ~Panner ( ) { }
Panner::Point point ( int i );
};

View File

@ -1,27 +0,0 @@
# -*- mode: makefile; -*-
Mixer/.sources:
@ echo "Mixer_SRCS=\\" > Mixer/.sources
@ git ls-files 'Mixer/*.C' | tr '\n' ' ' >> Mixer/.sources
@ git ls-files 'Mixer/*.fl' | tr '\n' ' ' >> Mixer/.sources
include Mixer/.sources
Mixer_SRCS += util/debug.C
Mixer_SRCS:=$(Mixer_SRCS:.fl=.C)
Mixer_OBJS:=$(Mixer_SRCS:.C=.o)
Mixer_LIBS := $(FLTK_LIBS)
INCLUDES := -I.
Mixer/mixer: $(Mixer_OBJS) FL
@ echo -n Linking mixer...
@ $(CXX) $(CXXFLAGS) $(Mixer_LIBS) $(Mixer_OBJS) -o $@ -LFL -lfl_widgets && echo $(DONE)
.PHONEY: Mixer
Mixer: Mixer/mixer
Mixer_clean:
rm -f $(Mixer_OBJS) Mixer/mixer