Browse Source

Mixer: Save/restore state of spatialization console.

tags/non-daw-v1.2.0
Jonathan Moore Liles 11 years ago
parent
commit
612fdfe952
8 changed files with 132 additions and 71 deletions
  1. +1
    -1
      lib/ntk
  2. +20
    -14
      mixer/src/Mixer.C
  3. +2
    -1
      mixer/src/Mixer.H
  4. +39
    -48
      mixer/src/Panner.C
  5. +6
    -5
      mixer/src/Panner.H
  6. +50
    -0
      mixer/src/Spatialization_Console.C
  7. +12
    -2
      mixer/src/Spatialization_Console.H
  8. +2
    -0
      mixer/src/main.C

+ 1
- 1
lib/ntk

@@ -1 +1 @@
Subproject commit 81f41f5fed153f7f9aa5f7b845d7171f74919750
Subproject commit 415422bd1b35cdbac5c751dcf8f4fb9cbe696927

+ 20
- 14
mixer/src/Mixer.C View File

@@ -318,19 +318,6 @@ void Mixer::cb_menu(Fl_Widget* o) {
{ {
Fl::paste(*this); Fl::paste(*this);
} }
else if ( !strcmp( picked, "&Mixer/Spatialization Console" ) )
{
if ( ! spatialization_console )
{
Spatialization_Console *o = new Spatialization_Console();
spatialization_console = o;
}

if ( spatialization_console->shown() )
spatialization_console->hide();
else
spatialization_console->show();
}
else if (! strcmp( picked, "&Project/Se&ttings/&Rows/One") ) else if (! strcmp( picked, "&Project/Se&ttings/&Rows/One") )
{ {
rows( 1 ); rows( 1 );
@@ -343,6 +330,19 @@ void Mixer::cb_menu(Fl_Widget* o) {
{ {
rows( 3 ); rows( 3 );
} }
else if (! strcmp( picked, "&Mixer/&Spatialization Console") )
{
if ( ! spatialization_console )
{
Spatialization_Console *o = new Spatialization_Console();
spatialization_console = o;
}
if ( ! menu->mvalue()->value() )
spatialization_console->hide();
else
spatialization_console->show();
}
else if (! strcmp( picked, "&Project/Se&ttings/Make Default") ) else if (! strcmp( picked, "&Project/Se&ttings/Make Default") )
{ {
save_default_project_settings(); save_default_project_settings();
@@ -517,7 +517,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
o->add( "&Mixer/Add &N Strips" ); o->add( "&Mixer/Add &N Strips" );
o->add( "&Mixer/&Import Strip" ); o->add( "&Mixer/&Import Strip" );
o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 ); o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 );
o->add( "&Mixer/Spatialization Console", FL_F + 8, 0, 0 );
o->add( "&Mixer/&Spatialization Console", FL_F + 8, 0, 0, FL_MENU_TOGGLE );
o->add( "&Remote Control/Start Learning", FL_F + 9, 0, 0 ); o->add( "&Remote Control/Start Learning", FL_F + 9, 0, 0 );
o->add( "&Remote Control/Stop Learning", FL_F + 10, 0, 0 ); o->add( "&Remote Control/Stop Learning", FL_F + 10, 0, 0 );
o->add( "&Remote Control/Send State" ); o->add( "&Remote Control/Send State" );
@@ -933,6 +933,9 @@ Mixer::handle_dirty ( int d, void *v )
void void
Mixer::snapshot ( void ) Mixer::snapshot ( void )
{ {
if ( spatialization_console )
spatialization_console->log_create();

for ( int i = 0; i < mixer_strips->children(); ++i ) for ( int i = 0; i < mixer_strips->children(); ++i )
((Mixer_Strip*)mixer_strips->child( i ))->log_children(); ((Mixer_Strip*)mixer_strips->child( i ))->log_children();
} }
@@ -981,6 +984,9 @@ void
Mixer::update_menu ( void ) Mixer::update_menu ( void )
{ {
project_name->label( Project::name() ); project_name->label( Project::name() );

const_cast<Fl_Menu_Item*>(menubar->find_item( "&Mixer/&Spatialization Console" ))
->flags = FL_MENU_TOGGLE | ( ( spatialization_console && spatialization_console->shown() ) ? FL_MENU_VALUE : 0 );
} }


void void


+ 2
- 1
mixer/src/Mixer.H View File

@@ -73,7 +73,6 @@ private:


void load_options ( void ); void load_options ( void );
void save_options ( void ); void save_options ( void );
void update_menu ( void );
void save_translations ( void ); void save_translations ( void );
void load_translations ( void ); void load_translations ( void );


@@ -91,6 +90,8 @@ private:


public: public:


void update_menu ( void );

static Spatialization_Console *spatialization_console; static Spatialization_Console *spatialization_console;


int nstrips ( void ) const; int nstrips ( void ) const;


+ 39
- 48
mixer/src/Panner.C View File

@@ -66,6 +66,33 @@ Panner::Panner ( int X, int Y, int W, int H, const char *L ) :
} }
end(); end();
_bg_image[0] = _bg_image[1] = 0;
}

Panner::~Panner ( )
{
if ( _bg_image[0] )
((Fl_Shared_Image*)_bg_image[0])->release();
if ( _bg_image[1] )
((Fl_Shared_Image*)_bg_image[1])->release();
}

static int find_numeric_menu_item( const Fl_Menu_Item *menu, int n )
{
for ( unsigned int i = 0; menu[i].text; i++ )
{
if ( atoi( menu[i].text ) == n )
return i;
}
}

void
Panner::range ( float v )
{
int i = find_numeric_menu_item( _range_choice->menu(), v );
_range_choice->value( i );
} }


/** set X, Y, W, and H to the bounding box of point /p/ in screen coords */ /** set X, Y, W, and H to the bounding box of point /p/ in screen coords */
@@ -136,8 +163,10 @@ Panner::draw_the_box ( int tx, int ty, int tw, int th )


Fl_Image *i = 0; Fl_Image *i = 0;


if ( projection() == POLAR )
if ( ! ( _bg_image[0] && _bg_image[1] ))
{ {
Fl_Image *i;
switch ( tw ) switch ( tw )
{ {
case 802: case 802:
@@ -150,9 +179,9 @@ Panner::draw_the_box ( int tx, int ty, int tw, int th )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-502x502.png" ); i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-sphere-502x502.png" );
break; break;
} }
}
else
{
_bg_image[0] = i;
switch ( tw ) switch ( tw )
{ {
case 802: case 802:
@@ -165,56 +194,18 @@ Panner::draw_the_box ( int tx, int ty, int tw, int th )
i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-502x502.png" ); i = Fl_Shared_Image::get( PIXMAP_PATH "/non-mixer/panner-plane-502x502.png" );
break; break;
} }
_bg_image[1] = i;
} }
if ( projection() == POLAR )
i = _bg_image[0];
else
i = _bg_image[1];


if ( i ) if ( i )
i->draw( tx, ty ); i->draw( tx, ty );
} }


void
Panner::draw_grid ( int tx, int ty, int tw, int th )
{

fl_push_matrix();
fl_translate(tx,ty);
fl_scale(tw,th);

fl_color( fl_color_add_alpha( FL_WHITE, 25 ) );

for ( float x = 0.0f; x <= 1.0f; x += 0.05f )
{
fl_begin_line();
for ( float y = 0.0f; y <= 1.0f; y += 0.5f )
{
fl_vertex( x, y );
}
fl_end_line();
}

for ( float y = 0.0f; y <= 1.0f; y += 0.05f )
{
fl_begin_line();
for ( float x = 0.0f; x <= 1.0f; x += 0.5f )
{
fl_vertex( x, y );
}
fl_end_line();
}

for ( float x = 0.0f; x < 1.0f; x += 0.05f )
{
fl_begin_points();
for ( float y = 0.0f; y < 1.0f; y += 0.05f )
{
fl_vertex( x, y );
}
fl_end_points();
}

fl_pop_matrix();

}

/** translate angle /a/ into x/y coords and place the result in /X/ and /Y/ */ /** translate angle /a/ into x/y coords and place the result in /X/ and /Y/ */
void void
Panner::project_polar ( const Point *p, float *X, float *Y, float *S ) const Panner::project_polar ( const Point *p, float *X, float *Y, float *S ) const


+ 6
- 5
mixer/src/Panner.H View File

@@ -24,7 +24,7 @@
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/Fl_Choice.H> #include <FL/Fl_Choice.H>
#include <math.h> #include <math.h>
#include <FL/Fl_Image.H>
#include <vector> #include <vector>
using namespace std; using namespace std;


@@ -33,6 +33,7 @@ class Panner : public Fl_Group
Fl_Choice *_range_choice; Fl_Choice *_range_choice;
Fl_Choice *_projection_choice; Fl_Choice *_projection_choice;


Fl_Image *_bg_image[2];
void draw_grid( int,int,int,int); void draw_grid( int,int,int,int);
void draw_the_box( int, int, int, int ); void draw_the_box( int, int, int, int );


@@ -177,14 +178,14 @@ protected:
public: public:


enum { POLAR, ORTHO }; enum { POLAR, ORTHO };
float projection ( void ) const { return _projection_choice->value(); }
int projection ( void ) const { return _projection_choice->value(); }
void projection ( int v ) { _projection_choice->value(v); } void projection ( int v ) { _projection_choice->value(v); }


Panner ( int X, int Y, int W, int H, const char *L = 0 ); Panner ( int X, int Y, int W, int H, const char *L = 0 );


float range ( void ) const { return *((int*)_range_choice->mvalue()->user_data()); } float range ( void ) const { return *((int*)_range_choice->mvalue()->user_data()); }
/* void range ( float v ) { _range = v; } */
void range ( float v );


void clear_points ( void ) { _points.clear(); } void clear_points ( void ) { _points.clear(); }


@@ -193,7 +194,7 @@ public:
_points.push_back( p ); _points.push_back( p );
} }


virtual ~Panner ( ) { }
virtual ~Panner ( );


Panner::Point *point ( int i ); Panner::Point *point ( int i );




+ 50
- 0
mixer/src/Spatialization_Console.C View File

@@ -53,18 +53,68 @@ Spatialization_Console::Spatialization_Console ( void ) : Fl_Double_Window( 850,
panner->callback( cb_panner_value_handle, this ); panner->callback( cb_panner_value_handle, this );
panner->when( FL_WHEN_CHANGED ); panner->when( FL_WHEN_CHANGED );


callback( cb_window, this );
end(); end();


make_controls(); make_controls();

mixer->spatialization_console = this;
} }


Spatialization_Console::~Spatialization_Console ( ) Spatialization_Console::~Spatialization_Console ( )
{ {
// controls_by_port.clear(); // controls_by_port.clear();
mixer->spatialization_console = NULL;
}

void
Spatialization_Console::get ( Log_Entry &e ) const
{
e.add( ":range", panner->range() );
e.add( ":projection", panner->projection() );
e.add( ":shown", ((const Fl_Double_Window*)this)->shown() );
}

void
Spatialization_Console::set ( Log_Entry &e )
{
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;

e.get( i, &s, &v );

if ( ! ( strcmp( s, ":range" ) ) )
panner->range( atoi( v ) );
if ( ! ( strcmp( s, ":projection" ) ) )
panner->projection( atoi( v ) );
else if ( ! ( strcmp( s, ":shown" ) ) )
{
if ( atoi( v ) )
show();
else
hide();
}
}
} }




void
Spatialization_Console::cb_window ( Fl_Widget *w, void *v )
{
((Spatialization_Console*)v)->cb_window(w);
}

void
Spatialization_Console::cb_window ( Fl_Widget *w )
{
w->hide();
mixer->update_menu();
}



void void


+ 12
- 2
mixer/src/Spatialization_Console.H View File

@@ -21,7 +21,7 @@


#include <FL/Fl_Double_Window.H> #include <FL/Fl_Double_Window.H>
#include <Module.H> #include <Module.H>
#include "Loggable.H"


class Fl_Pack; class Fl_Pack;
class Fl_Flowpack; class Fl_Flowpack;
@@ -31,13 +31,16 @@ class Panner;
class Controller_Module; class Controller_Module;
#include <vector> #include <vector>


class Spatialization_Console : public Fl_Double_Window
class Spatialization_Console : public Loggable, public Fl_Double_Window
{ {
Panner *panner; Panner *panner;


static void cb_panner_value_handle ( Fl_Widget *w, void *v ); static void cb_panner_value_handle ( Fl_Widget *w, void *v );
void make_controls ( void ); void make_controls ( void );


static void cb_window ( Fl_Widget *w, void *v );
static void cb_window ( Fl_Widget *w );

bool _resized; bool _resized;
int _min_width; int _min_width;


@@ -46,8 +49,15 @@ class Spatialization_Console : public Fl_Double_Window
std::vector<Fl_Widget*> controls_by_port; std::vector<Fl_Widget*> controls_by_port;


protected:

virtual void get ( Log_Entry &e ) const;
virtual void set ( Log_Entry &e );

public: public:


LOG_CREATE_FUNC( Spatialization_Console );

void handle_control_changed ( Controller_Module *m ); void handle_control_changed ( Controller_Module *m );


void update ( void ); void update ( void );


+ 2
- 0
mixer/src/main.C View File

@@ -54,6 +54,7 @@
#include "Mixer_Strip.H" #include "Mixer_Strip.H"
#include "AUX_Module.H" #include "AUX_Module.H"
#include "NSM.H" #include "NSM.H"
#include "Spatialization_Console.H"


#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
@@ -159,6 +160,7 @@ main ( int argc, char **argv )
LOG_REGISTER_CREATE( Meter_Indicator_Module ); LOG_REGISTER_CREATE( Meter_Indicator_Module );
LOG_REGISTER_CREATE( Controller_Module ); LOG_REGISTER_CREATE( Controller_Module );
LOG_REGISTER_CREATE( AUX_Module ); LOG_REGISTER_CREATE( AUX_Module );
LOG_REGISTER_CREATE( Spatialization_Console );


signal( SIGPIPE, SIG_IGN ); signal( SIGPIPE, SIG_IGN );




Loading…
Cancel
Save