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.

150 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. /* TODO: put these in a header */
  47. #define USER_CONFIG_DIR ".non-daw/"
  48. const char APP_NAME[] = "Non-DAW";
  49. const char APP_TITLE[] = "The Non-DAW (Digital Audio Workstation)";
  50. const char COPYRIGHT[] = "Copyright (C) 2008 Jonathan Moore Liles";
  51. #define PACKAGE "non"
  52. #include "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. const float lash_poll_interval = 0.2f;
  63. static void
  64. lash_cb ( void *arg )
  65. {
  66. lash->poll();
  67. Fl::repeat_timeout( lash_poll_interval, lash_cb, 0 );
  68. }
  69. int
  70. main ( int argc, char **argv )
  71. {
  72. /* welcome to C++ */
  73. LOG_REGISTER_CREATE( Annotation_Point );
  74. LOG_REGISTER_CREATE( Annotation_Region );
  75. LOG_REGISTER_CREATE( Annotation_Sequence );
  76. LOG_REGISTER_CREATE( Audio_Region );
  77. LOG_REGISTER_CREATE( Audio_Sequence );
  78. LOG_REGISTER_CREATE( Control_Point );
  79. LOG_REGISTER_CREATE( Control_Sequence );
  80. LOG_REGISTER_CREATE( Tempo_Point );
  81. LOG_REGISTER_CREATE( Time_Point );
  82. LOG_REGISTER_CREATE( Track );
  83. init_boxtypes();
  84. if ( ! ensure_dirs() )
  85. FATAL( "Cannot create required directories" );
  86. printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT );
  87. TLE tle;
  88. MESSAGE( "Initializing JACK" );
  89. /* we don't really need a pointer for this */
  90. engine = new Engine;
  91. engine->init();
  92. /* always start stopped (please imagine for me a realistic
  93. * scenario requiring otherwise */
  94. transport->stop();
  95. MESSAGE( "Initializing LASH" );
  96. lash = new LASH;
  97. lash->init( APP_NAME, APP_TITLE, &argc, &argv );
  98. Fl::add_timeout( lash_poll_interval, lash_cb, 0 );
  99. if ( argc > 1 )
  100. if ( ! Project::open( argv[ 1 ] ) )
  101. FATAL( "Could not open project specified on command line" );
  102. /* FIXME: open project in /tmp if none is given? */
  103. MESSAGE( "Starting GUI" );
  104. // tle.main_window->show( argc, argv );
  105. tle.run();
  106. MESSAGE( "Your fun is over" );
  107. }