Non reinvents the DAW. Powerful enough to form a complete studio, fast and light enough to run on low-end hardware like the eeePC or Raspberry Pi, and so reliable that it can be used live https://non.tuxfamily.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

818 lines
20KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2009 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. /* This is the main mixer group. It contains and manages Mixer_Strips. */
  19. #include "const.h"
  20. #include "Mixer.H"
  21. #include "Mixer_Strip.H"
  22. #include <FL/Fl_Pack.H>
  23. #include <FL/Fl_Scroll.H>
  24. #include <FL/Fl_Menu_Bar.H>
  25. #include <FL/fl_ask.H>
  26. #include <FL/Fl.H>
  27. #include <New_Project_Dialog.H>
  28. #include "Engine/Engine.H"
  29. #include <Fl_Flowpack.H>
  30. #include "Project.H"
  31. #include <Fl_Menu_Settings.H>
  32. #include <About_Dialog.H>
  33. #include <FL/Fl_File_Chooser.H>
  34. #include <FL/Fl_Theme_Chooser.H>
  35. #include <Fl_Value_SliderX.H>
  36. #include "file.h"
  37. #include <string.h>
  38. #include "debug.h"
  39. #include <unistd.h>
  40. #include <sys/types.h>
  41. #include "OSC/Endpoint.H"
  42. #include <lo/lo.h>
  43. const double STATUS_UPDATE_FREQ = 0.2f;
  44. extern char *user_config_dir;
  45. extern char *instance_name;
  46. #include "debug.h"
  47. #include "NSM.H"
  48. extern NSM_Client *nsm;
  49. /* static void update_cb( void *v ) { */
  50. /* Fl::repeat_timeout( STATUS_UPDATE_FREQ, update_cb, v ); */
  51. /* ((Mixer*)v)->update(); */
  52. /* } */
  53. /************************/
  54. /* OSC Message Handlers */
  55. /************************/
  56. #undef OSC_REPLY_OK
  57. #undef OSC_REPLY_ERR
  58. #undef OSC_REPLY
  59. #define OSC_REPLY_OK() ((OSC::Endpoint*)user_data)->send( lo_message_get_source( msg ), path, 0, "OK" )
  60. #define OSC_REPLY( value ) ((OSC::Endpoint*)user_data)->send( lo_message_get_source( msg ), path, value )
  61. #define OSC_REPLY_ERR(errcode, value) ((OSC::Endpoint*)user_data)->send( lo_message_get_source( msg ), path,errcode, value )
  62. #define OSC_ENDPOINT() ((OSC::Endpoint*)user_data)
  63. static int osc_add_strip ( const char *path, const char *, lo_arg **, int , lo_message msg, void *user_data )
  64. {
  65. OSC_DMSG();
  66. Fl::lock();
  67. ((Mixer*)(OSC_ENDPOINT())->owner)->command_add_strip();
  68. Fl::unlock();
  69. OSC_REPLY_OK();
  70. return 0;
  71. }
  72. void
  73. Mixer::reply_to_finger ( lo_message msg )
  74. {
  75. int argc = lo_message_get_argc( msg );
  76. lo_arg **argv = lo_message_get_argv( msg );
  77. if ( argc >= 4 )
  78. {
  79. const char *url = &argv[0]->s;
  80. const char *name = &argv[1]->s;
  81. const char *version = &argv[2]->s;
  82. const char *id = &argv[3]->s;
  83. MESSAGE( "Discovered NON peer %s (%s) @ %s with ID \"%s\"", name, version, url, id );
  84. MESSAGE( "Registering Signals" );
  85. lo_address to = lo_address_new_from_url( &argv[0]->s );
  86. osc_endpoint->send( to,
  87. "/non/hello",
  88. osc_endpoint->url(),
  89. APP_NAME,
  90. VERSION,
  91. instance_name );
  92. mixer->osc_endpoint->hello( url );
  93. lo_address_free( to );
  94. }
  95. }
  96. void
  97. Mixer::say_hello ( void )
  98. {
  99. lo_message m = lo_message_new();
  100. lo_message_add( m, "sssss",
  101. "/non/hello",
  102. osc_endpoint->url(),
  103. APP_NAME,
  104. VERSION,
  105. instance_name );
  106. nsm->broadcast( m );
  107. lo_message_free( m );
  108. }
  109. static
  110. Fl_Menu_Item *
  111. find_item( Fl_Menu_ *menu, const char *path )
  112. {
  113. return const_cast<Fl_Menu_Item*>(menu->find_item( path ));
  114. }
  115. void
  116. Mixer::sm_active ( bool b )
  117. {
  118. sm_blinker->value( b );
  119. sm_blinker->tooltip( nsm->session_manager_name() );
  120. if ( b )
  121. {
  122. find_item( menubar, "&Project/&Open" )->deactivate();
  123. find_item( menubar, "&Project/&New" )->deactivate();
  124. }
  125. }
  126. void
  127. Mixer::redraw_windows ( void )
  128. {
  129. window()->redraw();
  130. if ( Fl::first_window() )
  131. for ( Fl_Window *w = Fl::first_window(); ( w = Fl::next_window( w ) ); )
  132. w->redraw();
  133. }
  134. void Mixer::cb_menu(Fl_Widget* o) {
  135. Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o;
  136. /* const Fl_Menu_Item *mi = &menu->menu()[menu->value()]; */
  137. char picked[256];
  138. // const char *picked = menu->text();
  139. menu->item_pathname( picked, sizeof( picked ) );
  140. if (! strcmp( picked, "&Project/&New") )
  141. {
  142. DMESSAGE( "New project" );
  143. const char *templates[] = { "Default", NULL };
  144. char *default_path;
  145. char *selected_template;
  146. read_line( user_config_dir, "default_path", &default_path );
  147. char *path = new_project_chooser( templates, &default_path, &selected_template );
  148. if ( path )
  149. {
  150. if ( ! Project::create( path, selected_template ) )
  151. fl_alert( "Error creating project!" );
  152. free( path );
  153. free( selected_template );
  154. }
  155. update_menu();
  156. if ( default_path )
  157. {
  158. write_line( user_config_dir, "default_path", default_path );
  159. free( default_path );
  160. }
  161. }
  162. else if (! strcmp( picked, "&Project/&Open" ) )
  163. {
  164. char *path = NULL;
  165. // read_line( user_config_dir, "default_path", &path );
  166. const char *name = fl_dir_chooser( "Open Project", path );
  167. free( path );
  168. mixer->hide();
  169. if ( int err = Project::open( name ) )
  170. {
  171. fl_alert( "Error opening project: %s", Project::errstr( err ) );
  172. }
  173. update_menu();
  174. mixer->show();
  175. }
  176. else if (! strcmp( picked, "&Project/&Save" ) )
  177. {
  178. command_save();
  179. }
  180. else if (! strcmp( picked, "&Project/&Quit") )
  181. {
  182. command_quit();
  183. }
  184. else if ( !strcmp( picked, "&Mixer/&Add Strip" ) )
  185. {
  186. command_add_strip();
  187. }
  188. else if ( !strcmp( picked, "&Mixer/Add &N Strips" ) )
  189. {
  190. const char *s = fl_input( "Enter number of strips to add" );
  191. if ( s )
  192. {
  193. for ( int i = atoi( s ); i > 0; i-- )
  194. command_add_strip();
  195. }
  196. }
  197. else if ( !strcmp( picked, "&Mixer/&Import Strip" ) )
  198. {
  199. const char *s = fl_file_chooser( "Export strip to filename:", "*.strip", NULL, 0 );
  200. if ( s )
  201. {
  202. if (! Mixer_Strip::import_strip( s ) )
  203. fl_alert( "%s", "Failed to import strip!" );
  204. }
  205. }
  206. else if (! strcmp( picked, "&Mixer/&Rows/One") )
  207. {
  208. rows( 1 );
  209. }
  210. else if (! strcmp( picked, "&Mixer/&Rows/Two") )
  211. {
  212. rows( 2 );
  213. }
  214. else if (! strcmp( picked, "&Mixer/&Rows/Three") )
  215. {
  216. rows( 3 );
  217. }
  218. else if (! strcmp( picked, "&View/&Theme") )
  219. {
  220. fl_theme_chooser();
  221. }
  222. else if (! strcmp( picked, "&Options/&Display/&Knobs/&Burnished") )
  223. {
  224. Fl_Dial::default_style( Fl_Dial::BURNISHED_DIAL );
  225. redraw_windows();
  226. }
  227. else if (! strcmp( picked, "&Options/&Display/&Knobs/&Arc") )
  228. {
  229. Fl_Dial::default_style( Fl_Dial::ARC_DIAL );
  230. redraw_windows();
  231. }
  232. else if (! strcmp( picked, "&Options/&Display/&Knobs/&Plastic") )
  233. {
  234. Fl_Dial::default_style( Fl_Dial::PLASTIC_DIAL );
  235. redraw_windows();
  236. }
  237. else if (! strcmp( picked, "&Options/&Display/&Sliders/&Nice") )
  238. {
  239. Fl_Value_SliderX::default_style( Fl_Value_SliderX::NICE_SLIDER );
  240. redraw_windows();
  241. }
  242. else if (! strcmp( picked, "&Options/&Display/&Sliders/&Fill") )
  243. {
  244. Fl_Value_SliderX::default_style( Fl_Value_SliderX::FILL_SLIDER );
  245. redraw_windows();
  246. }
  247. else if (! strcmp( picked, "&Options/&Display/&Sliders/&Simple") )
  248. {
  249. Fl_Value_SliderX::default_style( Fl_Value_SliderX::SIMPLE_SLIDER );
  250. redraw_windows();
  251. }
  252. else if ( ! strcmp( picked, "&Help/&About" ) )
  253. {
  254. About_Dialog ab( PIXMAP_PATH "/non-mixer/icon-256x256.png" );
  255. ab.logo_box->label( VERSION );
  256. ab.title->label( "The Non Mixer" );
  257. ab.copyright->label( "Copyright (C) 2008-2010 Jonathan Moore Liles" );
  258. ab.credits->label(
  259. "Non-Mixer was written from scratch by\n"
  260. "Jonathan Moore Liles for his own use\n"
  261. "(see the manual).\n"
  262. "\n"
  263. "Nobody planned. Nobody helped.\n"
  264. "You can help now by donating time, money,\n"
  265. "and/or replacing the rest of Linux Audio\n"
  266. "with fast, light, reliable alternatives.\n" );
  267. ab.website_url->label( "http://non-mixer.tuxfamily.org" );
  268. ab.run();
  269. }
  270. else if ( !strcmp( picked, "&Help/&Manual" ))
  271. {
  272. char *pat;
  273. asprintf( &pat, "file://%s.html", DOCUMENT_PATH "/non-mixer/MANUAL" );
  274. open_url( pat );
  275. free( pat );
  276. }
  277. }
  278. void Mixer::cb_menu(Fl_Widget* o, void* v) {
  279. ((Mixer*)(v))->cb_menu(o);
  280. }
  281. Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
  282. Fl_Group( X, Y, W, H, L )
  283. {
  284. Loggable::dirty_callback( &Mixer::handle_dirty, this );
  285. _rows = 1;
  286. box( FL_FLAT_BOX );
  287. labelsize( 96 );
  288. { Fl_Group *o = new Fl_Group( X, Y, W, 24 );
  289. { Fl_Menu_Bar *o = menubar = new Fl_Menu_Bar( X, Y, W, 24 );
  290. o->add( "&Project/&New" );
  291. o->add( "&Project/&Open" );
  292. o->add( "&Project/&Save", FL_CTRL + 's', 0, 0 );
  293. o->add( "&Project/&Quit", FL_CTRL + 'q', 0, 0 );
  294. o->add( "&Mixer/&Add Strip", 'a', 0, 0 );
  295. o->add( "&Mixer/Add &N Strips" );
  296. o->add( "&Mixer/&Import Strip" );
  297. o->add( "&Mixer/&Rows/One", '1', 0, 0 );
  298. o->add( "&Mixer/&Rows/Two", '2', 0, 0 );
  299. o->add( "&Mixer/&Rows/Three", '3', 0, 0 );
  300. o->add( "&View/&Theme", 0, 0, 0 );
  301. o->add( "_&Options/&Display/&Knobs/&Arc", 0, 0, 0, FL_MENU_RADIO );
  302. o->add( "_&Options/&Display/&Knobs/&Burnished", 0, 0, 0, FL_MENU_RADIO );
  303. o->add( "_&Options/&Display/&Knobs/&Plastic", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
  304. o->add( "_&Options/&Display/&Sliders/&Nice", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
  305. o->add( "_&Options/&Display/&Sliders/&Fill", 0, 0, 0, FL_MENU_RADIO );
  306. o->add( "_&Options/&Display/&Sliders/&Simple", 0, 0, 0, FL_MENU_RADIO );
  307. o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO );
  308. o->add( "&Help/&Manual" );
  309. o->add( "&Help/&About" );
  310. o->callback( cb_menu, this );
  311. }
  312. { Fl_Box *o = project_name = new Fl_Box( X + 150, Y, W, 24 );
  313. o->labelfont( FL_HELVETICA_ITALIC );
  314. o->label( 0 );
  315. o->align( FL_ALIGN_INSIDE | FL_ALIGN_CENTER );
  316. o->labeltype( FL_SHADOW_LABEL );
  317. Fl_Group::current()->resizable( o );
  318. }
  319. { sm_blinker = new Fl_Button( ( X + W) - 37, Y + 4, 35, 15, "SM");
  320. sm_blinker->box(FL_ROUNDED_BOX);
  321. sm_blinker->down_box(FL_ROUNDED_BOX);
  322. sm_blinker->color(FL_DARK2);
  323. sm_blinker->selection_color((Fl_Color)93);
  324. sm_blinker->labeltype(FL_NORMAL_LABEL);
  325. sm_blinker->labelfont(3);
  326. sm_blinker->labelsize(14);
  327. sm_blinker->labelcolor(FL_DARK3);
  328. sm_blinker->align(Fl_Align(FL_ALIGN_CENTER));
  329. sm_blinker->when(FL_WHEN_RELEASE);
  330. sm_blinker->deactivate();
  331. } // Fl_Blink_Button* sm_blinker
  332. o->end();
  333. }
  334. { Fl_Scroll *o = scroll = new Fl_Scroll( X, Y + 24, W, H - 24 );
  335. o->box( FL_FLAT_BOX );
  336. // o->type( Fl_Scroll::HORIZONTAL_ALWAYS );
  337. // o->box( Fl_Scroll::BOTH );
  338. {
  339. Fl_Flowpack *o = mixer_strips = new Fl_Flowpack( X, Y + 24, W, H - 18 - 24 );
  340. // label( "Non-Mixer" );
  341. align( (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE) );
  342. o->box( FL_FLAT_BOX );
  343. o->type( Fl_Pack::HORIZONTAL );
  344. o->hspacing( 2 );
  345. o->vspacing( 2 );
  346. o->end();
  347. Fl_Group::current()->resizable( o );
  348. }
  349. o->end();
  350. Fl_Group::current()->resizable( o );
  351. }
  352. end();
  353. // Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );
  354. update_menu();
  355. load_options();
  356. }
  357. int
  358. Mixer::init_osc ( const char *osc_port )
  359. {
  360. osc_endpoint = new OSC::Endpoint();
  361. if ( int r = osc_endpoint->init( LO_UDP, osc_port ) )
  362. return r;
  363. osc_endpoint->owner = this;
  364. printf( "OSC=%s\n", osc_endpoint->url() );
  365. osc_endpoint->add_method( "/non/mixer/add_strip", "", osc_add_strip, osc_endpoint, "" );
  366. osc_endpoint->start();
  367. return 0;
  368. }
  369. Mixer::~Mixer ( )
  370. {
  371. DMESSAGE( "Destroying mixer" );
  372. save_options();
  373. /* FIXME: teardown */
  374. mixer_strips->clear();
  375. }
  376. void Mixer::resize ( int X, int Y, int W, int H )
  377. {
  378. Fl_Group::resize( X, Y, W, H );
  379. mixer_strips->resize( X, Y + 24, W, H - 18 - 24 );
  380. scroll->resize( X, Y + 24, W, H - 24 );
  381. rows( _rows );
  382. }
  383. void Mixer::add ( Mixer_Strip *ms )
  384. {
  385. MESSAGE( "Add mixer strip \"%s\"", ms->name() );
  386. mixer_strips->add( ms );
  387. ms->take_focus();
  388. rows( _rows );
  389. // scroll->redraw();
  390. }
  391. void
  392. Mixer::quit ( void )
  393. {
  394. /* TODO: save project? */
  395. while ( Fl::first_window() ) Fl::first_window()->hide();
  396. }
  397. void
  398. Mixer::insert ( Mixer_Strip *ms, Mixer_Strip *before )
  399. {
  400. mixer_strips->remove( ms );
  401. mixer_strips->insert( *ms, before );
  402. scroll->redraw();
  403. }
  404. void
  405. Mixer::insert ( Mixer_Strip *ms, int i )
  406. {
  407. Mixer_Strip *before = (Mixer_Strip*)mixer_strips->child( i );
  408. insert( ms, before);
  409. }
  410. void
  411. Mixer::move_left ( Mixer_Strip *ms )
  412. {
  413. int i = mixer_strips->find( ms );
  414. if ( i > 0 )
  415. insert( ms, i - 1 );
  416. }
  417. void
  418. Mixer::move_right ( Mixer_Strip *ms )
  419. {
  420. int i = mixer_strips->find( ms );
  421. if ( i < mixer_strips->children() - 1 )
  422. insert( ms, i + 2 );
  423. }
  424. void Mixer::remove ( Mixer_Strip *ms )
  425. {
  426. MESSAGE( "Remove mixer strip \"%s\"", ms->name() );
  427. mixer_strips->remove( ms );
  428. if ( parent() )
  429. parent()->redraw();
  430. }
  431. bool
  432. Mixer::contains ( Mixer_Strip *ms )
  433. {
  434. return ms->parent() == mixer_strips;
  435. }
  436. /* set the ideal number of rows... All may not actually fit. */
  437. void
  438. Mixer::rows ( int ideal_rows )
  439. {
  440. int sh;
  441. int actual_rows = 1;
  442. if ( ideal_rows > 1 )
  443. {
  444. sh = (scroll->h() / ideal_rows ) - (mixer_strips->vspacing() * (ideal_rows - 1));
  445. mixer_strips->flow( true );
  446. if ( sh < Mixer_Strip::min_h() )
  447. {
  448. int can_fit = ( scroll->h() - 18 ) / Mixer_Strip::min_h();
  449. actual_rows = can_fit > 0 ? can_fit : 1;
  450. }
  451. else
  452. actual_rows = ideal_rows;
  453. }
  454. else
  455. actual_rows = 1;
  456. if ( 1 == actual_rows )
  457. {
  458. sh = (scroll->h() - 18);
  459. mixer_strips->flow( false );
  460. actual_rows = 1;
  461. }
  462. int tw = 0;
  463. for ( int i = 0; i < mixer_strips->children(); ++i )
  464. {
  465. Mixer_Strip *t = (Mixer_Strip*)mixer_strips->child( i );
  466. t->size( t->w(), sh );
  467. tw += t->w() + mixer_strips->hspacing();
  468. }
  469. if ( actual_rows > 1 )
  470. mixer_strips->size( scroll->w() - 18, mixer_strips->h() );
  471. else
  472. mixer_strips->size( tw, mixer_strips->h() );
  473. _rows = ideal_rows;
  474. scroll->redraw();
  475. }
  476. /** retrun a pointer to the track named /name/, or NULL if no track is named /name/ */
  477. Mixer_Strip *
  478. Mixer::track_by_name ( const char *name )
  479. {
  480. for ( int i = mixer_strips->children(); i-- ; )
  481. {
  482. Mixer_Strip *t = (Mixer_Strip*)mixer_strips->child( i );
  483. if ( ! strcmp( name, t->name() ) )
  484. return t;
  485. }
  486. return NULL;
  487. }
  488. /** return a malloc'd string representing a unique name for a new track */
  489. char *
  490. Mixer::get_unique_track_name ( const char *name )
  491. {
  492. char pat[256];
  493. strcpy( pat, name );
  494. for ( int i = 1; track_by_name( pat ); ++i )
  495. snprintf( pat, sizeof( pat ), "%s.%d", name, i );
  496. return strdup( pat );
  497. }
  498. void
  499. Mixer::handle_dirty ( int d, void *v )
  500. {
  501. //Mixer *m = (Mixer*)v;
  502. if ( !nsm )
  503. return;
  504. if ( d == 1 )
  505. nsm->is_dirty();
  506. else if ( d == 0 )
  507. nsm->is_clean();
  508. }
  509. void
  510. Mixer::snapshot ( void )
  511. {
  512. for ( int i = 0; i < mixer_strips->children(); ++i )
  513. ((Mixer_Strip*)mixer_strips->child( i ))->log_children();
  514. }
  515. void
  516. Mixer::new_strip ( void )
  517. {
  518. add( new Mixer_Strip( get_unique_track_name( "Unnamed" ) ) );
  519. }
  520. bool
  521. Mixer::save ( void )
  522. {
  523. MESSAGE( "Saving state" );
  524. Loggable::snapshot_callback( &Mixer::snapshot, this );
  525. Loggable::snapshot( "snapshot" );
  526. return true;
  527. }
  528. static const char options_filename[] = "options";
  529. void
  530. Mixer::load_options ( void )
  531. {
  532. // save options
  533. char *path;
  534. asprintf( &path, "%s/options", user_config_dir );
  535. ((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Options" ), path );
  536. free( path );
  537. }
  538. void
  539. Mixer::save_options ( void )
  540. {
  541. char *path;
  542. asprintf( &path, "%s/%s", user_config_dir, options_filename );
  543. ((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Options" ), path );
  544. free( path );
  545. }
  546. void
  547. Mixer::update_menu ( void )
  548. {
  549. bool b = Project::open();
  550. if ( b )
  551. {
  552. ((Fl_Menu_Item*)menubar->find_item( "&Mixer" ))->flags &= ~FL_MENU_INACTIVE;
  553. ((Fl_Menu_Item*)menubar->find_item( "&Project/&Save" ))->flags &= ~FL_MENU_INACTIVE;
  554. mixer_strips->activate();
  555. }
  556. else
  557. {
  558. ((Fl_Menu_Item*)menubar->find_item( "&Mixer" ))->flags |= FL_MENU_INACTIVE;
  559. ((Fl_Menu_Item*)menubar->find_item( "&Project/&Save" ))->flags |= FL_MENU_INACTIVE;
  560. mixer_strips->deactivate();
  561. }
  562. project_name->label( Project::name() );
  563. }
  564. int
  565. Mixer::handle ( int m )
  566. {
  567. if ( Fl_Group::handle( m ) )
  568. return 1;
  569. switch ( m )
  570. {
  571. case FL_ENTER:
  572. case FL_LEAVE:
  573. return 1;
  574. }
  575. return 0;
  576. }
  577. void
  578. Mixer::discover_peers ( void )
  579. {
  580. if ( nsm->is_active() )
  581. {
  582. lo_message m = lo_message_new();
  583. lo_message_add_string( m, "/non/finger" );
  584. lo_message_add_string( m, osc_endpoint->url() );
  585. nsm->broadcast( m );
  586. lo_message_free( m );
  587. }
  588. }
  589. /************/
  590. /* Commands */
  591. /************/
  592. bool
  593. Mixer::command_save ( void )
  594. {
  595. return Project::save();
  596. }
  597. bool
  598. Mixer::command_load ( const char *path, const char *display_name )
  599. {
  600. mixer->hide();
  601. if ( Project::open( path ) )
  602. {
  603. // fl_alert( "Error opening project specified on commandline: %s", Project::errstr( err ) );
  604. return false;
  605. }
  606. if ( display_name )
  607. Project::name( display_name );
  608. update_menu();
  609. mixer->show();
  610. return true;
  611. }
  612. bool
  613. Mixer::command_new ( const char *path, const char *display_name )
  614. {
  615. if ( ! Project::create( path, "" ) )
  616. return false;
  617. if ( display_name )
  618. Project::name( display_name );
  619. update_menu();
  620. return true;
  621. // fl_alert( "Error creating project!" );
  622. }
  623. void
  624. Mixer::command_quit ( void )
  625. {
  626. if ( Loggable::dirty() )
  627. {
  628. int i = fl_choice( "There have been changes since the last save. Quitting now will discard them", "Discard", "Cancel", NULL );
  629. if ( i != 0 )
  630. return;
  631. }
  632. quit();
  633. }
  634. /* */
  635. void
  636. Mixer::command_add_strip ( void )
  637. {
  638. new_strip();
  639. }