Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
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.

153 lines
4.1KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 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. #include <stdlib.h>
  19. #include <unistd.h>
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22. #include <FL/Fl.H>
  23. #include <FL/Fl_Double_Window.H>
  24. #include <FL/Fl_Scroll.H>
  25. #include <FL/Fl_Tooltip.H>
  26. #include <FL/fl_ask.H>
  27. #include <FL/Fl_Pack.H>
  28. #include <FL/Boxtypes.H>
  29. #include "util/Thread.H"
  30. #include "util/debug.h"
  31. #include "Mixer.H"
  32. #include "Project.H"
  33. #include "Loggable.H"
  34. /* for registration */
  35. #include "Module.H"
  36. #include "Gain_Module.H"
  37. #include "Plugin_Module.H"
  38. #include "JACK_Module.H"
  39. #include "Meter_Module.H"
  40. #include "Meter_Indicator_Module.H"
  41. #include "Controller_Module.H"
  42. #include "Mono_Pan_Module.H"
  43. #include "Chain.H"
  44. #include "Mixer_Strip.H"
  45. /* TODO: put these in a header */
  46. #define USER_CONFIG_DIR ".non-mixer/"
  47. char *user_config_dir;
  48. Mixer *mixer;
  49. #include <errno.h>
  50. static int
  51. ensure_dirs ( void )
  52. {
  53. asprintf( &user_config_dir, "%s/%s", getenv( "HOME" ), USER_CONFIG_DIR );
  54. int r = mkdir( user_config_dir, 0777 );
  55. return r == 0 || errno == EEXIST;
  56. }
  57. #include <signal.h>
  58. static void cb_main ( Fl_Double_Window *o, void *v )
  59. {
  60. if ( Fl::event_key() != FL_Escape )
  61. o->hide();
  62. }
  63. int
  64. main ( int argc, char **argv )
  65. {
  66. Thread::init();
  67. Thread thread( "UI" );
  68. thread.set();
  69. ensure_dirs();
  70. Fl_Tooltip::color( FL_BLACK );
  71. Fl_Tooltip::textcolor( FL_YELLOW );
  72. Fl_Tooltip::size( 14 );
  73. Fl_Tooltip::hoverdelay( 0.1f );
  74. Fl::visible_focus( 0 );
  75. LOG_REGISTER_CREATE( Mixer_Strip );
  76. LOG_REGISTER_CREATE( Chain );
  77. LOG_REGISTER_CREATE( Plugin_Module );
  78. LOG_REGISTER_CREATE( Gain_Module );
  79. LOG_REGISTER_CREATE( Meter_Module );
  80. LOG_REGISTER_CREATE( JACK_Module );
  81. LOG_REGISTER_CREATE( Mono_Pan_Module );
  82. LOG_REGISTER_CREATE( Meter_Indicator_Module );
  83. LOG_REGISTER_CREATE( Controller_Module );
  84. init_boxtypes();
  85. signal( SIGPIPE, SIG_IGN );
  86. Fl::get_system_colors();
  87. Fl::scheme( "plastic" );
  88. Plugin_Module::spawn_discover_thread();
  89. Fl_Double_Window *main_window;
  90. {
  91. Fl_Double_Window *o = main_window = new Fl_Double_Window( 800, 600, "Mixer" );
  92. {
  93. Fl_Widget *o = mixer = new Mixer( 0, 0, main_window->w(), main_window->h(), NULL );
  94. Fl_Group::current()->resizable(o);
  95. }
  96. o->end();
  97. o->callback( (Fl_Callback*)cb_main, main_window );
  98. o->show( argc, argv );
  99. }
  100. {
  101. if ( argc > 1 )
  102. {
  103. MESSAGE( "Loading \"%s\"", argv[1] );
  104. if ( ! mixer->command_load( argv[1] ) )
  105. {
  106. fl_alert( "Error opening project specified on commandline" );
  107. }
  108. }
  109. else
  110. {
  111. WARNING( "Running without a project--nothing will be saved." );
  112. }
  113. }
  114. Fl::run();
  115. delete main_window;
  116. main_window = NULL;
  117. MESSAGE( "Your fun is over" );
  118. }