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.

161 lines
4.2KB

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