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.0KB

  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 <FL/Fl.H>
  19. #include <stdio.h>
  20. #include <unistd.h>
  21. #include <sys/stat.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <stdlib.h>
  25. /* for registrations */
  26. #include "Audio_Region.H"
  27. #include "Sequence.H"
  28. #include "Audio_Sequence.H"
  29. #include "Timeline.H"
  30. #include "Tempo_Sequence.H"
  31. #include "Time_Sequence.H"
  32. #include "Annotation_Sequence.H"
  33. #include "Control_Sequence.H"
  34. #include "Track.H"
  35. #include "TLE.H"
  36. #include "../FL/Boxtypes.H"
  37. #include "Project.H"
  38. #include "LASH.H"
  39. #include "Transport.H"
  40. #include "Engine/Engine.H"
  41. #include "util/Thread.H"
  42. Engine *engine;
  43. Timeline *timeline;
  44. Transport *transport;
  45. LASH *lash;
  46. TLE *tle;
  47. /* TODO: put these in a header */
  48. #define USER_CONFIG_DIR ".non-daw/"
  49. const char APP_NAME[] = "Non-DAW";
  50. const char APP_TITLE[] = "The Non-DAW";
  51. const char COPYRIGHT[] = "Copyright (C) 2008 Jonathan Moore Liles";
  52. #define PACKAGE "non"
  53. #include "const.h"
  54. #include "util/debug.h"
  55. char *user_config_dir;
  56. #include <errno.h>
  57. static int
  58. ensure_dirs ( void )
  59. {
  60. asprintf( &user_config_dir, "%s/%s", getenv( "HOME" ), USER_CONFIG_DIR );
  61. int r = mkdir( user_config_dir, 0777 );
  62. return r == 0 || errno == EEXIST;
  63. }
  64. #include <FL/Fl_Shared_Image.H>
  65. #include <signal.h>
  66. int
  67. main ( int argc, char **argv )
  68. {
  69. Thread::init();
  70. Thread thread( "UI" );
  71. thread.set();
  72. fl_register_images();
  73. /* welcome to C++ */
  74. LOG_REGISTER_CREATE( Annotation_Point );
  75. LOG_REGISTER_CREATE( Annotation_Region );
  76. LOG_REGISTER_CREATE( Annotation_Sequence );
  77. LOG_REGISTER_CREATE( Audio_Region );
  78. LOG_REGISTER_CREATE( Audio_Sequence );
  79. LOG_REGISTER_CREATE( Control_Point );
  80. LOG_REGISTER_CREATE( Control_Sequence );
  81. LOG_REGISTER_CREATE( Tempo_Point );
  82. LOG_REGISTER_CREATE( Time_Point );
  83. LOG_REGISTER_CREATE( Track );
  84. init_boxtypes();
  85. signal( SIGPIPE, SIG_IGN );
  86. if ( ! ensure_dirs() )
  87. FATAL( "Cannot create required directories" );
  88. printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT );
  89. tle = new TLE;
  90. MESSAGE( "Initializing JACK" );
  91. /* we don't really need a pointer for this */
  92. engine = new Engine;
  93. const char *jack_name;
  94. if ( ! ( jack_name = engine->init() ) )
  95. FATAL( "Could not connect to JACK!" );
  96. /* always start stopped (please imagine for me a realistic
  97. * scenario requiring otherwise */
  98. transport->stop();
  99. MESSAGE( "Initializing LASH" );
  100. lash = new LASH;
  101. lash->init( jack_name, APP_TITLE, &argc, &argv );
  102. MESSAGE( "Starting GUI" );
  103. tle->run();
  104. if ( argc > 1 )
  105. tle->open( argv[ 1 ] );
  106. Fl::run();
  107. MESSAGE( "Your fun is over" );
  108. }