From 426600ed8bdb68c07b57cdc69b006851609fffdb Mon Sep 17 00:00:00 2001 From: angel Date: Sun, 12 Jun 2005 16:36:21 +0000 Subject: [PATCH] All useful code from wav.c have been ported into main.c (Closes: #1075, #1076). git-svn-id: file:///home/angel/tmp/svn-triptico/ahxm/trunk@675 c87de0a0-a11c-0410-a1e5-866214bc28b2 --- TODO | 8 +++--- VERSION | 2 +- annhell.h | 2 +- main.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- makefile.in | 10 +++----- 5 files changed, 80 insertions(+), 27 deletions(-) diff --git a/TODO b/TODO index df4c6b9..ba44a19 100644 --- a/TODO +++ b/TODO @@ -10,9 +10,7 @@ Release Critical Bugs * 1067: Fill the extended commands document. * 1071: Add the posibility to start a song from a given measure or time. * 1074: Add configuration file support. - * 1075: Unify everything inside the same executable. - * 1076: Make the unified executable to accept all options as command - line arguments. + * 1079: Add midiin.c functionality to main.c. Open Bugs --------- @@ -184,5 +182,9 @@ Closed * 1077: Delete all stdout crap (Sat, 11 Jun 2005 20:27:43 +0200). * 1078: After a measure change, all measure bar checks break (Sat, 11 Jun 2005 21:03:24 +0200). + * 1075: Unify everything inside the same executable (closed by #1079; + Sun, 12 Jun 2005 18:34:35 +0200). + * 1076: Make the unified executable to accept all options as command + line arguments (Sun, 12 Jun 2005 18:34:40 +0200). Email bugs to angel@triptico.com diff --git a/VERSION b/VERSION index 890cde0..3f810f3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -#define VERSION "0.6" +#define VERSION "1.0.0-pre0" diff --git a/annhell.h b/annhell.h index 09281b1..c362fdc 100644 --- a/annhell.h +++ b/annhell.h @@ -420,7 +420,7 @@ int midi_song_play(void); int compile(char * code); int compile_file(char * file); -/* in main.c */ +/* in support.c */ void add_to_library_path(char * path); FILE * path_fopen(char * filename, char * mode); diff --git a/main.c b/main.c index e87b830..52bcedb 100644 --- a/main.c +++ b/main.c @@ -35,6 +35,9 @@ Data ********************/ +static char * devfile=NULL; +static char * driver="default"; + /******************* Code ********************/ @@ -44,10 +47,10 @@ static void read_config(void) } -static void main_usage(void) +static int main_usage(void) { - printf("Ann Hell Ex Machina - Music Writing Software\n"); - printf("Copyright (C) 1991-2004 Angel Ortega \n"); + printf("Ann Hell Ex Machina %s - Music Writing Software\n", VERSION); + printf("Copyright (C) 2003-2005 Angel Ortega \n"); printf("This software is covered by the GPL license. NO WARRANTY.\n\n"); printf("Usage: annhell [options] {script.ahs}\n\n"); printf("Options:\n\n"); @@ -63,19 +66,64 @@ static void main_usage(void) printf("-M Output song to MIDI device instead of softsynth.\n"); printf("-I Interactive; read from MIDI device and\n"); printf(" use {script} as instrument.\n"); + + return(1); +} + + +static int main_interactive(char * script_or_ins) +{ + return(0); +} + + +static int main_midi(char * script) +{ + if(compile_file(script)) + return(3); + + midi_song_play(); + + return(0); +} + + +static int main_ss(char * script) +{ + if(ss_output_open(driver, devfile) < 0) + { + printf("Error: can't init driver\n"); + return(2); + } + + if(compile_file(script)) + return(3); + + ss_song_render(); + + ss_output_close(); + + printf("clipped: %d optimal volume: %f\n", + ss_output_clipped, ss_optimal_volume); + + return(0); } static int annhell_main(int argc, char * argv[]) { + int ret=1; int n=1; char * opt=NULL; - char * devfile=NULL; - char * driver=NULL; char * script=NULL; int midi=0; int interactive=0; + if(argc == 1) + return(main_usage()); + + read_config(); + while(n < argc - 1) { opt=argv[n++]; @@ -134,19 +182,26 @@ static int annhell_main(int argc, char * argv[]) midi=1; } else - { - main_usage(); - return(1); - } + return(main_usage()); } - if(script == NULL) - { - main_usage(); - return(1); - } + script=argv[argc - 1]; - return(0); + if(*script == '-') + return(main_usage()); + + /* HACK */ + add_to_library_path("/home/angel/annhell/"); + + if(interactive) + ret=main_interactive(script); + else + if(midi) + ret=main_midi(script); + else + ret=main_ss(script); + + return(ret); } diff --git a/makefile.in b/makefile.in index 6003584..25be2ab 100644 --- a/makefile.in +++ b/makefile.in @@ -3,7 +3,7 @@ PROJ=annhell LIB=lib$(PROJ).a DOCS= -BIN=wav midiin +BIN=annhell midiin OBJS=support.o song.o compiler_l.o compiler_y.o \ ss_core.o ss_input.o ss_gen.o ss_eff.o ss_ins.o ss_song.o \ @@ -68,12 +68,8 @@ dist: distclean ChangeLog y.tab.c y.tab.h lex.yy.c dep: gcc -MM *.c > makefile.depend -#install: -# install $(BIN) $(PREFIX)/bin +install: + install annhell $(PREFIX)/bin # mkdir -p $(PREFIX)/share/doc/$(PROJ) # cp $(DOCS) $(PREFIX)/share/doc/$(PROJ) -#qq: compiler_l.o compiler_y.o -# cc compiler_l.o compiler_y.o -L. -lannhell -lm -o qq - - -- 2.11.4.GIT