2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Copyright (C) 2009 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. */
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* This is the main mixer group. It contains and manages Mixer_Strips. */
|
2010-01-24 22:54:32 +01:00
|
|
|
|
#include "const.h"
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
#include "Mixer.H"
|
|
|
|
|
#include "Mixer_Strip.H"
|
|
|
|
|
|
|
|
|
|
#include <FL/Fl_Pack.H>
|
|
|
|
|
#include <FL/Fl_Scroll.H>
|
2009-12-28 06:25:28 +01:00
|
|
|
|
#include <FL/Fl_Menu_Bar.H>
|
2010-01-12 03:31:15 +01:00
|
|
|
|
#include <FL/fl_ask.H>
|
2010-01-24 03:45:53 +01:00
|
|
|
|
#include <FL/Fl.H>
|
2013-03-15 01:32:15 +01:00
|
|
|
|
#include <FL/New_Project_Dialog.H>
|
|
|
|
|
#include <FL/Fl_Flowpack.H>
|
2009-12-28 06:25:28 +01:00
|
|
|
|
#include "Project.H"
|
2013-03-15 01:32:15 +01:00
|
|
|
|
#include <FL/Fl_Menu_Settings.H>
|
|
|
|
|
#include <FL/About_Dialog.H>
|
2010-01-21 01:33:02 +01:00
|
|
|
|
#include <FL/Fl_File_Chooser.H>
|
2012-11-14 10:54:03 +01:00
|
|
|
|
#include <FL/Fl_Theme_Chooser.H>
|
2013-03-15 01:32:15 +01:00
|
|
|
|
#include <FL/Fl_Value_SliderX.H>
|
2013-06-26 07:28:51 +02:00
|
|
|
|
#include <Spatialization_Console.H>
|
2010-02-01 07:25:16 +01:00
|
|
|
|
#include "file.h"
|
2013-08-06 09:03:19 +02:00
|
|
|
|
#include "Group.H"
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "debug.h"
|
2010-01-21 01:33:02 +01:00
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/types.h>
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
#include "OSC/Endpoint.H"
|
|
|
|
|
#include <lo/lo.h>
|
2010-01-31 07:47:08 +01:00
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
#include "Controller_Module.H"
|
|
|
|
|
|
2020-11-20 03:48:41 +01:00
|
|
|
|
/* const double FEEDBACK_UPDATE_FREQ = 1.0f; */
|
|
|
|
|
const double FEEDBACK_UPDATE_FREQ = 1.0f / 30.0f;
|
2013-06-06 01:26:36 +02:00
|
|
|
|
|
2010-01-24 03:45:53 +01:00
|
|
|
|
extern char *user_config_dir;
|
2010-01-21 01:33:02 +01:00
|
|
|
|
extern char *instance_name;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2010-02-01 07:25:16 +01:00
|
|
|
|
#include "debug.h"
|
2013-05-30 03:27:43 +02:00
|
|
|
|
#include "string_util.h"
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
#include "NSM.H"
|
2013-06-06 00:58:52 +02:00
|
|
|
|
#include <FL/Fl_Tooltip.H>
|
2013-08-06 09:03:19 +02:00
|
|
|
|
#include "Chain.H"
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
|
|
|
|
extern NSM_Client *nsm;
|
|
|
|
|
|
2013-06-26 07:28:51 +02:00
|
|
|
|
Spatialization_Console *Mixer::spatialization_console = 0;
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::show_tooltip ( const char *s )
|
2013-06-06 00:58:52 +02:00
|
|
|
|
{
|
2013-06-06 01:26:36 +02:00
|
|
|
|
mixer->_status->label( s );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::hide_tooltip ( void )
|
2013-06-06 00:58:52 +02:00
|
|
|
|
{
|
2013-06-06 01:26:36 +02:00
|
|
|
|
mixer->_status->label( 0 );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
/************************/
|
|
|
|
|
/* OSC Message Handlers */
|
|
|
|
|
/************************/
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
#undef OSC_REPLY_OK
|
|
|
|
|
#undef OSC_REPLY_ERR
|
|
|
|
|
#undef OSC_REPLY
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
#define OSC_REPLY_OK() ((OSC::Endpoint*)user_data)->send( lo_message_get_source( msg ), path, 0, "OK" )
|
|
|
|
|
#define OSC_REPLY( value ) ((OSC::Endpoint*)user_data)->send( lo_message_get_source( msg ), path, value )
|
|
|
|
|
#define OSC_REPLY_ERR(errcode, value) ((OSC::Endpoint*)user_data)->send( lo_message_get_source( msg ), path,errcode, value )
|
2012-02-27 04:35:31 +01:00
|
|
|
|
#define OSC_ENDPOINT() ((OSC::Endpoint*)user_data)
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-02-27 04:35:31 +01:00
|
|
|
|
static int osc_add_strip ( const char *path, const char *, lo_arg **, int , lo_message msg, void *user_data )
|
2010-01-21 01:33:02 +01:00
|
|
|
|
{
|
|
|
|
|
OSC_DMSG();
|
|
|
|
|
|
2012-03-14 06:41:54 +01:00
|
|
|
|
Fl::lock();
|
2013-06-06 01:26:36 +02:00
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
((Mixer*)(OSC_ENDPOINT())->owner)->command_add_strip();
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-03-14 06:41:54 +01:00
|
|
|
|
Fl::unlock();
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
OSC_REPLY_OK();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
int
|
|
|
|
|
Mixer::osc_non_hello ( const char *, const char *, lo_arg **, int , lo_message msg, void * )
|
|
|
|
|
{
|
|
|
|
|
mixer->handle_hello( msg );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-02-20 10:58:46 +01:00
|
|
|
|
void
|
2013-04-09 05:56:33 +02:00
|
|
|
|
Mixer::handle_hello ( lo_message msg )
|
2012-02-20 10:58:46 +01:00
|
|
|
|
{
|
|
|
|
|
int argc = lo_message_get_argc( msg );
|
|
|
|
|
lo_arg **argv = lo_message_get_argv( msg );
|
2013-04-09 05:56:33 +02:00
|
|
|
|
|
2012-06-19 06:25:41 +02:00
|
|
|
|
if ( argc >= 4 )
|
|
|
|
|
{
|
|
|
|
|
const char *url = &argv[0]->s;
|
|
|
|
|
const char *name = &argv[1]->s;
|
|
|
|
|
const char *version = &argv[2]->s;
|
|
|
|
|
const char *id = &argv[3]->s;
|
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
MESSAGE( "Got hello from NON peer %s (%s) @ %s with ID \"%s\"", name, version, url, id );
|
|
|
|
|
|
|
|
|
|
mixer->osc_endpoint->handle_hello( id, url );
|
2012-06-19 06:25:41 +02:00
|
|
|
|
}
|
2012-02-20 10:58:46 +01:00
|
|
|
|
}
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
void
|
|
|
|
|
Mixer::say_hello ( void )
|
|
|
|
|
{
|
|
|
|
|
lo_message m = lo_message_new();
|
|
|
|
|
|
|
|
|
|
lo_message_add( m, "sssss",
|
|
|
|
|
"/non/hello",
|
|
|
|
|
osc_endpoint->url(),
|
|
|
|
|
APP_NAME,
|
|
|
|
|
VERSION,
|
|
|
|
|
instance_name );
|
|
|
|
|
|
|
|
|
|
nsm->broadcast( m );
|
|
|
|
|
|
|
|
|
|
lo_message_free( m );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
static
|
|
|
|
|
Fl_Menu_Item *
|
|
|
|
|
find_item( Fl_Menu_ *menu, const char *path )
|
|
|
|
|
{
|
|
|
|
|
return const_cast<Fl_Menu_Item*>(menu->find_item( path ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::sm_active ( bool b )
|
|
|
|
|
{
|
|
|
|
|
sm_blinker->value( b );
|
|
|
|
|
sm_blinker->tooltip( nsm->session_manager_name() );
|
|
|
|
|
|
|
|
|
|
if ( b )
|
|
|
|
|
{
|
|
|
|
|
find_item( menubar, "&Project/&Open" )->deactivate();
|
|
|
|
|
find_item( menubar, "&Project/&New" )->deactivate();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-12 03:31:15 +01:00
|
|
|
|
|
2012-03-03 03:02:23 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::redraw_windows ( void )
|
|
|
|
|
{
|
|
|
|
|
window()->redraw();
|
|
|
|
|
|
|
|
|
|
if ( Fl::first_window() )
|
|
|
|
|
for ( Fl_Window *w = Fl::first_window(); ( w = Fl::next_window( w ) ); )
|
|
|
|
|
w->redraw();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-14 02:21:57 +02:00
|
|
|
|
void Mixer::command_new ( void )
|
|
|
|
|
{
|
|
|
|
|
DMESSAGE( "New project" );
|
|
|
|
|
|
2013-07-31 06:36:35 +02:00
|
|
|
|
char *default_path = read_line( user_config_dir, "default_path" );
|
2013-05-14 02:21:57 +02:00
|
|
|
|
|
2013-07-31 06:36:35 +02:00
|
|
|
|
char *result_path = default_path;
|
|
|
|
|
|
|
|
|
|
char *path = new_project_chooser( &result_path );
|
2013-05-14 02:21:57 +02:00
|
|
|
|
|
|
|
|
|
if ( path )
|
|
|
|
|
{
|
|
|
|
|
if ( ! Project::create( path, NULL ) )
|
|
|
|
|
fl_alert( "Error creating project!" );
|
|
|
|
|
free( path );
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-14 03:02:01 +02:00
|
|
|
|
load_project_settings();
|
|
|
|
|
|
2013-05-14 02:21:57 +02:00
|
|
|
|
update_menu();
|
|
|
|
|
|
2013-07-31 06:36:35 +02:00
|
|
|
|
if ( result_path != default_path )
|
|
|
|
|
free(default_path);
|
|
|
|
|
|
|
|
|
|
if ( result_path )
|
2013-05-14 02:21:57 +02:00
|
|
|
|
{
|
2013-07-31 06:36:35 +02:00
|
|
|
|
write_line( user_config_dir, "default_path", result_path );
|
|
|
|
|
free( result_path );
|
2013-05-14 02:21:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-03 03:02:23 +01:00
|
|
|
|
|
2010-01-12 03:31:15 +01:00
|
|
|
|
void Mixer::cb_menu(Fl_Widget* o) {
|
|
|
|
|
Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o;
|
|
|
|
|
|
|
|
|
|
/* const Fl_Menu_Item *mi = &menu->menu()[menu->value()]; */
|
|
|
|
|
|
|
|
|
|
char picked[256];
|
|
|
|
|
// const char *picked = menu->text();
|
|
|
|
|
|
|
|
|
|
menu->item_pathname( picked, sizeof( picked ) );
|
|
|
|
|
|
2013-05-14 03:02:01 +02:00
|
|
|
|
DMESSAGE( "Picked %s", picked );
|
|
|
|
|
|
2010-01-12 03:31:15 +01:00
|
|
|
|
if (! strcmp( picked, "&Project/&New") )
|
|
|
|
|
{
|
2013-05-14 02:21:57 +02:00
|
|
|
|
command_new();
|
2010-01-12 03:31:15 +01:00
|
|
|
|
}
|
2010-01-23 19:22:33 +01:00
|
|
|
|
else if (! strcmp( picked, "&Project/&Open" ) )
|
|
|
|
|
{
|
|
|
|
|
char *path = NULL;
|
|
|
|
|
|
|
|
|
|
// read_line( user_config_dir, "default_path", &path );
|
|
|
|
|
|
2012-02-27 04:35:31 +01:00
|
|
|
|
const char *name = fl_dir_chooser( "Open Project", path );
|
2010-01-23 19:22:33 +01:00
|
|
|
|
|
|
|
|
|
free( path );
|
|
|
|
|
|
|
|
|
|
mixer->hide();
|
|
|
|
|
|
|
|
|
|
if ( int err = Project::open( name ) )
|
|
|
|
|
{
|
|
|
|
|
fl_alert( "Error opening project: %s", Project::errstr( err ) );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 22:02:26 +01:00
|
|
|
|
update_menu();
|
|
|
|
|
|
2010-01-23 19:22:33 +01:00
|
|
|
|
mixer->show();
|
|
|
|
|
}
|
2010-01-12 03:31:15 +01:00
|
|
|
|
else if (! strcmp( picked, "&Project/&Save" ) )
|
|
|
|
|
{
|
2010-01-31 21:42:14 +01:00
|
|
|
|
command_save();
|
2010-01-12 03:31:15 +01:00
|
|
|
|
}
|
2010-01-20 07:54:35 +01:00
|
|
|
|
else if (! strcmp( picked, "&Project/&Quit") )
|
2010-01-12 06:31:02 +01:00
|
|
|
|
{
|
2010-01-31 21:42:14 +01:00
|
|
|
|
command_quit();
|
2010-01-12 06:31:02 +01:00
|
|
|
|
}
|
2010-01-12 03:31:15 +01:00
|
|
|
|
else if ( !strcmp( picked, "&Mixer/&Add Strip" ) )
|
|
|
|
|
{
|
2010-01-31 21:42:14 +01:00
|
|
|
|
command_add_strip();
|
2010-01-12 03:31:15 +01:00
|
|
|
|
}
|
2010-01-23 06:11:00 +01:00
|
|
|
|
else if ( !strcmp( picked, "&Mixer/Add &N Strips" ) )
|
|
|
|
|
{
|
|
|
|
|
const char *s = fl_input( "Enter number of strips to add" );
|
|
|
|
|
|
|
|
|
|
if ( s )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = atoi( s ); i > 0; i-- )
|
2010-01-31 21:42:14 +01:00
|
|
|
|
command_add_strip();
|
2010-01-23 06:11:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-31 19:51:55 +01:00
|
|
|
|
else if ( !strcmp( picked, "&Mixer/&Import Strip" ) )
|
|
|
|
|
{
|
|
|
|
|
const char *s = fl_file_chooser( "Export strip to filename:", "*.strip", NULL, 0 );
|
|
|
|
|
|
|
|
|
|
if ( s )
|
|
|
|
|
{
|
|
|
|
|
if (! Mixer_Strip::import_strip( s ) )
|
|
|
|
|
fl_alert( "%s", "Failed to import strip!" );
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-06 01:26:36 +02:00
|
|
|
|
else if ( ! strcmp( picked, "&Project/Se&ttings/Learn/By Strip Name" ) )
|
|
|
|
|
{
|
|
|
|
|
Controller_Module::learn_by_number = false;
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( picked, "&Project/Se&ttings/Learn/By Strip Number" ) )
|
|
|
|
|
{
|
|
|
|
|
Controller_Module::learn_by_number = true;
|
|
|
|
|
}
|
2013-07-09 06:53:20 +02:00
|
|
|
|
else if ( ! strcmp( picked, "&Remote Control/Start Learning" ) )
|
2013-06-06 00:58:52 +02:00
|
|
|
|
{
|
|
|
|
|
Controller_Module::learn_mode( true );
|
2013-06-06 01:26:36 +02:00
|
|
|
|
tooltip( "Now in learn mode. Click on a highlighted control to teach it something." );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
redraw();
|
|
|
|
|
}
|
2013-07-09 06:53:20 +02:00
|
|
|
|
else if ( ! strcmp( picked, "&Remote Control/Stop Learning" ) )
|
2013-06-06 00:58:52 +02:00
|
|
|
|
{
|
|
|
|
|
Controller_Module::learn_mode( false );
|
2013-06-06 01:26:36 +02:00
|
|
|
|
tooltip( "Learning complete" );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
redraw();
|
|
|
|
|
}
|
2013-07-09 06:53:20 +02:00
|
|
|
|
else if ( !strcmp( picked, "&Remote Control/Send State" ) )
|
|
|
|
|
{
|
|
|
|
|
send_feedback();
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( picked, "&Remote Control/Clear All Mappings" ) )
|
2013-06-06 01:26:36 +02:00
|
|
|
|
{
|
2013-07-14 23:12:44 +02:00
|
|
|
|
if ( 1 == fl_choice( "This will remove all mappings, are you sure?", "No", "Yes", NULL ) )
|
2013-06-06 01:26:36 +02:00
|
|
|
|
{
|
|
|
|
|
command_clear_mappings();
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-30 03:27:43 +02:00
|
|
|
|
else if ( !strcmp( picked, "&Mixer/Paste" ) )
|
|
|
|
|
{
|
|
|
|
|
Fl::paste(*this);
|
|
|
|
|
}
|
2013-05-14 03:02:01 +02:00
|
|
|
|
else if (! strcmp( picked, "&Project/Se&ttings/&Rows/One") )
|
2010-01-20 07:54:35 +01:00
|
|
|
|
{
|
|
|
|
|
rows( 1 );
|
|
|
|
|
}
|
2013-05-14 03:02:01 +02:00
|
|
|
|
else if (! strcmp( picked, "&Project/Se&ttings/&Rows/Two") )
|
2010-01-20 07:54:35 +01:00
|
|
|
|
{
|
|
|
|
|
rows( 2 );
|
|
|
|
|
}
|
2013-05-14 03:02:01 +02:00
|
|
|
|
else if (! strcmp( picked, "&Project/Se&ttings/&Rows/Three") )
|
2010-01-20 07:54:35 +01:00
|
|
|
|
{
|
|
|
|
|
rows( 3 );
|
|
|
|
|
}
|
2013-07-22 05:20:42 +02:00
|
|
|
|
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();
|
|
|
|
|
}
|
2013-05-14 03:02:01 +02:00
|
|
|
|
else if (! strcmp( picked, "&Project/Se&ttings/Make Default") )
|
|
|
|
|
{
|
|
|
|
|
save_default_project_settings();
|
|
|
|
|
}
|
2012-04-11 08:59:12 +02:00
|
|
|
|
else if (! strcmp( picked, "&View/&Theme") )
|
2010-01-24 03:45:53 +01:00
|
|
|
|
{
|
2012-04-11 08:59:12 +02:00
|
|
|
|
fl_theme_chooser();
|
2012-03-02 05:23:23 +01:00
|
|
|
|
}
|
2013-09-09 04:22:58 +02:00
|
|
|
|
else if ( ! strcmp( picked, "&Mixer/Swap &Fader//Signal View" ) )
|
|
|
|
|
{
|
|
|
|
|
command_toggle_fader_view();
|
|
|
|
|
}
|
2010-01-24 22:54:32 +01:00
|
|
|
|
else if ( ! strcmp( picked, "&Help/&About" ) )
|
|
|
|
|
{
|
2013-04-14 06:41:39 +02:00
|
|
|
|
About_Dialog ab( PIXMAP_PATH "/non-mixer/icon-256x256.png" );
|
2010-01-20 07:54:35 +01:00
|
|
|
|
|
2010-02-02 04:54:09 +01:00
|
|
|
|
ab.logo_box->label( VERSION );
|
|
|
|
|
|
2013-03-11 01:52:15 +01:00
|
|
|
|
ab.title->label( "Non Mixer" );
|
2010-02-02 04:54:09 +01:00
|
|
|
|
|
2013-03-11 01:52:15 +01:00
|
|
|
|
ab.copyright->label( "Copyright (C) 2008-2013 Jonathan Moore Liles" );
|
2010-02-02 04:54:09 +01:00
|
|
|
|
ab.credits->label(
|
2013-03-11 01:52:15 +01:00
|
|
|
|
"Non Mixer was written from scratch by\n"
|
2010-02-02 04:54:09 +01:00
|
|
|
|
"Jonathan Moore Liles for his own use\n"
|
|
|
|
|
"(see the manual).\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Nobody planned. Nobody helped.\n"
|
|
|
|
|
"You can help now by donating time, money,\n"
|
|
|
|
|
"and/or replacing the rest of Linux Audio\n"
|
|
|
|
|
"with fast, light, reliable alternatives.\n" );
|
|
|
|
|
|
2013-03-11 01:52:15 +01:00
|
|
|
|
ab.website_url->label( "http://non.tuxfamily.org" );
|
2010-02-02 04:54:09 +01:00
|
|
|
|
|
2010-01-24 22:54:32 +01:00
|
|
|
|
ab.run();
|
|
|
|
|
}
|
2010-01-24 23:35:36 +01:00
|
|
|
|
else if ( !strcmp( picked, "&Help/&Manual" ))
|
|
|
|
|
{
|
|
|
|
|
char *pat;
|
|
|
|
|
|
2010-02-01 04:26:12 +01:00
|
|
|
|
asprintf( &pat, "file://%s.html", DOCUMENT_PATH "/non-mixer/MANUAL" );
|
2010-01-24 23:35:36 +01:00
|
|
|
|
|
|
|
|
|
open_url( pat );
|
|
|
|
|
|
|
|
|
|
free( pat );
|
|
|
|
|
}
|
2010-01-12 03:31:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Mixer::cb_menu(Fl_Widget* o, void* v) {
|
|
|
|
|
((Mixer*)(v))->cb_menu(o);
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-18 04:26:04 +02:00
|
|
|
|
void Mixer::update_frequency ( float v )
|
|
|
|
|
{
|
|
|
|
|
_update_interval = 1.0f / v;
|
|
|
|
|
|
2013-06-18 04:54:39 +02:00
|
|
|
|
Fl::remove_timeout( &Mixer::update_cb, this );
|
2013-06-18 04:26:04 +02:00
|
|
|
|
Fl::add_timeout( _update_interval, &Mixer::update_cb, this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::update_cb ( void *v )
|
|
|
|
|
{
|
|
|
|
|
((Mixer*)v)->update_cb();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::update_cb ( void )
|
|
|
|
|
{
|
|
|
|
|
Fl::repeat_timeout( _update_interval, &Mixer::update_cb, this );
|
|
|
|
|
|
2020-11-07 03:35:55 +01:00
|
|
|
|
/* if ( active_r() && visible_r() ) */
|
2013-06-18 04:26:04 +02:00
|
|
|
|
{
|
2013-06-18 04:54:39 +02:00
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
((Mixer_Strip*)mixer_strips->child(i))->update();
|
|
|
|
|
}
|
2013-06-18 04:26:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-04-10 02:51:47 +02:00
|
|
|
|
static void
|
|
|
|
|
progress_cb ( int p, void *v )
|
|
|
|
|
{
|
|
|
|
|
static int oldp = 0;
|
|
|
|
|
|
|
|
|
|
if ( p != oldp )
|
|
|
|
|
{
|
|
|
|
|
oldp = p;
|
|
|
|
|
if ( nsm )
|
|
|
|
|
{
|
|
|
|
|
nsm->progress( p / 100.0f );
|
|
|
|
|
}
|
|
|
|
|
Fl::check();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-14 03:02:01 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::save_default_project_settings ( void )
|
|
|
|
|
{
|
|
|
|
|
char path[256];
|
|
|
|
|
snprintf( path, sizeof( path ), "%s/%s", user_config_dir, ".default_project_settings" );
|
|
|
|
|
|
|
|
|
|
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Project/Se&ttings" ), path );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::load_default_project_settings ( void )
|
|
|
|
|
{
|
|
|
|
|
char path[256];
|
|
|
|
|
snprintf( path, sizeof( path ), "%s/%s", user_config_dir, ".default_project_settings" );
|
|
|
|
|
|
|
|
|
|
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Project/Se&ttings" ), path );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::reset_project_settings ( void )
|
|
|
|
|
{
|
|
|
|
|
rows(1);
|
|
|
|
|
|
|
|
|
|
load_default_project_settings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::save_project_settings ( void )
|
|
|
|
|
{
|
|
|
|
|
if ( ! Project::open() )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Project/Se&ttings" ), "options" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::load_project_settings ( void )
|
|
|
|
|
{
|
|
|
|
|
reset_project_settings();
|
|
|
|
|
|
2013-06-25 02:41:15 +02:00
|
|
|
|
// if ( Project::open() )
|
2013-05-14 03:02:01 +02:00
|
|
|
|
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Project/Se&ttings" ), "options" );
|
|
|
|
|
|
|
|
|
|
update_menu();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
|
|
|
|
|
Fl_Group( X, Y, W, H, L )
|
|
|
|
|
{
|
2012-03-05 03:02:01 +01:00
|
|
|
|
Loggable::dirty_callback( &Mixer::handle_dirty, this );
|
2013-04-10 02:51:47 +02:00
|
|
|
|
Loggable::progress_callback( progress_cb, NULL );
|
2012-03-05 03:02:01 +01:00
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
Fl_Tooltip::hoverdelay( 0 );
|
|
|
|
|
Fl_Tooltip::delay( 0 );
|
2013-06-06 01:26:36 +02:00
|
|
|
|
fl_show_tooltip = &Mixer::show_tooltip;
|
|
|
|
|
fl_hide_tooltip = &Mixer::hide_tooltip;
|
2013-06-06 00:58:52 +02:00
|
|
|
|
/* Fl_Tooltip::size( 11 ); */
|
|
|
|
|
/* Fl_Tooltip::textcolor( FL_FOREGROUND_COLOR ); */
|
|
|
|
|
/* Fl_Tooltip::color( fl_color_add_alpha( FL_DARK1, 0 ) ); */
|
|
|
|
|
// fl_tooltip_docked = 1;
|
|
|
|
|
|
2013-08-06 09:03:19 +02:00
|
|
|
|
// _groups.resize(16);
|
|
|
|
|
|
2010-01-20 07:54:35 +01:00
|
|
|
|
_rows = 1;
|
2013-06-25 02:41:15 +02:00
|
|
|
|
_strip_height = 0;
|
2012-06-20 09:55:58 +02:00
|
|
|
|
box( FL_FLAT_BOX );
|
2009-12-26 01:21:40 +01:00
|
|
|
|
labelsize( 96 );
|
2012-04-14 23:11:58 +02:00
|
|
|
|
{ Fl_Group *o = new Fl_Group( X, Y, W, 24 );
|
|
|
|
|
|
|
|
|
|
{ Fl_Menu_Bar *o = menubar = new Fl_Menu_Bar( X, Y, W, 24 );
|
|
|
|
|
o->add( "&Project/&New" );
|
|
|
|
|
o->add( "&Project/&Open" );
|
2013-05-14 03:02:01 +02:00
|
|
|
|
o->add( "&Project/Se&ttings/&Rows/One", '1', 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
|
|
|
|
|
o->add( "&Project/Se&ttings/&Rows/Two", '2', 0, 0, FL_MENU_RADIO );
|
|
|
|
|
o->add( "&Project/Se&ttings/&Rows/Three", '3', 0, 0, FL_MENU_RADIO );
|
2013-06-06 01:26:36 +02:00
|
|
|
|
o->add( "&Project/Se&ttings/Learn/By Strip Number", 0, 0, 0, FL_MENU_RADIO );
|
|
|
|
|
o->add( "&Project/Se&ttings/Learn/By Strip Name", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
|
2013-07-09 06:53:20 +02:00
|
|
|
|
o->add( "&Project/Se&ttings/Make Default", 0,0,0);
|
2012-04-14 23:11:58 +02:00
|
|
|
|
o->add( "&Project/&Save", FL_CTRL + 's', 0, 0 );
|
|
|
|
|
o->add( "&Project/&Quit", FL_CTRL + 'q', 0, 0 );
|
|
|
|
|
o->add( "&Mixer/&Add Strip", 'a', 0, 0 );
|
|
|
|
|
o->add( "&Mixer/Add &N Strips" );
|
|
|
|
|
o->add( "&Mixer/&Import Strip" );
|
2013-05-30 03:27:43 +02:00
|
|
|
|
o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 );
|
2013-07-22 05:20:42 +02:00
|
|
|
|
o->add( "&Mixer/&Spatialization Console", FL_F + 8, 0, 0, FL_MENU_TOGGLE );
|
2013-09-09 04:22:58 +02:00
|
|
|
|
o->add( "&Mixer/Swap &Fader//Signal View", FL_ALT + 'f', 0, 0, FL_MENU_TOGGLE );
|
|
|
|
|
// o->add( "&Mixer/&Signal View", FL_ALT + 's', 0, 0, FL_MENU_TOGGLE );
|
2013-07-09 06:53:20 +02:00
|
|
|
|
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/Send State" );
|
|
|
|
|
o->add( "&Remote Control/Clear All Mappings", 0, 0, 0 );
|
2012-04-14 23:11:58 +02:00
|
|
|
|
o->add( "&View/&Theme", 0, 0, 0 );
|
|
|
|
|
o->add( "&Help/&Manual" );
|
|
|
|
|
o->add( "&Help/&About" );
|
|
|
|
|
o->callback( cb_menu, this );
|
|
|
|
|
}
|
|
|
|
|
{ Fl_Box *o = project_name = new Fl_Box( X + 150, Y, W, 24 );
|
|
|
|
|
o->labelfont( FL_HELVETICA_ITALIC );
|
|
|
|
|
o->label( 0 );
|
|
|
|
|
o->align( FL_ALIGN_INSIDE | FL_ALIGN_CENTER );
|
|
|
|
|
o->labeltype( FL_SHADOW_LABEL );
|
|
|
|
|
Fl_Group::current()->resizable( o );
|
|
|
|
|
}
|
|
|
|
|
{ sm_blinker = new Fl_Button( ( X + W) - 37, Y + 4, 35, 15, "SM");
|
|
|
|
|
sm_blinker->box(FL_ROUNDED_BOX);
|
|
|
|
|
sm_blinker->down_box(FL_ROUNDED_BOX);
|
|
|
|
|
sm_blinker->color(FL_DARK2);
|
|
|
|
|
sm_blinker->selection_color((Fl_Color)93);
|
|
|
|
|
sm_blinker->labeltype(FL_NORMAL_LABEL);
|
|
|
|
|
sm_blinker->labelfont(3);
|
|
|
|
|
sm_blinker->labelsize(14);
|
|
|
|
|
sm_blinker->labelcolor(FL_DARK3);
|
|
|
|
|
sm_blinker->align(Fl_Align(FL_ALIGN_CENTER));
|
|
|
|
|
sm_blinker->when(FL_WHEN_RELEASE);
|
|
|
|
|
sm_blinker->deactivate();
|
|
|
|
|
|
|
|
|
|
} // Fl_Blink_Button* sm_blinker
|
|
|
|
|
o->end();
|
2010-02-01 03:54:15 +01:00
|
|
|
|
}
|
2013-06-06 01:26:36 +02:00
|
|
|
|
{ Fl_Scroll *o = scroll = new Fl_Scroll( X, Y + 24, W, H - ( 100 ) );
|
2012-06-20 09:55:58 +02:00
|
|
|
|
o->box( FL_FLAT_BOX );
|
2010-01-20 07:54:35 +01:00
|
|
|
|
// o->type( Fl_Scroll::HORIZONTAL_ALWAYS );
|
|
|
|
|
// o->box( Fl_Scroll::BOTH );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
2013-06-06 00:58:52 +02:00
|
|
|
|
Fl_Flowpack *o = mixer_strips = new Fl_Flowpack( X, Y + 24, W, H - ( 18*2 + 24 ));
|
2012-06-20 09:55:58 +02:00
|
|
|
|
// label( "Non-Mixer" );
|
2009-12-26 01:21:40 +01:00
|
|
|
|
align( (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE) );
|
2013-06-25 02:41:15 +02:00
|
|
|
|
o->flow( false );
|
2012-06-20 09:55:58 +02:00
|
|
|
|
o->box( FL_FLAT_BOX );
|
2020-11-03 03:03:54 +01:00
|
|
|
|
o->color( fl_darker(FL_BACKGROUND_COLOR ));
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->type( Fl_Pack::HORIZONTAL );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
o->hspacing( 2 );
|
2010-01-20 07:54:35 +01:00
|
|
|
|
o->vspacing( 2 );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->end();
|
|
|
|
|
Fl_Group::current()->resizable( o );
|
|
|
|
|
}
|
|
|
|
|
o->end();
|
|
|
|
|
Fl_Group::current()->resizable( o );
|
|
|
|
|
}
|
2013-06-06 00:58:52 +02:00
|
|
|
|
{ Fl_Box *o = _status = new Fl_Box( X, Y + H - 18, W, 18 );
|
|
|
|
|
o->align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
|
|
|
|
|
o->labelsize( 10 );
|
|
|
|
|
o->box( FL_FLAT_BOX );
|
|
|
|
|
o->color( FL_DARK1 );
|
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
|
end();
|
|
|
|
|
|
2013-09-08 01:58:16 +02:00
|
|
|
|
resize( X,Y,W,H );
|
2013-07-14 23:36:44 +02:00
|
|
|
|
|
2020-11-07 03:35:55 +01:00
|
|
|
|
update_frequency( 24 );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
|
2010-01-31 22:02:26 +01:00
|
|
|
|
update_menu();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2010-01-24 03:45:53 +01:00
|
|
|
|
load_options();
|
2012-02-08 19:39:03 +01:00
|
|
|
|
}
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
/* translate message addressed to strip number to appropriate strip */
|
|
|
|
|
int
|
|
|
|
|
Mixer::osc_strip_by_number ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data )
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
char *rem;
|
2013-06-06 01:26:36 +02:00
|
|
|
|
char *client_name;
|
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
OSC::Endpoint *ep = (OSC::Endpoint*)user_data;
|
|
|
|
|
|
2017-03-28 08:16:09 +02:00
|
|
|
|
if ( 3 != sscanf( path, "%m[^/]/strip#/%d/%m[^\n]", &client_name, &n, &rem ) )
|
2013-06-06 00:58:52 +02:00
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
Mixer_Strip *o = mixer->track_by_number( n );
|
|
|
|
|
|
|
|
|
|
if ( ! o )
|
|
|
|
|
{
|
|
|
|
|
DMESSAGE( "No strip by number %i", n );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *new_path;
|
2020-09-25 08:16:27 +02:00
|
|
|
|
|
|
|
|
|
char *stripname = escape_url( o->name() );
|
|
|
|
|
|
|
|
|
|
asprintf( &new_path, "%s/strip/%s/%s", client_name, stripname, rem );
|
|
|
|
|
|
|
|
|
|
free( stripname );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
|
2020-09-25 08:16:27 +02:00
|
|
|
|
/* DMESSAGE( "Forwarding by-number OSC path: %s === %s", path, new_path ); */
|
2013-06-06 00:58:52 +02:00
|
|
|
|
|
|
|
|
|
free( rem );
|
|
|
|
|
|
|
|
|
|
lo_send_message( ep->address(), new_path, msg );
|
|
|
|
|
|
|
|
|
|
free( new_path );
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::load_translations ( void )
|
|
|
|
|
{
|
|
|
|
|
FILE *fp = fopen( "mappings", "r" );
|
|
|
|
|
|
|
|
|
|
if ( ! fp )
|
|
|
|
|
{
|
|
|
|
|
WARNING( "Error opening mappings file for reading" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *to;
|
|
|
|
|
char *from;
|
|
|
|
|
|
2017-03-28 08:16:09 +02:00
|
|
|
|
while ( 2 == fscanf( fp, "%m[^|> ] |> %m[^ \n]\n", &from, &to ) )
|
2013-06-06 01:26:36 +02:00
|
|
|
|
{
|
|
|
|
|
osc_endpoint->add_translation( from, to );
|
|
|
|
|
free(from);
|
|
|
|
|
free(to);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose( fp );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::save_translations ( void )
|
|
|
|
|
{
|
|
|
|
|
FILE *fp = fopen( "mappings", "w" );
|
|
|
|
|
|
|
|
|
|
if ( ! fp )
|
|
|
|
|
{
|
|
|
|
|
WARNING( "Error opening mappings file for writing" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < osc_endpoint->ntranslations(); i++ )
|
|
|
|
|
{
|
|
|
|
|
const char *to;
|
|
|
|
|
const char *from;
|
|
|
|
|
|
|
|
|
|
if ( osc_endpoint->get_translation( i, &to, &from ) )
|
|
|
|
|
{
|
|
|
|
|
fprintf( fp, "%s |> %s\n", to, from );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose( fp );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
int
|
2012-02-08 19:39:03 +01:00
|
|
|
|
Mixer::init_osc ( const char *osc_port )
|
|
|
|
|
{
|
2010-01-21 01:33:02 +01:00
|
|
|
|
osc_endpoint = new OSC::Endpoint();
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-02-24 05:34:07 +01:00
|
|
|
|
if ( int r = osc_endpoint->init( LO_UDP, osc_port ) )
|
2010-01-21 01:33:02 +01:00
|
|
|
|
return r;
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
osc_endpoint->owner = this;
|
|
|
|
|
|
|
|
|
|
printf( "OSC=%s\n", osc_endpoint->url() );
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
osc_endpoint->add_method( "/non/hello", "ssss", &Mixer::osc_non_hello, osc_endpoint, "" );
|
|
|
|
|
|
|
|
|
|
//
|
2012-02-27 04:35:31 +01:00
|
|
|
|
osc_endpoint->add_method( "/non/mixer/add_strip", "", osc_add_strip, osc_endpoint, "" );
|
2012-02-09 00:39:03 +01:00
|
|
|
|
|
2012-03-14 06:41:54 +01:00
|
|
|
|
osc_endpoint->start();
|
2012-02-20 10:58:46 +01:00
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
osc_endpoint->add_method( NULL, NULL, osc_strip_by_number, osc_endpoint, "");
|
|
|
|
|
|
2012-02-20 10:58:46 +01:00
|
|
|
|
return 0;
|
2010-01-21 01:33:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
Mixer::~Mixer ( )
|
|
|
|
|
{
|
2010-01-16 09:00:47 +01:00
|
|
|
|
DMESSAGE( "Destroying mixer" );
|
2010-01-23 19:22:33 +01:00
|
|
|
|
|
2010-01-24 03:45:53 +01:00
|
|
|
|
save_options();
|
|
|
|
|
|
2013-06-18 04:54:39 +02:00
|
|
|
|
Fl::remove_timeout( &Mixer::update_cb, this );
|
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
Fl::remove_timeout( &Mixer::send_feedback_cb, this );
|
|
|
|
|
|
|
|
|
|
/* FIXME: teardown */
|
2010-01-23 19:22:33 +01:00
|
|
|
|
mixer_strips->clear();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-06 09:03:19 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::add_group ( Group *g )
|
|
|
|
|
{
|
|
|
|
|
groups.push_back( g );
|
|
|
|
|
|
|
|
|
|
for ( int i = mixer_strips->children(); i--; )
|
|
|
|
|
((Mixer_Strip*)mixer_strips->child(i))->update_group_choice();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::remove_group ( Group *g )
|
|
|
|
|
{
|
|
|
|
|
groups.remove(g);
|
|
|
|
|
|
|
|
|
|
for ( int i = mixer_strips->children(); i--; )
|
|
|
|
|
((Mixer_Strip*)mixer_strips->child(i))->update_group_choice();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
void Mixer::resize ( int X, int Y, int W, int H )
|
|
|
|
|
{
|
2009-12-26 01:21:40 +01:00
|
|
|
|
Fl_Group::resize( X, Y, W, H );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
scroll->resize( X, Y + 24, W, H - 24 - 18 );
|
2010-01-20 07:54:35 +01:00
|
|
|
|
|
2013-09-08 01:58:16 +02:00
|
|
|
|
mixer_strips->resize( X, Y + 24, W, H - (18*2) - 24 );
|
|
|
|
|
|
2010-01-20 07:54:35 +01:00
|
|
|
|
rows( _rows );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Mixer::add ( Mixer_Strip *ms )
|
|
|
|
|
{
|
|
|
|
|
MESSAGE( "Add mixer strip \"%s\"", ms->name() );
|
|
|
|
|
|
|
|
|
|
mixer_strips->add( ms );
|
|
|
|
|
|
2013-06-25 02:17:15 +02:00
|
|
|
|
ms->size( ms->w(), _strip_height );
|
2020-10-24 07:06:32 +02:00
|
|
|
|
/* ms->redraw(); */
|
2020-10-11 05:10:16 +02:00
|
|
|
|
ms->take_focus();
|
|
|
|
|
|
|
|
|
|
renumber_strips();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
int
|
|
|
|
|
Mixer::find_strip ( const Mixer_Strip *m ) const
|
|
|
|
|
{
|
|
|
|
|
return mixer_strips->find( m );
|
|
|
|
|
}
|
2013-06-25 02:17:15 +02:00
|
|
|
|
|
2010-01-12 06:31:02 +01:00
|
|
|
|
void
|
|
|
|
|
Mixer::quit ( void )
|
|
|
|
|
{
|
|
|
|
|
/* TODO: save project? */
|
|
|
|
|
|
|
|
|
|
while ( Fl::first_window() ) Fl::first_window()->hide();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-11 05:10:16 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::renumber_strips ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = mixer_strips->children(); i--; )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *o = (Mixer_Strip*)mixer_strips->child(i);
|
|
|
|
|
|
|
|
|
|
o->number( find_strip( o ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-12 06:31:02 +01:00
|
|
|
|
|
2010-01-12 06:23:40 +01:00
|
|
|
|
void
|
|
|
|
|
Mixer::insert ( Mixer_Strip *ms, Mixer_Strip *before )
|
|
|
|
|
{
|
2013-06-25 02:17:15 +02:00
|
|
|
|
// mixer_strips->remove( ms );
|
2010-01-12 06:23:40 +01:00
|
|
|
|
mixer_strips->insert( *ms, before );
|
2020-10-11 05:10:16 +02:00
|
|
|
|
renumber_strips();
|
2013-06-25 02:41:15 +02:00
|
|
|
|
// scroll->redraw();
|
2010-01-12 06:23:40 +01:00
|
|
|
|
}
|
|
|
|
|
void
|
|
|
|
|
Mixer::insert ( Mixer_Strip *ms, int i )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *before = (Mixer_Strip*)mixer_strips->child( i );
|
|
|
|
|
|
|
|
|
|
insert( ms, before);
|
2020-10-11 05:10:16 +02:00
|
|
|
|
renumber_strips();
|
2010-01-12 06:23:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::move_left ( Mixer_Strip *ms )
|
|
|
|
|
{
|
|
|
|
|
int i = mixer_strips->find( ms );
|
|
|
|
|
|
|
|
|
|
if ( i > 0 )
|
|
|
|
|
insert( ms, i - 1 );
|
2013-06-25 02:41:15 +02:00
|
|
|
|
|
2020-10-11 05:10:16 +02:00
|
|
|
|
renumber_strips();
|
2013-06-25 02:41:15 +02:00
|
|
|
|
/* FIXME: do better */
|
|
|
|
|
mixer_strips->redraw();
|
2010-01-12 06:23:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::move_right ( Mixer_Strip *ms )
|
|
|
|
|
{
|
|
|
|
|
int i = mixer_strips->find( ms );
|
|
|
|
|
|
|
|
|
|
if ( i < mixer_strips->children() - 1 )
|
|
|
|
|
insert( ms, i + 2 );
|
2013-06-25 02:41:15 +02:00
|
|
|
|
|
2020-10-11 05:10:16 +02:00
|
|
|
|
renumber_strips();
|
|
|
|
|
|
2013-06-25 02:41:15 +02:00
|
|
|
|
/* FIXME: do better */
|
|
|
|
|
mixer_strips->redraw();
|
2010-01-12 06:23:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
void Mixer::remove ( Mixer_Strip *ms )
|
|
|
|
|
{
|
|
|
|
|
MESSAGE( "Remove mixer strip \"%s\"", ms->name() );
|
|
|
|
|
|
|
|
|
|
mixer_strips->remove( ms );
|
2013-08-06 09:03:19 +02:00
|
|
|
|
|
2012-02-09 00:36:25 +01:00
|
|
|
|
if ( parent() )
|
|
|
|
|
parent()->redraw();
|
2020-10-11 05:10:16 +02:00
|
|
|
|
|
|
|
|
|
renumber_strips();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 07:45:55 +02:00
|
|
|
|
|
|
|
|
|
Mixer_Strip *
|
|
|
|
|
Mixer::event_inside ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = mixer_strips->children(); i--; )
|
|
|
|
|
if ( Fl::event_inside( mixer_strips->child(i) ) )
|
|
|
|
|
return (Mixer_Strip*)mixer_strips->child(i);
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
bool
|
|
|
|
|
Mixer::contains ( Mixer_Strip *ms )
|
|
|
|
|
{
|
|
|
|
|
return ms->parent() == mixer_strips;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-04 14:45:56 +01:00
|
|
|
|
/* set the ideal number of rows... All may not actually fit. */
|
2010-01-20 07:54:35 +01:00
|
|
|
|
void
|
2010-02-04 14:45:56 +01:00
|
|
|
|
Mixer::rows ( int ideal_rows )
|
2010-01-20 07:54:35 +01:00
|
|
|
|
{
|
2013-08-06 09:03:19 +02:00
|
|
|
|
int sh = 0;
|
2010-01-20 07:54:35 +01:00
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
int actual_rows = 1;
|
2010-02-04 14:45:56 +01:00
|
|
|
|
|
2013-06-25 02:41:15 +02:00
|
|
|
|
/* calculate how many rows will actually fit */
|
|
|
|
|
int can_fit = scroll->h() / ( Mixer_Strip::min_h() );
|
|
|
|
|
|
|
|
|
|
actual_rows = can_fit > 0 ? can_fit : 1;
|
|
|
|
|
|
|
|
|
|
if ( actual_rows > ideal_rows )
|
|
|
|
|
actual_rows = ideal_rows;
|
|
|
|
|
|
|
|
|
|
/* calculate strip height */
|
|
|
|
|
if ( actual_rows > 1 )
|
2010-01-27 05:28:39 +01:00
|
|
|
|
{
|
2013-06-25 02:41:15 +02:00
|
|
|
|
sh = ( scroll->h() / (float)actual_rows ) - ( mixer_strips->vspacing() * ( actual_rows - 2 ));
|
|
|
|
|
mixer_strips->flow(true);
|
2010-01-27 05:28:39 +01:00
|
|
|
|
}
|
2010-01-20 07:54:35 +01:00
|
|
|
|
else
|
2013-06-06 00:58:52 +02:00
|
|
|
|
actual_rows = 1;
|
|
|
|
|
|
|
|
|
|
if ( 1 == actual_rows )
|
2010-01-25 03:12:10 +01:00
|
|
|
|
{
|
2013-06-25 02:41:15 +02:00
|
|
|
|
sh = (scroll->h() - 18);
|
|
|
|
|
mixer_strips->flow( false );
|
2010-01-25 03:12:10 +01:00
|
|
|
|
}
|
2010-01-23 05:29:12 +01:00
|
|
|
|
|
2010-01-20 07:54:35 +01:00
|
|
|
|
int tw = 0;
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); ++i )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *t = (Mixer_Strip*)mixer_strips->child( i );
|
|
|
|
|
|
|
|
|
|
t->size( t->w(), sh );
|
|
|
|
|
|
|
|
|
|
tw += t->w() + mixer_strips->hspacing();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-04 14:45:56 +01:00
|
|
|
|
if ( actual_rows > 1 )
|
2010-01-20 07:54:35 +01:00
|
|
|
|
mixer_strips->size( scroll->w() - 18, mixer_strips->h() );
|
|
|
|
|
else
|
2013-09-08 01:58:16 +02:00
|
|
|
|
mixer_strips->size( tw, sh );
|
2010-01-20 07:54:35 +01:00
|
|
|
|
|
2010-02-04 14:45:56 +01:00
|
|
|
|
_rows = ideal_rows;
|
2013-06-25 02:17:15 +02:00
|
|
|
|
|
2020-09-25 02:58:55 +02:00
|
|
|
|
if ( _strip_height != sh )
|
2013-06-25 02:17:15 +02:00
|
|
|
|
{
|
2013-09-08 01:58:16 +02:00
|
|
|
|
mixer_strips->redraw();
|
2013-06-25 02:17:15 +02:00
|
|
|
|
scroll->redraw();
|
|
|
|
|
_strip_height = sh;
|
|
|
|
|
}
|
2010-01-20 07:54:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-26 07:28:51 +02:00
|
|
|
|
int
|
|
|
|
|
Mixer::nstrips ( void ) const
|
|
|
|
|
{
|
|
|
|
|
return mixer_strips->children();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
/** retrun a pointer to the track named /name/, or NULL if no track is named /name/ */
|
|
|
|
|
Mixer_Strip *
|
|
|
|
|
Mixer::track_by_name ( const char *name )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = mixer_strips->children(); i-- ; )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *t = (Mixer_Strip*)mixer_strips->child( i );
|
|
|
|
|
|
|
|
|
|
if ( ! strcmp( name, t->name() ) )
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-06-06 00:58:52 +02:00
|
|
|
|
/** retrun a pointer to the track named /name/, or NULL if no track is named /name/ */
|
|
|
|
|
Mixer_Strip *
|
|
|
|
|
Mixer::track_by_number ( int n )
|
|
|
|
|
{
|
|
|
|
|
if ( n < 0 || n >= mixer_strips->children() )
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return (Mixer_Strip*)mixer_strips->child(n);
|
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
/** return a malloc'd string representing a unique name for a new track */
|
|
|
|
|
char *
|
|
|
|
|
Mixer::get_unique_track_name ( const char *name )
|
|
|
|
|
{
|
|
|
|
|
char pat[256];
|
|
|
|
|
|
|
|
|
|
strcpy( pat, name );
|
|
|
|
|
|
|
|
|
|
for ( int i = 1; track_by_name( pat ); ++i )
|
|
|
|
|
snprintf( pat, sizeof( pat ), "%s.%d", name, i );
|
|
|
|
|
|
|
|
|
|
return strdup( pat );
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-06 09:03:19 +02:00
|
|
|
|
Group *
|
|
|
|
|
Mixer::group_by_name ( const char *name )
|
|
|
|
|
{
|
|
|
|
|
for ( std::list<Group*>::iterator i = groups.begin();
|
|
|
|
|
i != groups.end();
|
|
|
|
|
i++ )
|
|
|
|
|
if ( !strcmp( (*i)->name(), name ))
|
|
|
|
|
return *i;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
Mixer::get_unique_group_name ( const char *name )
|
|
|
|
|
{
|
|
|
|
|
char pat[256];
|
|
|
|
|
|
|
|
|
|
strcpy( pat, name );
|
|
|
|
|
|
|
|
|
|
for ( int i = 1; group_by_name( pat ); ++i )
|
|
|
|
|
snprintf( pat, sizeof( pat ), "%s.%d", name, i );
|
|
|
|
|
|
|
|
|
|
return strdup( pat );
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-05 03:02:01 +01:00
|
|
|
|
void
|
|
|
|
|
Mixer::handle_dirty ( int d, void *v )
|
|
|
|
|
{
|
|
|
|
|
//Mixer *m = (Mixer*)v;
|
|
|
|
|
if ( !nsm )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ( d == 1 )
|
|
|
|
|
nsm->is_dirty();
|
|
|
|
|
else if ( d == 0 )
|
|
|
|
|
nsm->is_clean();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::snapshot ( void )
|
|
|
|
|
{
|
2013-07-22 05:20:42 +02:00
|
|
|
|
if ( spatialization_console )
|
|
|
|
|
spatialization_console->log_create();
|
|
|
|
|
|
2013-08-06 09:03:19 +02:00
|
|
|
|
for ( std::list<Group*>::iterator i = groups.begin(); i != groups.end(); ++i )
|
|
|
|
|
(*i)->log_create();
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); ++i )
|
2009-12-28 06:25:28 +01:00
|
|
|
|
((Mixer_Strip*)mixer_strips->child( i ))->log_children();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::new_strip ( void )
|
|
|
|
|
{
|
2010-01-25 03:12:10 +01:00
|
|
|
|
add( new Mixer_Strip( get_unique_track_name( "Unnamed" ) ) );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-28 06:25:28 +01:00
|
|
|
|
bool
|
|
|
|
|
Mixer::save ( void )
|
|
|
|
|
{
|
|
|
|
|
MESSAGE( "Saving state" );
|
|
|
|
|
Loggable::snapshot_callback( &Mixer::snapshot, this );
|
2010-01-12 03:31:15 +01:00
|
|
|
|
Loggable::snapshot( "snapshot" );
|
2013-06-06 01:26:36 +02:00
|
|
|
|
|
|
|
|
|
save_translations();
|
2009-12-28 06:25:28 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-24 03:45:53 +01:00
|
|
|
|
static const char options_filename[] = "options";
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::load_options ( void )
|
|
|
|
|
{
|
|
|
|
|
// save options
|
|
|
|
|
|
2013-05-29 07:11:07 +02:00
|
|
|
|
/* char *path; */
|
|
|
|
|
/* asprintf( &path, "%s/options", user_config_dir ); */
|
|
|
|
|
/* ((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Options" ), path ); */
|
|
|
|
|
/* free( path ); */
|
2010-01-24 03:45:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::save_options ( void )
|
|
|
|
|
{
|
2013-05-29 07:11:07 +02:00
|
|
|
|
/* char *path; */
|
|
|
|
|
/* asprintf( &path, "%s/%s", user_config_dir, options_filename ); */
|
|
|
|
|
/* ((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Options" ), path ); */
|
|
|
|
|
/* free( path ); */
|
2010-01-24 03:45:53 +01:00
|
|
|
|
}
|
2009-12-28 06:25:28 +01:00
|
|
|
|
|
2010-01-31 22:02:26 +01:00
|
|
|
|
void
|
|
|
|
|
Mixer::update_menu ( void )
|
|
|
|
|
{
|
2010-02-01 03:54:15 +01:00
|
|
|
|
project_name->label( Project::name() );
|
2013-07-22 05:20:42 +02:00
|
|
|
|
|
|
|
|
|
const_cast<Fl_Menu_Item*>(menubar->find_item( "&Mixer/&Spatialization Console" ))
|
|
|
|
|
->flags = FL_MENU_TOGGLE | ( ( spatialization_console && spatialization_console->shown() ) ? FL_MENU_VALUE : 0 );
|
2010-01-31 22:02:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::send_feedback_cb ( void *v )
|
|
|
|
|
{
|
|
|
|
|
Mixer *m = (Mixer*)v;
|
|
|
|
|
|
|
|
|
|
m->send_feedback();
|
|
|
|
|
|
2020-11-20 03:48:41 +01:00
|
|
|
|
/* just to it once at the start... */
|
2013-06-06 01:26:36 +02:00
|
|
|
|
Fl::repeat_timeout( FEEDBACK_UPDATE_FREQ, send_feedback_cb, v );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** unconditionally send feedback to all mapped controls. This is
|
|
|
|
|
* useful for updating the state of an external controller. */
|
|
|
|
|
void
|
|
|
|
|
Mixer::send_feedback ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
((Mixer_Strip*)mixer_strips->child(i))->send_feedback();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 21:42:14 +01:00
|
|
|
|
|
|
|
|
|
|
2013-05-30 03:27:43 +02:00
|
|
|
|
int
|
|
|
|
|
Mixer::handle ( int m )
|
|
|
|
|
{
|
2020-11-12 04:42:26 +01:00
|
|
|
|
/* if user presses certain keys when project is loading it can cause a crash. Don't respond to input. */
|
|
|
|
|
if ( Project::is_opening() )
|
|
|
|
|
return 0;
|
2013-05-30 03:27:43 +02:00
|
|
|
|
|
|
|
|
|
if ( Fl_Group::handle( m ) )
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
switch ( m )
|
|
|
|
|
{
|
|
|
|
|
case FL_PASTE:
|
|
|
|
|
{
|
|
|
|
|
if ( ! Fl::event_inside( this ) )
|
|
|
|
|
return 0;
|
2020-11-03 03:03:54 +01:00
|
|
|
|
|
|
|
|
|
DMESSAGE( "Got paste into mixer, expecting strip file..." );
|
|
|
|
|
|
2013-05-30 03:27:43 +02:00
|
|
|
|
const char *text = Fl::event_text();
|
|
|
|
|
|
|
|
|
|
char *file;
|
|
|
|
|
|
2017-03-28 08:16:09 +02:00
|
|
|
|
if ( ! sscanf( text, "file://%m[^\r\n]\n", &file ) )
|
2013-05-30 03:27:43 +02:00
|
|
|
|
{
|
|
|
|
|
WARNING( "invalid drop \"%s\"\n", text );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unescape_url( file );
|
|
|
|
|
|
|
|
|
|
printf( "pasted file \"%s\"\n", file );
|
|
|
|
|
|
|
|
|
|
if (! Mixer_Strip::import_strip( file ) )
|
|
|
|
|
fl_alert( "%s", "Failed to import strip!" );
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-04 10:00:29 +02:00
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
std::list <std::string>
|
|
|
|
|
Mixer::get_auto_connect_targets ( void )
|
|
|
|
|
{
|
|
|
|
|
std::list <std::string> sl;
|
|
|
|
|
std::list <std::string> rl;
|
|
|
|
|
|
|
|
|
|
for ( int i = mixer_strips->children(); i--; )
|
|
|
|
|
{
|
|
|
|
|
((Mixer_Strip*)mixer_strips->child(i))->get_output_ports(sl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( std::list<std::string>::iterator i = sl.begin(); i != sl.end(); i++ )
|
|
|
|
|
{
|
|
|
|
|
char *s = strdup( i->c_str() );
|
|
|
|
|
|
|
|
|
|
*rindex( s, '/' ) = 0;
|
|
|
|
|
|
|
|
|
|
if ( !index( s, '/' ) )
|
|
|
|
|
{
|
|
|
|
|
char *o;
|
|
|
|
|
asprintf( &o, "%s/mains", s );
|
|
|
|
|
free(s);
|
|
|
|
|
s = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( std::find( rl.begin(), rl.end(), s ) == rl.end() )
|
|
|
|
|
{
|
|
|
|
|
rl.push_back( s );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::auto_connect ( void )
|
|
|
|
|
{
|
2016-03-03 06:13:17 +01:00
|
|
|
|
if ( Project::is_opening() )
|
|
|
|
|
/* it's more efficient to do this once at the end rather than as we go. */
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DMESSAGE("Full auto-connect cycle" );
|
|
|
|
|
|
2013-09-04 10:00:29 +02:00
|
|
|
|
/* give strips with group affinity the first shot */
|
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *s = ((Mixer_Strip*)mixer_strips->child(i));
|
|
|
|
|
|
|
|
|
|
if ( s->has_group_affinity() )
|
|
|
|
|
s->auto_connect_outputs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now do that catch-alls, first one wins! */
|
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *s = ((Mixer_Strip*)mixer_strips->child(i));
|
|
|
|
|
|
|
|
|
|
if ( ! s->has_group_affinity() )
|
|
|
|
|
s->auto_connect_outputs();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::maybe_auto_connect_output ( Module::Port *p )
|
|
|
|
|
{
|
2016-03-03 06:13:17 +01:00
|
|
|
|
if ( Project::is_opening() )
|
|
|
|
|
/* it's more efficient to do this once at the end rather than as we go. */
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// DMESSAGE( "Single output auto connect cycle" );
|
|
|
|
|
|
2013-09-04 10:00:29 +02:00
|
|
|
|
/* give strips with group affinity the first shot */
|
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *s = ((Mixer_Strip*)mixer_strips->child(i));
|
|
|
|
|
|
|
|
|
|
if ( s->has_group_affinity() )
|
|
|
|
|
if ( s->maybe_auto_connect_output( p ) )
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now do that catch-alls, first one wins! */
|
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *s = ((Mixer_Strip*)mixer_strips->child(i));
|
|
|
|
|
|
|
|
|
|
if ( ! s->has_group_affinity() )
|
|
|
|
|
if ( s->maybe_auto_connect_output( p ) )
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-31 21:42:14 +01:00
|
|
|
|
/************/
|
|
|
|
|
/* Commands */
|
|
|
|
|
/************/
|
|
|
|
|
|
2013-09-09 04:22:58 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::command_toggle_fader_view ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = 0; i < mixer_strips->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
Mixer_Strip *s = ((Mixer_Strip*)mixer_strips->child(i));
|
|
|
|
|
s->command_toggle_fader_view();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
void
|
|
|
|
|
Mixer::command_clear_mappings ( void )
|
|
|
|
|
{
|
|
|
|
|
osc_endpoint->clear_translations();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 21:42:14 +01:00
|
|
|
|
bool
|
|
|
|
|
Mixer::command_save ( void )
|
|
|
|
|
{
|
2013-05-14 02:21:57 +02:00
|
|
|
|
if ( ! Project::open() )
|
|
|
|
|
{
|
|
|
|
|
command_new();
|
|
|
|
|
update_menu();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-14 03:02:01 +02:00
|
|
|
|
save_project_settings();
|
|
|
|
|
|
2010-01-31 21:42:14 +01:00
|
|
|
|
return Project::save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Mixer::command_load ( const char *path, const char *display_name )
|
|
|
|
|
{
|
2013-04-10 02:51:47 +02:00
|
|
|
|
mixer->deactivate();
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2013-08-24 02:05:23 +02:00
|
|
|
|
Project::close();
|
|
|
|
|
|
|
|
|
|
char *pwd = (char*)malloc( PATH_MAX + 1 );
|
|
|
|
|
getcwd( pwd, PATH_MAX );
|
2013-06-25 02:17:15 +02:00
|
|
|
|
chdir( path );
|
|
|
|
|
load_project_settings();
|
2013-08-24 02:05:23 +02:00
|
|
|
|
chdir( pwd );
|
|
|
|
|
free( pwd );
|
2013-08-06 09:03:19 +02:00
|
|
|
|
|
2012-02-27 04:35:31 +01:00
|
|
|
|
if ( Project::open( path ) )
|
2010-01-31 21:42:14 +01:00
|
|
|
|
{
|
|
|
|
|
// fl_alert( "Error opening project specified on commandline: %s", Project::errstr( err ) );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( display_name )
|
|
|
|
|
Project::name( display_name );
|
2013-05-14 03:02:01 +02:00
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
load_translations();
|
|
|
|
|
|
2010-01-31 22:02:26 +01:00
|
|
|
|
update_menu();
|
|
|
|
|
|
2013-09-04 10:00:29 +02:00
|
|
|
|
auto_connect();
|
|
|
|
|
|
2013-04-10 02:51:47 +02:00
|
|
|
|
mixer->activate();
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2020-11-20 03:48:41 +01:00
|
|
|
|
/* Fl::remove_timeout( send_feedback_cb, this ); */
|
|
|
|
|
Fl::add_timeout( FEEDBACK_UPDATE_FREQ, send_feedback_cb, this );
|
|
|
|
|
|
2010-01-31 21:42:14 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Mixer::command_new ( const char *path, const char *display_name )
|
|
|
|
|
{
|
|
|
|
|
if ( ! Project::create( path, "" ) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if ( display_name )
|
|
|
|
|
Project::name( display_name );
|
|
|
|
|
|
2013-05-14 03:02:01 +02:00
|
|
|
|
load_project_settings();
|
|
|
|
|
|
2010-01-31 22:02:26 +01:00
|
|
|
|
update_menu();
|
|
|
|
|
|
2010-01-31 21:42:14 +01:00
|
|
|
|
return true;
|
|
|
|
|
// fl_alert( "Error creating project!" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::command_quit ( void )
|
|
|
|
|
{
|
2010-02-01 04:14:56 +01:00
|
|
|
|
if ( Loggable::dirty() )
|
|
|
|
|
{
|
|
|
|
|
int i = fl_choice( "There have been changes since the last save. Quitting now will discard them", "Discard", "Cancel", NULL );
|
|
|
|
|
|
|
|
|
|
if ( i != 0 )
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 21:42:14 +01:00
|
|
|
|
quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mixer::command_add_strip ( void )
|
|
|
|
|
{
|
|
|
|
|
new_strip();
|
|
|
|
|
}
|