Browse Source

Mixer: Tweaks to by-number learning.

tags/non-daw-v1.2.0
Jonathan Moore Liles 12 years ago
parent
commit
fd64b39fa4
7 changed files with 71 additions and 96 deletions
  1. +1
    -1
      lib/ntk
  2. +26
    -37
      mixer/src/Controller_Module.C
  3. +12
    -42
      mixer/src/Mixer.C
  4. +13
    -10
      mixer/src/Module.C
  5. +12
    -1
      mixer/src/Module.H
  6. +5
    -3
      mixer/src/midi-mapper.C
  7. +2
    -2
      mixer/wscript

+ 1
- 1
lib/ntk

@@ -1 +1 @@
Subproject commit 8ee564bef320b3561e204d17c1aa054311b2ce47
Subproject commit fd8c8d419e8e548c8f6328f1b21783c6ca3001a5

+ 26
- 37
mixer/src/Controller_Module.C View File

@@ -514,13 +514,7 @@ Controller_Module::menu_cb ( const Fl_Menu_ *m )
Port *p = control_output[0].connected_port();

if ( learn_by_number )
{
char *our_path = p->osc_number_path();
mixer->osc_endpoint->add_translation( path, our_path );

free(our_path);
}
mixer->osc_endpoint->add_translation( path, p->osc_number_path());
else
mixer->osc_endpoint->add_translation( path, p->osc_path() );
}
@@ -608,7 +602,7 @@ Controller_Module::peer_callback( OSC::Signal *sig, OSC::Signal::State state, v
else
{
/* building menu */
const char *name = sig->peer_name();
// const char *name = sig->peer_name();
assert( sig->path() );

@@ -649,29 +643,37 @@ Controller_Module::add_osc_connections_to_menu ( Fl_Menu_Button *m, const char *
// mixer->osc_endpoint->list_peer_signals( this );

Port *p = control_output[0].connected_port();
const char ** conn = mixer->osc_endpoint->get_connections( p->osc_path() );

if ( conn )
const char *number_path = p->osc_number_path();
const char *name_path = p->osc_path();

const char *paths[] = { number_path,name_path,NULL };

for ( const char **cpath = paths; *cpath; cpath++ )
{
for ( const char **s = conn; *s; s++ )
const char ** conn = mixer->osc_endpoint->get_connections( *cpath );

if ( conn )
{
/* building menu */
for ( const char **s = conn; *s; s++ )
{
/* building menu */
char *path = strdup( *s );
char *path = strdup( *s );
unescape_url( path );
unescape_url( path );

char *ns;
asprintf( &ns, "%s/%s", peer_prefix, path );
char *ns;
asprintf( &ns, "%s/%s", peer_prefix, path );
peer_menu->add( ns, 0, NULL, const_cast<char*>(*s), 0 );
peer_menu->add( ns, 0, NULL, const_cast<char*>(*s), 0 );
free( path );
free( path );
// free(*s);
}
}

free( conn );
free( conn );
}
}
}

@@ -730,24 +732,11 @@ Controller_Module::handle ( int m )
if ( p )
{
if ( learn_by_number )
{
char *path = p->osc_number_path();

DMESSAGE( "Will learn %s", path );
const char * path = learn_by_number ? p->osc_number_path() : p->osc_path();

mixer->osc_endpoint->learn( path );

free(path);
}
else
{
const char *path = p->osc_path();
DMESSAGE( "Will learn %s", path );
DMESSAGE( "Will learn %s", path );

mixer->osc_endpoint->learn( path );
}
mixer->osc_endpoint->learn( path );
}

return 1;


+ 12
- 42
mixer/src/Mixer.C View File

@@ -37,7 +37,6 @@
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_Theme_Chooser.H>
#include <FL/Fl_Value_SliderX.H>
#include "FL/Fl_Text_Edit_Window.H"
#include "file.h"

#include <string.h>
@@ -261,10 +260,6 @@ void Mixer::cb_menu(Fl_Widget* o) {
{
command_add_strip();
}
else if ( !strcmp( picked, "&Mixer/Send Feedback" ) )
{
send_feedback();
}
else if ( !strcmp( picked, "&Mixer/Add &N Strips" ) )
{
const char *s = fl_input( "Enter number of strips to add" );
@@ -293,29 +288,29 @@ void Mixer::cb_menu(Fl_Widget* o) {
{
Controller_Module::learn_by_number = true;
}
else if ( ! strcmp( picked, "&Mixer/Remote Control/Start Learning" ) )
else if ( ! strcmp( picked, "&Remote Control/Start Learning" ) )
{
Controller_Module::learn_mode( true );
tooltip( "Now in learn mode. Click on a highlighted control to teach it something." );
redraw();
}
else if ( ! strcmp( picked, "&Mixer/Remote Control/Stop Learning" ) )
else if ( ! strcmp( picked, "&Remote Control/Stop Learning" ) )
{
Controller_Module::learn_mode( false );
tooltip( "Learning complete" );
redraw();
}
else if ( ! strcmp( picked, "&Mixer/Remote Control/Clear Mappings" ) )
else if ( !strcmp( picked, "&Remote Control/Send State" ) )
{
send_feedback();
}
else if ( ! strcmp( picked, "&Remote Control/Clear All Mappings" ) )
{
if ( 1 == fl_ask( "This will remove all mappings, are you sure?") )
{
command_clear_mappings();
}
}
else if ( ! strcmp( picked, "&Mixer/Remote Control/Edit Mappings" ) )
{
edit_translations();
}
else if ( !strcmp( picked, "&Mixer/Paste" ) )
{
Fl::paste(*this);
@@ -496,20 +491,19 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
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 );
o->add( "&Project/Se&ttings/Make Default", 0,0,0);
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 );
o->add( "&Project/Se&ttings/Make Default", 0,0,0);
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/Send Feedback" );
o->add( "&Mixer/&Import Strip" );
o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 );
o->add( "&Mixer/Remote Control/Start Learning", FL_F + 9, 0, 0 );
o->add( "&Mixer/Remote Control/Stop Learning", FL_F + 10, 0, 0 );
o->add( "&Mixer/Remote Control/Clear Mappings", 0, 0, 0 );
o->add( "&Mixer/Remote Control/Edit Mappings", 0, 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/Send State" );
o->add( "&Remote Control/Clear All Mappings", 0, 0, 0 );
o->add( "&View/&Theme", 0, 0, 0 );
o->add( "&Help/&Manual" );
o->add( "&Help/&About" );
@@ -656,30 +650,6 @@ Mixer::save_translations ( void )
fclose( fp );
}

void
Mixer::edit_translations ( void )
{
char *file_contents = NULL;

if ( exists( "mappings" ) )
{
size_t l = ::size( "mappings" );

file_contents = (char*)malloc( l );
FILE *fp = fopen( "mappings", "r" );

fread( file_contents, l, 1, fp );

fclose( fp );
}

char *s = fl_text_edit( "Mappings", "&Save", file_contents, 800, 600 );

if ( file_contents )
free(file_contents);
}

int
Mixer::init_osc ( const char *osc_port )
{


+ 13
- 10
mixer/src/Module.C View File

@@ -226,11 +226,17 @@ Module::paste_before ( void )


char *
const char *
Module::Port::osc_number_path ( void )
{
int n = _module->chain()->strip()->number();
if ( _by_number_path && n == _by_number_number )
return _by_number_path;

if ( _by_number_path )
free( _by_number_path );

char *rem;
char *client_name;
char *strip_name;
@@ -245,6 +251,9 @@ Module::Port::osc_number_path ( void )

free( client_name );
free( rem );
_by_number_path = path;
_by_number_number = n;

return path;
}
@@ -274,15 +283,9 @@ Module::Port::send_feedback ( void )
/* send feedback for by_name signal */
mixer->osc_endpoint->send_feedback( _scaled_signal->path(), f );
/* send feedback for by number signal */
{
char *path = osc_number_path();
mixer->osc_endpoint->send_feedback( path, f );
free(path);
}
}
/* send feedback for by number signal */
mixer->osc_endpoint->send_feedback( osc_number_path(), f );
}
}

void


+ 12
- 1
mixer/src/Module.H View File

@@ -138,6 +138,8 @@ public:
_module = module;
_scaled_signal = 0;
_unscaled_signal = 0;
_by_number_path = 0;
_by_number_number = -1;
}

Port ( const Port& p )
@@ -152,10 +154,16 @@ public:
hints = p.hints;
_scaled_signal = p._scaled_signal;
_unscaled_signal = p._unscaled_signal;
_by_number_path = 0;
_by_number_number = -1;
}

virtual ~Port ( )
{
if ( _by_number_path )
free( _by_number_path );
_by_number_path = NULL;

// change_osc_path( NULL );
// disconnect();
}
@@ -172,6 +180,9 @@ public:

OSC::Signal *scaled_signal ( void ) { return _scaled_signal; }

int _by_number_number;
char *_by_number_path;

const char *osc_path ( )
{
if ( _scaled_signal )
@@ -180,7 +191,7 @@ public:
return NULL;
}

char *osc_number_path ( void );
const char *osc_number_path ( void );

void update_osc_port ( )
{


mixer/src/midi-to-osc.C → mixer/src/midi-mapper.C View File

@@ -44,6 +44,8 @@ using namespace MIDI;

#undef APP_NAME
const char *APP_NAME = "non-midi-mapper";
#undef APP_TITLE
const char *APP_TITLE = "Non-MIDI-Mapper";
#undef VERSION
const char *VERSION = "1.0";

@@ -100,7 +102,7 @@ say_hello ( void )
lo_message_add( m, "sssss",
"/non/hello",
osc->url(),
APP_NAME,
APP_TITLE,
VERSION,
instance_name );
@@ -618,7 +620,7 @@ main ( int argc, char **argv )
{
if ( ! nsm_init( nsm, nsm_url ) )
{
nsm_send_announce( nsm, APP_NAME, ":dirty:", argv[0] );
nsm_send_announce( nsm, APP_TITLE, ":dirty:", basename( argv[0] ) );

/* poll so we can keep OSC handlers running in the GUI thread and avoid extra sync */
// Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL );
@@ -629,7 +631,7 @@ main ( int argc, char **argv )

DMESSAGE( "Creating JACK engine" );

if ( ! engine->init("midi-to-osc" ) )
if ( ! engine->init( APP_NAME ) )
{
WARNING( "Failed to create JACK client" );
}

+ 2
- 2
mixer/wscript View File

@@ -72,8 +72,8 @@ src/main.C
uselib = [ 'JACK', 'LIBLO', 'LRDF', 'NTK', 'NTK_IMAGES', 'PTHREAD', 'DL', 'M' ],
install_path = '${BINDIR}')

bld.program( source = 'src/midi-to-osc.C',
target = 'midi-to-osc',
bld.program( source = 'src/midi-mapper.C',
target = 'non-midi-mapper',
includes = ['.', 'src', '..', '../nonlib'],
use = ['nonlib', 'fl_widgets'],
uselib = [ 'JACK', 'LIBLO', 'LRDF', 'NTK', 'NTK_IMAGES', 'PTHREAD', 'DL', 'M' ],


Loading…
Cancel
Save