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.

156 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 <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 "Audio_Region.H"
  25. #include "Sequence.H"
  26. #include "Audio_Sequence.H"
  27. #include "Timeline.H"
  28. #include "Tempo_Sequence.H"
  29. #include "Time_Sequence.H"
  30. #include "Annotation_Sequence.H"
  31. #include "Control_Sequence.H"
  32. #include "Transport.H"
  33. #include "Loggable.H"
  34. #include "Track.H"
  35. #include "Engine.H"
  36. #include "TLE.H"
  37. #include "../FL/Boxtypes.H"
  38. #include <stdlib.h>
  39. #include <sys/stat.h>
  40. #include "Project.H"
  41. #include "LASH.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 "debug.h"
  54. char *user_config_dir;
  55. #include <errno.h>
  56. static int
  57. ensure_dirs ( void )
  58. {
  59. asprintf( &user_config_dir, "%s/%s", getenv( "HOME" ), USER_CONFIG_DIR );
  60. int r = mkdir( user_config_dir, 0777 );
  61. return r == 0 || errno == EEXIST;
  62. }
  63. const float lash_poll_interval = 0.2f;
  64. static void
  65. lash_cb ( void *arg )
  66. {
  67. lash->poll();
  68. Fl::repeat_timeout( lash_poll_interval, lash_cb, 0 );
  69. }
  70. #include <FL/Fl_Shared_Image.H>
  71. int
  72. main ( int argc, char **argv )
  73. {
  74. fl_register_images();
  75. /* welcome to C++ */
  76. LOG_REGISTER_CREATE( Annotation_Point );
  77. LOG_REGISTER_CREATE( Annotation_Region );
  78. LOG_REGISTER_CREATE( Annotation_Sequence );
  79. LOG_REGISTER_CREATE( Audio_Region );
  80. LOG_REGISTER_CREATE( Audio_Sequence );
  81. LOG_REGISTER_CREATE( Control_Point );
  82. LOG_REGISTER_CREATE( Control_Sequence );
  83. LOG_REGISTER_CREATE( Tempo_Point );
  84. LOG_REGISTER_CREATE( Time_Point );
  85. LOG_REGISTER_CREATE( Track );
  86. init_boxtypes();
  87. if ( ! ensure_dirs() )
  88. FATAL( "Cannot create required directories" );
  89. printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT );
  90. tle = new TLE;
  91. MESSAGE( "Initializing JACK" );
  92. /* we don't really need a pointer for this */
  93. engine = new Engine;
  94. engine->init();
  95. /* always start stopped (please imagine for me a realistic
  96. * scenario requiring otherwise */
  97. transport->stop();
  98. MESSAGE( "Initializing LASH" );
  99. lash = new LASH;
  100. lash->init( APP_NAME, APP_TITLE, &argc, &argv );
  101. Fl::add_timeout( lash_poll_interval, lash_cb, 0 );
  102. if ( argc > 1 )
  103. if ( ! Project::open( argv[ 1 ] ) )
  104. FATAL( "Could not open project specified on command line" );
  105. /* FIXME: open project in /tmp if none is given? */
  106. MESSAGE( "Starting GUI" );
  107. tle->run();
  108. MESSAGE( "Your fun is over" );
  109. }