Begin to support session directories. Show session name in TLE.tags/non-daw-v1.1.0
@@ -169,7 +169,7 @@ public: | |||||
void | void | ||||
register_create ( const char *name, create_func *func ) | register_create ( const char *name, create_func *func ) | ||||
{ | { | ||||
printf( "registering %s to %p\n", name, func ); | |||||
// printf( "registering %s to %p\n", name, func ); | |||||
_class_map[ string( name ) ] = func; | _class_map[ string( name ) ] = func; | ||||
} | } | ||||
@@ -31,6 +31,8 @@ | |||||
#include "dsp.h" | #include "dsp.h" | ||||
#include "debug.h" | |||||
bool | bool | ||||
Playback_DS::seek_pending ( void ) | Playback_DS::seek_pending ( void ) | ||||
{ | { | ||||
@@ -45,7 +47,7 @@ Playback_DS::seek_pending ( void ) | |||||
void | void | ||||
Playback_DS::seek ( nframes_t frame ) | Playback_DS::seek ( nframes_t frame ) | ||||
{ | { | ||||
printf( "requesting seek\n" ); | |||||
DMESSAGE( "requesting seek" ); | |||||
if ( seek_pending() ) | if ( seek_pending() ) | ||||
printf( "seek error, attempt to seek while seek is pending\n" ); | printf( "seek error, attempt to seek while seek is pending\n" ); | ||||
@@ -92,7 +94,7 @@ void | |||||
Playback_DS::disk_thread ( void ) | Playback_DS::disk_thread ( void ) | ||||
{ | { | ||||
printf( "IO thread running...\n" ); | |||||
DMESSAGE( "playback thread running" ); | |||||
/* buffer to hold the interleaved data returned by the track reader */ | /* buffer to hold the interleaved data returned by the track reader */ | ||||
sample_t *buf = new sample_t[ _nframes * channels() * _disk_io_blocks ]; | sample_t *buf = new sample_t[ _nframes * channels() * _disk_io_blocks ]; | ||||
@@ -111,7 +113,8 @@ Playback_DS::disk_thread ( void ) | |||||
if ( seek_pending() ) | if ( seek_pending() ) | ||||
{ | { | ||||
printf( "performing seek\n" ); | |||||
DMESSAGE( "performing seek" ); | |||||
_frame = _pending_seek; | _frame = _pending_seek; | ||||
_pending_seek = -1; | _pending_seek = -1; | ||||
blocks_ready = 1; | blocks_ready = 1; | ||||
@@ -189,7 +192,7 @@ Playback_DS::disk_thread ( void ) | |||||
} | } | ||||
printf( "IO thread terminating.\n" ); | |||||
DMESSAGE( "playback thread terminating" ); | |||||
delete[] buf; | delete[] buf; | ||||
#ifndef AVOID_UNNECESSARY_COPYING | #ifndef AVOID_UNNECESSARY_COPYING | ||||
@@ -29,6 +29,8 @@ | |||||
#include "dsp.h" | #include "dsp.h" | ||||
#include "debug.h" | |||||
/* THREAD: IO */ | /* THREAD: IO */ | ||||
/** write /nframes/ from buf to the capture file of the attached track */ | /** write /nframes/ from buf to the capture file of the attached track */ | ||||
void | void | ||||
@@ -54,7 +56,7 @@ Record_DS::write_block ( sample_t *buf, nframes_t nframes ) | |||||
void | void | ||||
Record_DS::disk_thread ( void ) | Record_DS::disk_thread ( void ) | ||||
{ | { | ||||
printf( "IO thread running...\n" ); | |||||
DMESSAGE( "capture thread running..." ); | |||||
const nframes_t nframes = _nframes * _disk_io_blocks; | const nframes_t nframes = _nframes * _disk_io_blocks; | ||||
@@ -134,8 +136,7 @@ Record_DS::disk_thread ( void ) | |||||
} | } | ||||
printf( "IO thread terminating.\n" ); | |||||
DMESSAGE( "capture thread terminating" ); | |||||
/* flush what remains in the buffer out to disk */ | /* flush what remains in the buffer out to disk */ | ||||
@@ -232,7 +233,7 @@ Record_DS::stop ( nframes_t frame ) | |||||
_th->stop( frame ); | _th->stop( frame ); | ||||
printf( "recording finished\n" ); | |||||
DMESSAGE( "recording finished" ); | |||||
} | } | ||||
@@ -31,6 +31,9 @@ decl {\#include <FL/fl_ask.H>} {} | |||||
decl {\#include <FL/Fl.H>} {} | decl {\#include <FL/Fl.H>} {} | ||||
decl {extern char session_display_name[256];} {global | |||||
} | |||||
decl {extern char *user_config_dir;} {global | decl {extern char *user_config_dir;} {global | ||||
} | } | ||||
@@ -227,7 +230,7 @@ exit( 0 );} | |||||
} | } | ||||
MenuItem {} { | MenuItem {} { | ||||
label {&Fit} | label {&Fit} | ||||
callback {timeline->zoom_fit();} selected | |||||
callback {timeline->zoom_fit();} | |||||
xywh {10 10 40 25} divider | xywh {10 10 40 25} divider | ||||
} | } | ||||
MenuItem {} { | MenuItem {} { | ||||
@@ -532,6 +535,11 @@ delete win;} | |||||
code0 {timeline = o;} | code0 {timeline = o;} | ||||
class Timeline | class Timeline | ||||
} | } | ||||
Fl_Box {} { | |||||
label {<session name>} selected | |||||
xywh {450 0 475 22} labeltype SHADOW_LABEL labelfont 2 | |||||
code0 {o->label( session_display_name );} | |||||
} | |||||
Fl_Value_Output xruns_output { | Fl_Value_Output xruns_output { | ||||
label {xruns:} | label {xruns:} | ||||
xywh {980 2 44 20} maximum 40000 step 1 | xywh {980 2 44 20} maximum 40000 step 1 | ||||
@@ -17,22 +17,8 @@ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||||
/*******************************************************************************/ | /*******************************************************************************/ | ||||
#include <FL/Fl.H> | #include <FL/Fl.H> | ||||
#include <FL/Fl_Window.H> | |||||
#include <FL/Fl_Double_Window.H> | |||||
#include <FL/Fl_Overlay_Window.H> | |||||
#include <FL/Fl_Scroll.H> | |||||
// #include <FL/Fl_Scrollbar.H> | |||||
#include <FL/Fl_Pack.H> | |||||
#include <FL/Fl_Group.H> | |||||
#include <FL/Fl_Slider.H> | |||||
#include <FL/Fl_Button.H> | |||||
#include "Scalebar.H" | |||||
// #include "Waveform.H" | |||||
#include "Region.H" | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
@@ -40,6 +26,7 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "Region.H" | |||||
#include "Sequence.H" | #include "Sequence.H" | ||||
#include "Audio_Sequence.H" | #include "Audio_Sequence.H" | ||||
#include "Timeline.H" | #include "Timeline.H" | ||||
@@ -55,8 +42,6 @@ | |||||
#include "Engine.H" | #include "Engine.H" | ||||
// #include "Clock.H" | |||||
#include "TLE.H" | #include "TLE.H" | ||||
#include "../FL/Boxtypes.H" | #include "../FL/Boxtypes.H" | ||||
@@ -64,28 +49,94 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
Engine *engine; | Engine *engine; | ||||
Timeline *timeline; | Timeline *timeline; | ||||
Transport *transport; | Transport *transport; | ||||
/* void cb_undo ( Fl_Widget *w, void *v ) */ | |||||
/* { */ | |||||
/* Loggable::undo(); */ | |||||
/* } */ | |||||
#define VERSION "0.5.0" | |||||
/* TODO: put these in a header */ | |||||
#define USER_CONFIG_DIR ".non-daw/" | |||||
const char APP_NAME[] = "Non-DAW"; | |||||
const char APP_TITLE[] = "The Non-DAW (Digital Audio Workstation)"; | |||||
const char COPYRIGHT[] = "Copyright (C) 2008 Jonathan Moore Liles"; | |||||
#define PACKAGE "non" | |||||
#include "debug.h" | |||||
char *user_config_dir; | char *user_config_dir; | ||||
char session_display_name[256]; | |||||
void | |||||
set_display_name ( const char *name ) | |||||
{ | |||||
char *s = rindex( name, '/' ); | |||||
strcpy( session_display_name, s ? s : name ); | |||||
for ( s = session_display_name; *s; ++s ) | |||||
if ( *s == '_' || *s == '-' ) | |||||
*s = ' '; | |||||
} | |||||
static int | |||||
exists ( const char *name ) | |||||
{ | |||||
struct stat st; | |||||
return 0 == stat( name, &st ); | |||||
} | |||||
#include <errno.h> | |||||
static int | static int | ||||
ensure_dirs ( void ) | ensure_dirs ( void ) | ||||
{ | { | ||||
asprintf( &user_config_dir, "%s/.non-daw", getenv( "HOME" ) ); | |||||
asprintf( &user_config_dir, "%s/%s", getenv( "HOME" ), USER_CONFIG_DIR ); | |||||
return 0 == mkdir( user_config_dir, 0777 ); | |||||
int r = mkdir( user_config_dir, 0777 ); | |||||
return r == 0 || errno == EEXIST; | |||||
} | |||||
bool | |||||
create_session ( const char *name ) | |||||
{ | |||||
if ( exists( name ) ) | |||||
{ | |||||
WARNING( "Session already exists" ); | |||||
return false; | |||||
} | |||||
if ( mkdir( name, 0777 ) ) | |||||
{ | |||||
WARNING( "Cannot create session directory" ); | |||||
return false; | |||||
} | |||||
if ( chdir( name ) ) | |||||
FATAL( "WTF? Cannot change to new session directory" ); | |||||
mkdir( "sources", 0777 ); | |||||
set_display_name( name ); | |||||
/* TODO: load template */ | |||||
return true; | |||||
} | } | ||||
int | int | ||||
main ( int argc, char **argv ) | main ( int argc, char **argv ) | ||||
{ | { | ||||
*session_display_name = '\0'; | |||||
/* welcome to C++ */ | /* welcome to C++ */ | ||||
LOG_REGISTER_CREATE( Region ); | LOG_REGISTER_CREATE( Region ); | ||||
LOG_REGISTER_CREATE( Time_Point ); | LOG_REGISTER_CREATE( Time_Point ); | ||||
@@ -96,16 +147,37 @@ main ( int argc, char **argv ) | |||||
LOG_REGISTER_CREATE( Audio_Sequence ); | LOG_REGISTER_CREATE( Audio_Sequence ); | ||||
LOG_REGISTER_CREATE( Control_Sequence ); | LOG_REGISTER_CREATE( Control_Sequence ); | ||||
init_boxtypes(); | init_boxtypes(); | ||||
if ( ! ensure_dirs() ) | if ( ! ensure_dirs() ) | ||||
/* error */; | |||||
FATAL( "Cannot create required directories" ); | |||||
printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT ); | |||||
const char *pwd = getenv( "PWD" ); | |||||
/* TODO: change to seesion dir */ | |||||
if ( argc > 1 ) | |||||
{ | |||||
/* FIXME: what about FLTK arguments? */ | |||||
/* change to session dir */ | |||||
if ( chdir( argv[ 1 ] ) ) | |||||
FATAL( "Cannot change to session dir \"%s\"", argv[ 1 ] ); | |||||
else | |||||
pwd = argv[ 1 ]; | |||||
} | |||||
if ( ! exists( "history" ) || | |||||
! exists( "sources" ) ) | |||||
// ! exists( "options" ) ) | |||||
FATAL( "Not a Non-DAW session: \"%s\"", pwd ); | |||||
set_display_name( pwd ); | |||||
TLE tle; | TLE tle; | ||||
MESSAGE( "Initializing JACK" ); | |||||
/* we don't really need a pointer for this */ | /* we don't really need a pointer for this */ | ||||
engine = new Engine; | engine = new Engine; | ||||
engine->init(); | engine->init(); | ||||
@@ -114,11 +186,12 @@ main ( int argc, char **argv ) | |||||
* scenario requiring otherwise */ | * scenario requiring otherwise */ | ||||
transport->stop(); | transport->stop(); | ||||
MESSAGE( "Opening session" ); | |||||
Loggable::open( "history" ); | Loggable::open( "history" ); | ||||
// Fl::add_timeout( UPDATE_FREQ, clock_update_cb, o ); | |||||
tle.main_window->show( argc, argv ); | |||||
MESSAGE( "Starting GUI" ); | |||||
// tle.main_window->show( argc, argv ); | |||||
tle.main_window->show(); | |||||
Fl::run(); | Fl::run(); | ||||
} | } |
@@ -1,4 +1,6 @@ | |||||
Timeline_VERSION := 0.5.0 | |||||
Timeline_SRCS= \ | Timeline_SRCS= \ | ||||
Timeline/Audio_File.C \ | Timeline/Audio_File.C \ | ||||
Timeline/Audio_File_SF.C \ | Timeline/Audio_File_SF.C \ | ||||
@@ -26,12 +28,12 @@ Timeline/Transport.C \ | |||||
Timeline/Waveform.C \ | Timeline/Waveform.C \ | ||||
Timeline/dsp.C \ | Timeline/dsp.C \ | ||||
Timeline/main.C \ | Timeline/main.C \ | ||||
debug.C \ | |||||
Timeline_OBJS:=$(Timeline_SRCS:.C=.o) | Timeline_OBJS:=$(Timeline_SRCS:.C=.o) | ||||
$(Timeline_OBJS): Makefile | $(Timeline_OBJS): Makefile | ||||
Timeline_LIBS := $(FLTK_LIBS) $(JACK_LIBS) $(SNDFILE_LIBS) | Timeline_LIBS := $(FLTK_LIBS) $(JACK_LIBS) $(SNDFILE_LIBS) | ||||
Timeline/timeline: $(Timeline_OBJS) FL | Timeline/timeline: $(Timeline_OBJS) FL | ||||
@@ -0,0 +1,60 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* This program is free software; you can redistribute it and/or modify it */ | |||||
/* under the terms of the GNU General Public License as published by the */ | |||||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||||
/* option) any later version. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
#include "debug.h" | |||||
void | |||||
warnf ( warning_t level, | |||||
const char *module, | |||||
const char *file, | |||||
const char *function, size_t line, const char *fmt, ... ) | |||||
{ | |||||
va_list args; | |||||
static const char *level_tab[] = { | |||||
"message", "\033[1;32m", | |||||
"warning", "\033[1;33m", | |||||
"assertion", "\033[1;31m" | |||||
}; | |||||
if ( module ) | |||||
fprintf( stderr, "[%s] ", module ); | |||||
#ifndef NDEBUG | |||||
if ( file ) | |||||
fprintf( stderr, "%s", file ); | |||||
if ( line ) | |||||
fprintf( stderr, ":%i", line ); | |||||
if ( function ) | |||||
fprintf( stderr, " %s()", function ); | |||||
fprintf( stderr, ": " ); | |||||
#endif | |||||
if ( unsigned( ( level << 1 ) + 1 ) < | |||||
( sizeof( level_tab ) / sizeof( level_tab[0] ) ) ) | |||||
fprintf( stderr, "%s", level_tab[( level << 1 ) + 1] ); | |||||
if ( fmt ) | |||||
{ | |||||
va_start( args, fmt ); | |||||
vfprintf( stderr, fmt, args ); | |||||
va_end( args ); | |||||
} | |||||
fprintf( stderr, "\033[0m\n" ); | |||||
} |
@@ -0,0 +1,116 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* This program is free software; you can redistribute it and/or modify it */ | |||||
/* under the terms of the GNU General Public License as published by the */ | |||||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||||
/* option) any later version. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
/* debug.h | |||||
* | |||||
* 11/21/2003 - Jonathan Moore Liles | |||||
* | |||||
* Debuging support. | |||||
* | |||||
* Disable by defining the preprocessor variable NDEBUG prior to inclusion. | |||||
* | |||||
* The following macros sould be defined as string literals | |||||
* | |||||
* name value | |||||
* | |||||
* __MODULE__ Name of module. eg. "libfoo" | |||||
* | |||||
* __FILE__ Name of file. eg. "foo.c" | |||||
* | |||||
* __FUNCTION__ Name of enclosing function. eg. "bar" | |||||
* | |||||
* (inteter literal) | |||||
* __LINE__ Number of enclosing line. | |||||
* | |||||
* | |||||
* __FILE__, and __LINE__ are automatically defined by standard CPP | |||||
* implementations. __FUNCTION__ is more or less unique to GNU, and isn't | |||||
* strictly a preprocessor macro, but rather a reserved word in the compiler. | |||||
* There is a sed script available with this toolset that is able to fake | |||||
* __FUNCTION__ (among other things) with an extra preprocesessing step. | |||||
* | |||||
* __MODULE__ is nonstandard and should be defined the enclosing program(s). | |||||
* Autoconf defines PACKAGE as the module name, and these routines will use its | |||||
* value instead if __MODULE__ is undefined. | |||||
* | |||||
* The following routines are provided (as macros) and take the same arguments | |||||
* as printf(): | |||||
* | |||||
* MESSAGE( const char *format, ... ) | |||||
* WARNING( const char *format, ... ) | |||||
* FATAL( const char *format, ... ) | |||||
* | |||||
* Calling MESSAGE or WARNING prints the message to stderr along with module, | |||||
* file and line information, as well as appropriate emphasis. Calling | |||||
* FATAL will do the same, and then call abort() to end the program. It is | |||||
* unwise to supply any of these marcros with arguments that produce side | |||||
* effects. As, doing so will most likely result in Heisenbugs; program | |||||
* behavior that changes when debugging is disabled. | |||||
* | |||||
*/ | |||||
#ifndef _DEBUG_H | |||||
#define _DEBUG_H | |||||
#ifndef __MODULE__ | |||||
#ifdef PACKAGE | |||||
#define __MODULE__ PACKAGE | |||||
#else | |||||
#define __MODULE__ NULL | |||||
#endif | |||||
#endif | |||||
#ifndef __GNUC__ | |||||
#define __FUNCTION__ NULL | |||||
#endif | |||||
#include <string.h> | |||||
#include <stdio.h> | |||||
#include <stdarg.h> | |||||
typedef enum { | |||||
W_MESSAGE = 0, | |||||
W_WARNING, | |||||
W_FATAL | |||||
} warning_t; | |||||
void | |||||
warnf ( warning_t level, | |||||
const char *module, | |||||
const char *file, | |||||
const char *function, size_t line, const char *fmt, ... ); | |||||
#ifndef NDEBUG | |||||
#define DMESSAGE( fmt, args... ) warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ) | |||||
#define DWARNING( fmt, args... ) warnf( W_WARNING, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ) | |||||
#define ASSERT( pred, fmt, args... ) do { if ( ! (pred) ) { warnf( W_FATAL, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ); abort(); } } while ( 0 ) | |||||
#else | |||||
#define DMESSAGE( fmt, args... ) | |||||
#define DWARNING( fmt, args... ) | |||||
#define ASSERT( pred, fmt, args... ) | |||||
#endif | |||||
/* these are always defined */ | |||||
#define MESSAGE( fmt, args... ) warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ) | |||||
#define WARNING( fmt, args... ) warnf( W_WARNING, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ) | |||||
#define FATAL( fmt, args... ) ( warnf( W_FATAL, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ), abort() ) | |||||
#endif |