diff --git a/Makefile b/Makefile index a2379a2..6ac212a 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ prefix = /usr/local exec_prefix = ${prefix} srcdir = . -VPATH = . + bindir = ${exec_prefix}/bin libdir = ${exec_prefix}/lib datadir = ${prefix}/share @@ -57,12 +57,12 @@ binaries=abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch all : abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch -OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o +OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o music_utils.o abc2midi : $(OBJECTS_ABC2MIDI) $(CC) $(CFLAGS) -o abc2midi $(OBJECTS_ABC2MIDI) $(LDFLAGS) -lm $(OBJECTS_ABC2MIDI): abc.h parseabc.h config.h Makefile -OBJECTS_ABC2ABC=parseabc.o toabc.o +OBJECTS_ABC2ABC=parseabc.o toabc.o music_utils.o abc2abc : $(OBJECTS_ABC2ABC) $(CC) $(CFLAGS) -o abc2abc $(OBJECTS_ABC2ABC) $(LDFLAGS) $(OBJECTS_ABC2ABC): abc.h parseabc.h config.h Makefile @@ -77,7 +77,7 @@ mftext : $(OBJECTS_MFTEXT) $(CC) $(CFLAGS) -o mftext $(OBJECTS_MFTEXT) $(LDFLAGS) $(OBJECTS_MFTEXT): abc.h midifile.h config.h Makefile -OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o +OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o music_utils.o yaps : $(OBJECTS_YAPS) $(CC) $(CFLAGS) -o yaps $(OBJECTS_YAPS) $(LDFLAGS) $(OBJECTS_YAPS): abc.h midifile.h config.h Makefile @@ -87,11 +87,13 @@ midicopy : $(OBJECTS_MIDICOPY) $(CC) $(CFLAGS) -o midicopy $(OBJECTS_MIDICOPY) $(LDFLAGS) $(OBJECTS_MIDICOPY): abc.h midifile.h midicopy.h config.h Makefile -OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o +OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o music_utils.o abcmatch : $(OBJECTS_ABCMATCH) $(CC) $(CFLAGS) -o abcmatch $(OBJECTS_ABCMATCH) $(LDFLAGS) $(OBJECTS_ABCMATCH): abc.h midifile.h config.h Makefile +music_utils.o : music_utils.c music_utils.h + parseabc.o : parseabc.c abc.h parseabc.h parser2.o : parser2.c abc.h parseabc.h parser2.h diff --git a/Makefile.in b/Makefile.in index d136d99..9c02eb6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -57,12 +57,12 @@ binaries=abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch all : abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch -OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o +OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o music_utils.o abc2midi : $(OBJECTS_ABC2MIDI) $(CC) $(CFLAGS) -o abc2midi $(OBJECTS_ABC2MIDI) $(LDFLAGS) -lm $(OBJECTS_ABC2MIDI): abc.h parseabc.h config.h Makefile -OBJECTS_ABC2ABC=parseabc.o toabc.o +OBJECTS_ABC2ABC=parseabc.o toabc.o music_utils.o abc2abc : $(OBJECTS_ABC2ABC) $(CC) $(CFLAGS) -o abc2abc $(OBJECTS_ABC2ABC) $(LDFLAGS) $(OBJECTS_ABC2ABC): abc.h parseabc.h config.h Makefile @@ -77,7 +77,7 @@ mftext : $(OBJECTS_MFTEXT) $(CC) $(CFLAGS) -o mftext $(OBJECTS_MFTEXT) $(LDFLAGS) $(OBJECTS_MFTEXT): abc.h midifile.h config.h Makefile -OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o +OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o music_utils.o yaps : $(OBJECTS_YAPS) $(CC) $(CFLAGS) -o yaps $(OBJECTS_YAPS) $(LDFLAGS) $(OBJECTS_YAPS): abc.h midifile.h config.h Makefile @@ -87,11 +87,13 @@ midicopy : $(OBJECTS_MIDICOPY) $(CC) $(CFLAGS) -o midicopy $(OBJECTS_MIDICOPY) $(LDFLAGS) $(OBJECTS_MIDICOPY): abc.h midifile.h midicopy.h config.h Makefile -OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o +OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o music_utils.o abcmatch : $(OBJECTS_ABCMATCH) $(CC) $(CFLAGS) -o abcmatch $(OBJECTS_ABCMATCH) $(LDFLAGS) $(OBJECTS_ABCMATCH): abc.h midifile.h config.h Makefile +music_utils.o : music_utils.c music_utils.h + parseabc.o : parseabc.c abc.h parseabc.h parser2.o : parser2.c abc.h parseabc.h parser2.h diff --git a/VERSION b/VERSION index 089a03f..5efd24d 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -2020 October 09 2020 +2020 October 19 2020 diff --git a/abcmatch.c b/abcmatch.c index be41144..cf2ea4f 100644 --- a/abcmatch.c +++ b/abcmatch.c @@ -49,7 +49,7 @@ Matching: -#define VERSION "1.75 October 12 2020 abcmatch" +#define VERSION "1.76 October 19 2020 abcmatch" #include #include #include diff --git a/config.h b/config.h new file mode 100644 index 0000000..397a030 --- /dev/null +++ b/config.h @@ -0,0 +1,4 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in */ + + diff --git a/config.log b/config.log new file mode 100644 index 0000000..c23a207 --- /dev/null +++ b/config.log @@ -0,0 +1,469 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by abcmidi configure 2011-08-03, which was +generated by GNU Autoconf 2.67. Invocation command line was + + $ ./configure + +## --------- ## +## Platform. ## +## --------- ## + +hostname = seymour-VirtualBox +uname -m = x86_64 +uname -r = 5.4.0-51-generic +uname -s = Linux +uname -v = #56-Ubuntu SMP Mon Oct 5 14:28:49 UTC 2020 + +/usr/bin/uname -p = unknown +/bin/uname -X = unknown + +/bin/arch = unknown +/usr/bin/arch -k = unknown +/usr/convex/getsysinfo = unknown +/usr/bin/hostinfo = unknown +/bin/machine = unknown +/usr/bin/oslevel = unknown +/bin/universe = unknown + +PATH: /home/seymour/bin +PATH: /usr/local/sbin +PATH: /usr/local/bin +PATH: /usr/sbin +PATH: /usr/bin +PATH: /sbin +PATH: /bin +PATH: /usr/games +PATH: /usr/local/games +PATH: /snap/bin +PATH: /usr/local/bin +PATH: /home/seymour/jdk1.6.0_02/bin +PATH: /home/seymour/bin +PATH: . + + +## ----------- ## +## Core tests. ## +## ----------- ## + +configure:2174: checking for gcc +configure:2190: found /usr/bin/gcc +configure:2201: result: gcc +configure:2430: checking for C compiler version +configure:2439: gcc --version >&5 +gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 +Copyright (C) 2019 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:2450: $? = 0 +configure:2439: gcc -v >&5 +Using built-in specs. +COLLECT_GCC=gcc +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper +OFFLOAD_TARGET_NAMES=nvptx-none:hsa +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) +configure:2450: $? = 0 +configure:2439: gcc -V >&5 +gcc: error: unrecognized command line option '-V' +gcc: fatal error: no input files +compilation terminated. +configure:2450: $? = 1 +configure:2439: gcc -qversion >&5 +gcc: error: unrecognized command line option '-qversion'; did you mean '--version'? +gcc: fatal error: no input files +compilation terminated. +configure:2450: $? = 1 +configure:2470: checking whether the C compiler works +configure:2492: gcc conftest.c >&5 +configure:2496: $? = 0 +configure:2544: result: yes +configure:2547: checking for C compiler default output file name +configure:2549: result: a.out +configure:2555: checking for suffix of executables +configure:2562: gcc -o conftest conftest.c >&5 +configure:2566: $? = 0 +configure:2588: result: +configure:2610: checking whether we are cross compiling +configure:2618: gcc -o conftest conftest.c >&5 +configure:2622: $? = 0 +configure:2629: ./conftest +configure:2633: $? = 0 +configure:2621: result: no +configure:2626: checking for suffix of object files +configure:2648: gcc -c conftest.c >&5 +configure:2652: $? = 0 +configure:2673: result: o +configure:2677: checking whether we are using the GNU C compiler +configure:2696: gcc -c conftest.c >&5 +configure:2696: $? = 0 +configure:2705: result: yes +configure:2714: checking whether gcc accepts -g +configure:2734: gcc -c -g conftest.c >&5 +configure:2734: $? = 0 +configure:2775: result: yes +configure:2792: checking for gcc option to accept ISO C89 +configure:2856: gcc -c -g -O2 conftest.c >&5 +configure:2856: $? = 0 +configure:2869: result: none needed +configure:2947: checking for a BSD-compatible install +configure:3015: result: /usr/bin/install -c +configure:3030: checking for main in -lm +configure:3049: gcc -o conftest -O2 conftest.c -lm >&5 +configure:3049: $? = 0 +configure:3058: result: yes +configure:3076: checking how to run the C preprocessor +configure:3107: gcc -E conftest.c +configure:3107: $? = 0 +configure:3121: gcc -E conftest.c +conftest.c:10:10: fatal error: ac_nonexistent.h: No such file or directory + 10 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:3121: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "abcmidi" +| #define PACKAGE_TARNAME "abcmidi" +| #define PACKAGE_VERSION "2011-08-03" +| #define PACKAGE_STRING "abcmidi 2011-08-03" +| #define PACKAGE_BUGREPORT "fy733@ncf.ca" +| #define PACKAGE_URL "" +| #define HAVE_LIBM 1 +| /* end confdefs.h. */ +| #include +configure:3146: result: gcc -E +configure:3166: gcc -E conftest.c +configure:3166: $? = 0 +configure:3180: gcc -E conftest.c +conftest.c:10:10: fatal error: ac_nonexistent.h: No such file or directory + 10 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:3180: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "abcmidi" +| #define PACKAGE_TARNAME "abcmidi" +| #define PACKAGE_VERSION "2011-08-03" +| #define PACKAGE_STRING "abcmidi 2011-08-03" +| #define PACKAGE_BUGREPORT "fy733@ncf.ca" +| #define PACKAGE_URL "" +| #define HAVE_LIBM 1 +| /* end confdefs.h. */ +| #include +configure:3209: checking for grep that handles long lines and -e +configure:3267: result: /bin/grep +configure:3272: checking for egrep +configure:3334: result: /bin/grep -E +configure:3339: checking for ANSI C header files +configure:3359: gcc -c -O2 conftest.c >&5 +configure:3359: $? = 0 +configure:3432: gcc -o conftest -O2 conftest.c -lm >&5 +configure:3432: $? = 0 +configure:3432: ./conftest +configure:3432: $? = 0 +configure:3443: result: yes +configure:3456: checking for sys/types.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for sys/stat.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for stdlib.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for string.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for memory.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for strings.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for inttypes.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for stdint.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3456: checking for unistd.h +configure:3456: gcc -c -O2 conftest.c >&5 +configure:3456: $? = 0 +configure:3456: result: yes +configure:3471: checking for stdlib.h +configure:3471: result: yes +configure:3471: checking for string.h +configure:3471: result: yes +configure:3483: checking for size_t +configure:3483: gcc -c -O2 conftest.c >&5 +configure:3483: $? = 0 +configure:3483: gcc -c -O2 conftest.c >&5 +conftest.c: In function 'main': +conftest.c:58:21: error: expected expression before ')' token + 58 | if (sizeof ((size_t))) + | ^ +configure:3483: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "abcmidi" +| #define PACKAGE_TARNAME "abcmidi" +| #define PACKAGE_VERSION "2011-08-03" +| #define PACKAGE_STRING "abcmidi 2011-08-03" +| #define PACKAGE_BUGREPORT "fy733@ncf.ca" +| #define PACKAGE_URL "" +| #define HAVE_LIBM 1 +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| /* end confdefs.h. */ +| #include +| #ifdef HAVE_SYS_TYPES_H +| # include +| #endif +| #ifdef HAVE_SYS_STAT_H +| # include +| #endif +| #ifdef STDC_HEADERS +| # include +| # include +| #else +| # ifdef HAVE_STDLIB_H +| # include +| # endif +| #endif +| #ifdef HAVE_STRING_H +| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H +| # include +| # endif +| # include +| #endif +| #ifdef HAVE_STRINGS_H +| # include +| #endif +| #ifdef HAVE_INTTYPES_H +| # include +| #endif +| #ifdef HAVE_STDINT_H +| # include +| #endif +| #ifdef HAVE_UNISTD_H +| # include +| #endif +| int +| main () +| { +| if (sizeof ((size_t))) +| return 0; +| ; +| return 0; +| } +configure:3483: result: yes +configure:3496: checking for error_at_line +configure:3512: gcc -o conftest -O2 conftest.c -lm >&5 +configure:3512: $? = 0 +configure:3520: result: yes +configure:3533: checking for stdlib.h +configure:3533: result: yes +configure:3543: checking for GNU libc compatible malloc +configure:3567: gcc -o conftest -O2 conftest.c -lm >&5 +configure:3567: $? = 0 +configure:3567: ./conftest +configure:3567: $? = 0 +configure:3577: result: yes +configure:3601: checking for strcasecmp +configure:3601: gcc -o conftest -O2 conftest.c -lm >&5 +conftest.c:47:6: warning: conflicting types for built-in function 'strcasecmp'; expected 'int(const char *, const char *)' [-Wbuiltin-declaration-mismatch] + 47 | char strcasecmp (); + | ^~~~~~~~~~ +configure:3601: $? = 0 +configure:3601: result: yes +configure:3601: checking for strchr +configure:3601: gcc -o conftest -O2 conftest.c -lm >&5 +conftest.c:48:6: warning: conflicting types for built-in function 'strchr'; expected 'char *(const char *, int)' [-Wbuiltin-declaration-mismatch] + 48 | char strchr (); + | ^~~~~~ +conftest.c:36:1: note: 'strchr' is declared in header '' + 35 | # include + 36 | #else +configure:3601: $? = 0 +configure:3601: result: yes +configure:3708: creating ./config.status + +## ---------------------- ## +## Running config.status. ## +## ---------------------- ## + +This file was extended by abcmidi config.status 2011-08-03, which was +generated by GNU Autoconf 2.67. Invocation command line was + + CONFIG_FILES = + CONFIG_HEADERS = + CONFIG_LINKS = + CONFIG_COMMANDS = + $ ./config.status + +on seymour-VirtualBox + +config.status:813: creating Makefile +config.status:813: creating config.h + +## ---------------- ## +## Cache variables. ## +## ---------------- ## + +ac_cv_c_compiler_gnu=yes +ac_cv_env_CC_set= +ac_cv_env_CC_value= +ac_cv_env_CFLAGS_set= +ac_cv_env_CFLAGS_value= +ac_cv_env_CPPFLAGS_set= +ac_cv_env_CPPFLAGS_value= +ac_cv_env_CPP_set= +ac_cv_env_CPP_value= +ac_cv_env_LDFLAGS_set= +ac_cv_env_LDFLAGS_value= +ac_cv_env_LIBS_set= +ac_cv_env_LIBS_value= +ac_cv_env_build_alias_set= +ac_cv_env_build_alias_value= +ac_cv_env_host_alias_set= +ac_cv_env_host_alias_value= +ac_cv_env_target_alias_set= +ac_cv_env_target_alias_value= +ac_cv_func_malloc_0_nonnull=yes +ac_cv_func_strcasecmp=yes +ac_cv_func_strchr=yes +ac_cv_header_inttypes_h=yes +ac_cv_header_memory_h=yes +ac_cv_header_stdc=yes +ac_cv_header_stdint_h=yes +ac_cv_header_stdlib_h=yes +ac_cv_header_string_h=yes +ac_cv_header_strings_h=yes +ac_cv_header_sys_stat_h=yes +ac_cv_header_sys_types_h=yes +ac_cv_header_unistd_h=yes +ac_cv_lib_error_at_line=yes +ac_cv_lib_m_main=yes +ac_cv_objext=o +ac_cv_path_EGREP='/bin/grep -E' +ac_cv_path_GREP=/bin/grep +ac_cv_path_install='/usr/bin/install -c' +ac_cv_prog_CPP='gcc -E' +ac_cv_prog_ac_ct_CC=gcc +ac_cv_prog_cc_c89= +ac_cv_prog_cc_g=yes +ac_cv_type_size_t=yes + +## ----------------- ## +## Output variables. ## +## ----------------- ## + +CC='gcc' +CFLAGS=' -O2' +CPP='gcc -E' +CPPFLAGS='' +DEFS='-DHAVE_CONFIG_H' +ECHO_C='' +ECHO_N='-n' +ECHO_T='' +EGREP='/bin/grep -E' +EXEEXT='' +GREP='/bin/grep' +INSTALL_DATA='${INSTALL} -m 644' +INSTALL_PROGRAM='${INSTALL}' +INSTALL_SCRIPT='${INSTALL}' +LDFLAGS='' +LIBOBJS='' +LIBS='-lm ' +LTLIBOBJS='' +OBJEXT='o' +PACKAGE_BUGREPORT='fy733@ncf.ca' +PACKAGE_NAME='abcmidi' +PACKAGE_STRING='abcmidi 2011-08-03' +PACKAGE_TARNAME='abcmidi' +PACKAGE_URL='' +PACKAGE_VERSION='2011-08-03' +PATH_SEPARATOR=':' +SHELL='/bin/bash' +ac_ct_CC='gcc' +bindir='${exec_prefix}/bin' +build_alias='' +datadir='${datarootdir}' +datarootdir='${prefix}/share' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +dvidir='${docdir}' +exec_prefix='${prefix}' +host_alias='' +htmldir='${docdir}' +includedir='${prefix}/include' +infodir='${datarootdir}/info' +libdir='${exec_prefix}/lib' +libexecdir='${exec_prefix}/libexec' +localedir='${datarootdir}/locale' +localstatedir='${prefix}/var' +mandir='${datarootdir}/man' +oldincludedir='/usr/include' +pdfdir='${docdir}' +prefix='/usr/local' +program_transform_name='s,x,x,' +psdir='${docdir}' +sbindir='${exec_prefix}/sbin' +sharedstatedir='${prefix}/com' +sysconfdir='${prefix}/etc' +target_alias='' + +## ----------- ## +## confdefs.h. ## +## ----------- ## + +/* confdefs.h */ +#define PACKAGE_NAME "abcmidi" +#define PACKAGE_TARNAME "abcmidi" +#define PACKAGE_VERSION "2011-08-03" +#define PACKAGE_STRING "abcmidi 2011-08-03" +#define PACKAGE_BUGREPORT "fy733@ncf.ca" +#define PACKAGE_URL "" +#define HAVE_LIBM 1 +#define STDC_HEADERS 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_MALLOC 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRCHR 1 + +configure: exit 0 diff --git a/config.status b/config.status new file mode 100755 index 0000000..94fe7b3 --- /dev/null +++ b/config.status @@ -0,0 +1,1011 @@ +#! /bin/bash +# Generated by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=${CONFIG_SHELL-/bin/bash} +export SHELL +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by abcmidi $as_me 2011-08-03, which was +generated by GNU Autoconf 2.67. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +# Files that config.status was made for. +config_files=" Makefile" +config_headers=" config.h" + +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to Seymour Shlien ." + +ac_cs_config="" +ac_cs_version="\ +abcmidi config.status 2011-08-03 +configured by ./configure, generated by GNU Autoconf 2.67, + with options \"$ac_cs_config\" + +Copyright (C) 2010 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='/home/seymour/new_abcmidi/abcmidi' +srcdir='.' +INSTALL='/usr/bin/install -c' +test -n "$AWK" || AWK=awk +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +if $ac_cs_recheck; then + set X '/bin/bash' './configure' $ac_configure_extra_args --no-create --no-recursion + shift + $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6 + CONFIG_SHELL='/bin/bash' + export CONFIG_SHELL + exec "$@" +fi + +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +cat >>"$tmp/subs1.awk" <<\_ACAWK && +S["LTLIBOBJS"]="" +S["LIBOBJS"]="" +S["EGREP"]="/bin/grep -E" +S["GREP"]="/bin/grep" +S["CPP"]="gcc -E" +S["INSTALL_DATA"]="${INSTALL} -m 644" +S["INSTALL_SCRIPT"]="${INSTALL}" +S["INSTALL_PROGRAM"]="${INSTALL}" +S["OBJEXT"]="o" +S["EXEEXT"]="" +S["ac_ct_CC"]="gcc" +S["CPPFLAGS"]="" +S["LDFLAGS"]="" +S["CFLAGS"]=" -O2" +S["CC"]="gcc" +S["target_alias"]="" +S["host_alias"]="" +S["build_alias"]="" +S["LIBS"]="-lm " +S["ECHO_T"]="" +S["ECHO_N"]="-n" +S["ECHO_C"]="" +S["DEFS"]="-DHAVE_CONFIG_H" +S["mandir"]="${datarootdir}/man" +S["localedir"]="${datarootdir}/locale" +S["libdir"]="${exec_prefix}/lib" +S["psdir"]="${docdir}" +S["pdfdir"]="${docdir}" +S["dvidir"]="${docdir}" +S["htmldir"]="${docdir}" +S["infodir"]="${datarootdir}/info" +S["docdir"]="${datarootdir}/doc/${PACKAGE_TARNAME}" +S["oldincludedir"]="/usr/include" +S["includedir"]="${prefix}/include" +S["localstatedir"]="${prefix}/var" +S["sharedstatedir"]="${prefix}/com" +S["sysconfdir"]="${prefix}/etc" +S["datadir"]="${datarootdir}" +S["datarootdir"]="${prefix}/share" +S["libexecdir"]="${exec_prefix}/libexec" +S["sbindir"]="${exec_prefix}/sbin" +S["bindir"]="${exec_prefix}/bin" +S["program_transform_name"]="s,x,x," +S["prefix"]="/usr/local" +S["exec_prefix"]="${prefix}" +S["PACKAGE_URL"]="" +S["PACKAGE_BUGREPORT"]="fy733@ncf.ca" +S["PACKAGE_STRING"]="abcmidi 2011-08-03" +S["PACKAGE_VERSION"]="2011-08-03" +S["PACKAGE_TARNAME"]="abcmidi" +S["PACKAGE_NAME"]="abcmidi" +S["PATH_SEPARATOR"]=":" +S["SHELL"]="/bin/bash" +_ACAWK +cat >>"$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +D["PACKAGE_NAME"]=" \"abcmidi\"" +D["PACKAGE_TARNAME"]=" \"abcmidi\"" +D["PACKAGE_VERSION"]=" \"2011-08-03\"" +D["PACKAGE_STRING"]=" \"abcmidi 2011-08-03\"" +D["PACKAGE_BUGREPORT"]=" \"fy733@ncf.ca\"" +D["PACKAGE_URL"]=" \"\"" +D["HAVE_LIBM"]=" 1" +D["STDC_HEADERS"]=" 1" +D["HAVE_SYS_TYPES_H"]=" 1" +D["HAVE_SYS_STAT_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_STRING_H"]=" 1" +D["HAVE_MEMORY_H"]=" 1" +D["HAVE_STRINGS_H"]=" 1" +D["HAVE_INTTYPES_H"]=" 1" +D["HAVE_STDINT_H"]=" 1" +D["HAVE_UNISTD_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_STRING_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_MALLOC"]=" 1" +D["HAVE_STRCASECMP"]=" 1" +D["HAVE_STRCHR"]=" 1" + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ { + line = $ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + ac_datarootdir_hack=' + s&@datadir@&${datarootdir}&g + s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g + s&@infodir@&${datarootdir}/info&g + s&@localedir@&${datarootdir}/locale&g + s&@mandir@&${datarootdir}/man&g + s&\${datarootdir}&${prefix}/share&g' ;; +esac +ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +} + +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 diff --git a/debug.c b/debug.c index 05376cc..22c5d28 100644 --- a/debug.c +++ b/debug.c @@ -14,7 +14,7 @@ void showfeature(struct feature *ft) struct rest* arest; struct tuple* atuple; struct note* anote; - struct aclef* theclef; + cleftype_t* theclef; /* [JA] 2020-10-19 */ switch (ft->type) { case SINGLE_BAR: printf("SINGLE_BAR\n"); break; @@ -181,8 +181,7 @@ struct voice* v; struct fract* afract; struct rest* arest; struct tuple* atuple; - struct aclef* theclef; -*/ + cleftype_t* theclef; /* [JA] 2020-10-19 */ int sharps; struct chord* thischord; int chordcount; diff --git a/doc/CHANGES b/doc/CHANGES index fca07c6..ee4dc38 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -13936,5 +13936,36 @@ an extern (in parseabc.h). In addition a new struct (voice_context) has been introduced in parseabc.h. +October 19 2020 +James Allwright has implement the abc draft standard 2.2 clef parameters. +This specifies the clef by letter and line number on which it sits. +See http://abcnotation.com/wiki/abc:standard:v2.2#clefs . An +example is given below. + +X:1 +T: clef test +M: 4/4 +L: 1/4 +K: D clef=G2 +"Treble" DEFG|AGFE|ABcd| +K: D clef=G1 +"French violin" DEFG|AGFE|ABcd| +K: D clef=F5 +"Sub-bass" DEFG|AGFE|ABcd| +K: D clef=F3 +"Baritone" DEFG|AGFE|ABcd| + +The implementation involved major changes to parseabc.c and the creation of +new files music_utils.c and music_utils.h. The function isclef() in parseabc.c +has been revised and now calls get_standard_clef() or +get_extended_clef_details() that are defined in music_utils.c. +The clef is represent by a new structure cleftype_t. parseclef() and +event_key() defined in parseabc.c have a new parameter, a structure newclef. + +Minor changes were made to store.c, toabc.c, matchsup.c. and debug.c. +Significant changes were made to yapstree.c and drawtune.c. + +The makefiles folder has been moved to legacy_code. + diff --git a/doc/readme.txt b/doc/readme.txt index 768f0c7..2faba71 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,10 +1,10 @@ abcMIDI : abc <-> MIDI conversion utilities midi2abc version 3.46 June 22 2020 -abc2midi version 4.43 October 12 2020 -abc2abc version 2.11 October 12 2020 -yaps version 1.81 October 12 2020 -abcmatch version 1.75 October 12 2020 +abc2midi version 4.44 October 19 2020 +abc2abc version 2.12 October 19 2020 +yaps version 1.82 October 19 2020 +abcmatch version 1.76 October 19 2020 midicopy version 1.37 October 10 2020 24th January 2002 @@ -14,7 +14,7 @@ J.R.Allwright@westminster.ac.uk University of Westminster, London, UK -February 2020 +October 2020 Seymour Shlien Ottawa, Canada diff --git a/drawtune.c b/drawtune.c index e696728..ad11bde 100644 --- a/drawtune.c +++ b/drawtune.c @@ -58,7 +58,7 @@ extern void spacevoices(struct tune* t); extern void showtune(struct tune *t); struct key* newkey(char* name, int sharps, char accidental[], int mult[]); -struct aclef* newclef(enum cleftype t, int octave); +cleftype_t* newclef(cleftype_t* clef); char* addstring(char *s); extern int lineno; extern int separate_voices; @@ -595,40 +595,78 @@ static void staveline() fprintf(f, "%.1f staff\n", scaledwidth); } -static void printclef(struct aclef* t, double x, double yup, double ydown) +static void printclef (cleftype_t * t, double x, double yup, + double ydown) /* draw a clef of the specified type */ { - switch (t->type) { - case treble: - fprintf(f, "%.1f tclef\n", x); - break; - case bass: - fprintf(f, "%.1f bclef\n", x); - break; - case alto: - fprintf(f, "%.1f cclef\n", x); - break; - case baritone: - fprintf(f, "0 %d T %.1f cclef 0 %d T\n", 4*TONE_HT, x, -4*TONE_HT); - break; - case tenor: - fprintf(f, "0 %d T %.1f cclef 0 %d T\n", 2*TONE_HT, x, -2*TONE_HT); - break; - case mezzo: - fprintf(f, "0 %d T %.1f cclef 0 %d T\n", -2*TONE_HT, x, 2*TONE_HT); - break; - case soprano: - fprintf(f, "0 %d T %.1f cclef 0 %d T\n", -4*TONE_HT, x, 4*TONE_HT); - break; - default: - break; - }; - if (t->octave > 0) { - fprintf(f, "%.1f %.1f (%d) bnum\n", x, yup - CLEFNUM_HT + 3, t->octave); - }; - if (t->octave < 0) { - fprintf(f, "%.1f %.1f (%d) bnum\n", x, -ydown, - t->octave); - }; + double y; + int num_to_show; + double clef_y; + double clef_ytop; + double clef_ybot; + + y = (TONE_HT * 2) * (t->staveline - 1); + switch (t->basic_clef) { + case basic_clef_treble: + case basic_clef_auto: + case basic_clef_perc: + case basic_clef_none: + clef_y = y - (TONE_HT * 2); + fprintf(f, "gsave 0 %.1f T\n", clef_y); + fprintf(f, "%.1f tclef grestore\n", x); + clef_ytop = clef_y + (TONE_HT * 11); + clef_ybot = clef_y - (TONE_HT * 4); + break; + case basic_clef_bass: + clef_y = y - (TONE_HT * 6); + fprintf(f, "gsave 0 %.1f T\n", clef_y); + fprintf(f, "%.1f bclef grestore\n", x); + clef_ytop = clef_y + (TONE_HT * 8); + clef_ybot = clef_y - (TONE_HT * 0); + break; + case basic_clef_alto: + clef_y = y - (TONE_HT * 4); + fprintf(f, "gsave 0 %.1f T\n", clef_y); + fprintf(f, "%.1f cclef grestore\n", x); + clef_ytop = clef_y + (TONE_HT * 8); + clef_ybot = clef_y - (TONE_HT * 0); + break; + default: + break; + } + /* make sure we don't draw within staves */ + if (clef_ybot > 0.0) { + clef_ybot = 0.0; + } + if (clef_ytop < (TONE_HT * 8)) { + clef_ytop = TONE_HT * 8; + } + //do_T (out, 0, -y); + + /* draw -15, -8, +8, +15 above or below clef */ + switch (t->octave_offset) { + case -2: + num_to_show = -15; + break; + case -1: + num_to_show = -8; + break; + case 1: + num_to_show = 8; + break; + case 2: + num_to_show = 15; + break; + default: + num_to_show = 0; + break; + } + if (t->octave_offset > 0) { + fprintf(f, "%.1f %.1f (+%d) bnum\n", x, clef_ytop + 2, num_to_show); + } + if (t->octave_offset < 0) { + fprintf(f, "%.1f %.1f (%d) bnum\n", x, clef_ybot - CLEFNUM_HT - 2, num_to_show); + } } void set_keysig(struct key* k, struct key* newval) @@ -676,7 +714,7 @@ static double size_timesig(struct fract* meter) } static void draw_keysig(char oldmap[], char newmap[], int newmult[], - double x, struct aclef* clef) + double x, cleftype_t* clef) /* draw key specified key signature at position x on line */ /* arrays oldmap[], newmap[], newmult[] are indexed with a=0 to g=7 */ /* sharp_pos[] and flat_pos[] give order of notes */ @@ -689,32 +727,23 @@ static void draw_keysig(char oldmap[], char newmap[], int newmult[], int i; int offset, pos; int note; - - switch (clef->type) { - case treble: - offset = 0; - break; - case soprano: - offset = 2; - break; - case mezzo: - offset = 4; - break; - case alto: - offset = 6; - break; - case tenor: - offset = 8; - break; - case baritone: - offset = 10; - break; - case bass: - offset = 12; - break; - case noclef: - break; - }; + + switch (clef->basic_clef) { + case basic_clef_treble: + case basic_clef_auto: + case basic_clef_perc: + case basic_clef_none: + offset = 0 + (clef->staveline - 2) * 2; + break; + case basic_clef_alto: + offset = 6 + (clef->staveline - 3) * 2; + break; + case basic_clef_bass: + offset = 12 + (clef->staveline - 6) * 2; + break; + case basic_clef_undefined: + break; + } xpos = x; /* draw naturals to cancel out old accidentals */ for (i=0; i<7; i++) { @@ -1237,13 +1266,69 @@ static void drawbeam(struct feature* beamset[], int beamctr, int dograce) if (redcolor) fprintf(f,"0 setgray\n"); } +static void sizeclef(cleftype_t *theclef, struct feature *ft) +{ + double y; + double clef_y; + double clef_ytop; + double clef_ybot; + + /* take account of staveline when calculating clef size */ + y = (TONE_HT * 2) * (theclef->staveline - 1); + switch (theclef->basic_clef) { + case basic_clef_treble: + case basic_clef_auto: + case basic_clef_perc: + case basic_clef_none: + default: + clef_y = y - (TONE_HT * 2); + clef_ytop = clef_y + (TONE_HT * 11); + clef_ybot = clef_y - (TONE_HT * 6); + ft->xright = TREBLE_RIGHT; + ft->xleft = TREBLE_LEFT; + break; + case basic_clef_bass: + clef_y = y - (TONE_HT * 6); + clef_ytop = clef_y + (TONE_HT * 8); + clef_ybot = clef_y - (TONE_HT * 0); + ft->xright = BASS_RIGHT; + ft->xleft = BASS_LEFT; + break; + case basic_clef_alto: + clef_y = y - (TONE_HT * 4); + clef_ytop = clef_y + (TONE_HT * 8); + clef_ybot = clef_y - (TONE_HT * 0); + ft->xright = CCLEF_RIGHT; + ft->xleft = CCLEF_LEFT; + break; + } + /* extend limits to top and bottom of stave if necessary */ + if (clef_ybot > 0.0) + { + ft->ydown = 0.0; + } + if (clef_ytop < (TONE_HT * 8)) + { + clef_ytop = TONE_HT * 8; + } + /* allow extra space for +8, -8 etc */ + if (theclef->octave_offset > 0) { + clef_ytop = clef_ytop + 2 + CLEFNUM_HT + 2; + } + if (theclef->octave_offset < 0) { + clef_ybot = clef_ybot - CLEFNUM_HT - 2; + } + ft->yup = clef_ytop; + ft->ydown = clef_ybot; +} + static void sizevoice(struct voice* v, struct tune* t) /* compute width and height values for all elements in voice */ { struct feature* ft; struct note* anote; struct key* akey; - struct aclef* theclef; + cleftype_t* theclef; char* astring; struct fract* afract; struct rest* arest; @@ -1262,8 +1347,7 @@ static void sizevoice(struct voice* v, struct tune* t) chordhead = NULL; thischord = NULL; chordplace = NULL; - v->clef->type = t->clef.type; - v->clef->octave = t->clef.octave; + copy_clef (v->clef, &t->clef); if (v->keysig == NULL) { event_error("Voice has no key signature"); }; @@ -1493,55 +1577,9 @@ static void sizevoice(struct voice* v, struct tune* t) theclef = ft->item; if (theclef == NULL) { theclef = v->clef; - }; - ft->yup = (double)8*TONE_HT; - ft->ydown = 0.0; - switch (theclef->type) { - case treble: - ft->yup = (double)TREBLE_UP; - ft->ydown = (double)TREBLE_DOWN; - ft->xright = TREBLE_RIGHT; - ft->xleft = TREBLE_LEFT; - break; - case baritone: - ft->yup = (double)12*TONE_HT; - ft->xright = CCLEF_RIGHT; - ft->xleft = CCLEF_LEFT; - break; - case tenor: - ft->yup = (double)10*TONE_HT; - ft->xright = CCLEF_RIGHT; - ft->xleft = CCLEF_LEFT; - break; - case alto: - ft->xright = CCLEF_RIGHT; - ft->xleft = CCLEF_LEFT; - break; - case mezzo: - ft->ydown = (double)2*TONE_HT; - ft->xright = CCLEF_RIGHT; - ft->xleft = CCLEF_LEFT; - break; - case soprano: - ft->ydown = (double)4*TONE_HT; - ft->xright = CCLEF_RIGHT; - ft->xleft = CCLEF_LEFT; - break; - case bass: - ft->xright = BASS_RIGHT; - ft->xleft = BASS_LEFT; - break; - case noclef: - break; - }; - if (theclef->octave > 0) { - ft->yup = ft->yup + CLEFNUM_HT; - }; - if (theclef->octave < 0) { - ft->ydown = ft->ydown + CLEFNUM_HT; - }; - v->clef->type = theclef->type; - v->clef->octave = theclef->octave; + } + sizeclef(theclef, ft); + copy_clef (v->clef, theclef); break; case PRINTLINE: break; @@ -2712,10 +2750,9 @@ static void resetvoice(struct tune* t, struct voice * v) { v->place = v->first; if (v->clef == NULL) { - v->clef = newclef(t->clef.type, t->clef.octave); + v->clef = newclef(&t->clef); } else { - v->clef->type = t->clef.type; - v->clef->octave = t->clef.octave; + copy_clef (v->clef, &t->clef); }; if (v->keysig == NULL) { v->keysig = newkey(t->keysig->name, t->keysig->sharps, @@ -2943,7 +2980,7 @@ static int printvoiceline(struct voice* v) struct chord* thischord; int chordcount; double xchord; - struct aclef* theclef; + cleftype_t* theclef; int printedline; double xend; int inend; @@ -3265,8 +3302,7 @@ static int printvoiceline(struct voice* v) case CLEF: theclef = ft->item; if (theclef != NULL) { - v->clef->type = theclef->type; - v->clef->octave = theclef->octave; + copy_clef (v->clef, theclef); }; if (v->line == midline) { printclef(v->clef, ft->x, ft->yup, ft->ydown); @@ -3566,8 +3602,7 @@ void printtune(struct tune* t) /* musicsetup(); */ thisvoice = firstitem(&t->voices); while (thisvoice != NULL) { - thisvoice->clef->type = t->clef.type; - thisvoice->clef->octave = t->clef.octave; + copy_clef (thisvoice->clef, &t->clef); setfract(&thisvoice->meter, t->meter.num, t->meter.denom); thisvoice->place = thisvoice->first; thisvoice = nextitem(&t->voices); diff --git a/makefiles/djgpp.mak b/legacy_code/makefiles/djgpp.mak similarity index 100% rename from makefiles/djgpp.mak rename to legacy_code/makefiles/djgpp.mak diff --git a/makefiles/makefile.bcc b/legacy_code/makefiles/makefile.bcc similarity index 100% rename from makefiles/makefile.bcc rename to legacy_code/makefiles/makefile.bcc diff --git a/makefiles/makefile.ming b/legacy_code/makefiles/makefile.ming similarity index 100% rename from makefiles/makefile.ming rename to legacy_code/makefiles/makefile.ming diff --git a/makefiles/makefile.wat b/legacy_code/makefiles/makefile.wat similarity index 100% rename from makefiles/makefile.wat rename to legacy_code/makefiles/makefile.wat diff --git a/makefiles/makefile.wd b/legacy_code/makefiles/makefile.wd similarity index 100% rename from makefiles/makefile.wd rename to legacy_code/makefiles/makefile.wd diff --git a/makefiles/pcc.mak b/legacy_code/makefiles/pcc.mak similarity index 100% rename from makefiles/pcc.mak rename to legacy_code/makefiles/pcc.mak diff --git a/makefiles/unix.mak b/legacy_code/makefiles/unix.mak similarity index 100% rename from makefiles/unix.mak rename to legacy_code/makefiles/unix.mak diff --git a/makefile b/makefile deleted file mode 100755 index 5438eaf..0000000 --- a/makefile +++ /dev/null @@ -1,174 +0,0 @@ -# Generic unix/gcc Makefile for abcMIDI package -# -# -# compilation #ifdefs - you need to compile with these defined to get -# the code to compile with PCC. -# -# NOFTELL in midifile.c and genmidi.c selects a version of the file-writing -# code which doesn't use file seeking. -# -# PCCFIX in mftext.c midifile.c midi2abc.c -# comments out various things that aren't available in PCC -# -# ANSILIBS includes some ANSI header files (which gcc can live without, -# but other compilers may want). -# -# USE_INDEX causes index() to be used instead of strchr(). This is needed -# by some pre-ANSI C compilers. -# -# ASCTIME causes asctime() to be used instead of strftime() in pslib.c. -# If ANSILIBS is not set, neither routine is used. -# -# KANDR selects functions prototypes without argument prototypes. -# currently yaps will only compile in ANSI mode. -# -# -# On running make, you may get the mysterious message : -# -# ', needed by `parseabc.o'. Stop `abc.h -# -# This means you are using GNU make and this file is in DOS text format. To -# cure the problem, change this file from using PC-style end-of-line (carriage -# return and line feed) to unix style end-of-line (line feed). - -VERSION = @VERSION@ - -CC = gcc -INSTALL = /usr/bin/install -c -INSTALL_DATA = ${INSTALL} -m 644 -INSTALL_PROGRAM = ${INSTALL} - -CFLAGS = -DANSILIBS -O2 -CPPFLAGS = -DHAVE_CONFIG_H -I. -LDFLAGS = -lm - -prefix = /usr/local -exec_prefix = ${prefix} - -srcdir = . -VPATH = . -bindir = ${exec_prefix}/bin -libdir = ${exec_prefix}/lib -datadir = ${prefix}/share -docdir = ${prefix}/share/doc/abcmidi -mandir = ${prefix}/share/man/man1 - -binaries=abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch - -all : abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch - -OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o -abc2midi : $(OBJECTS_ABC2MIDI) - $(CC) $(CFLAGS) -o abc2midi $(OBJECTS_ABC2MIDI) $(LDFLAGS) -lm -$(OBJECTS_ABC2MIDI): abc.h parseabc.h config.h Makefile - -OBJECTS_ABC2ABC=parseabc.o toabc.o -abc2abc : $(OBJECTS_ABC2ABC) - $(CC) $(CFLAGS) -o abc2abc $(OBJECTS_ABC2ABC) $(LDFLAGS) -$(OBJECTS_ABC2ABC): abc.h parseabc.h config.h Makefile - -OBJECTS_MIDI2ABC=midifile.o midi2abc.o -midi2abc : $(OBJECTS_MIDI2ABC) - $(CC) $(CFLAGS) -o midi2abc $(OBJECTS_MIDI2ABC) $(LDFLAGS) -$(OBJECTS_MIDI2ABC): abc.h midifile.h config.h Makefile - -OBJECTS_MFTEXT=midifile.o mftext.o crack.o -mftext : $(OBJECTS_MFTEXT) - $(CC) $(CFLAGS) -o mftext $(OBJECTS_MFTEXT) $(LDFLAGS) -$(OBJECTS_MFTEXT): abc.h midifile.h config.h Makefile - -OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o -yaps : $(OBJECTS_YAPS) - $(CC) $(CFLAGS) -o yaps $(OBJECTS_YAPS) $(LDFLAGS) -$(OBJECTS_YAPS): abc.h midifile.h config.h Makefile - -OBJECTS_MIDICOPY=midicopy.o -midicopy : $(OBJECTS_MIDICOPY) - $(CC) $(CFLAGS) -o midicopy $(OBJECTS_MIDICOPY) $(LDFLAGS) -$(OBJECTS_MIDICOPY): abc.h midifile.h midicopy.h config.h Makefile - -OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o -abcmatch : $(OBJECTS_ABCMATCH) - $(CC) $(CFLAGS) -o abcmatch $(OBJECTS_ABCMATCH) $(LDFLAGS) -$(OBJECTS_ABCMATCH): abc.h midifile.h config.h Makefile - -parseabc.o : parseabc.c abc.h parseabc.h - -parser2.o : parser2.c abc.h parseabc.h parser2.h - -toabc.o : toabc.c abc.h parseabc.h - -# could use -DNOFTELL here -genmidi.o : genmidi.c abc.h midifile.h genmidi.h - -stresspat.o : stresspat.c - -store.o : store.c abc.h parseabc.h midifile.h genmidi.h - -queues.o : queues.c genmidi.h - -# could use -DNOFTELL here -midifile.o : midifile.c midifile.h - -midi2abc.o : midi2abc.c midifile.h - -midicopy.o : midicopy.c midicopy.h - -abcmatch.o: abcmatch.c abc.h - -crack.o : crack.c - -mftext.o : mftext.c midifile.h - -# objects needed by yaps -# -yapstree.o: yapstree.c abc.h parseabc.h structs.h drawtune.h - -drawtune.o: drawtune.c structs.h sizes.h abc.h drawtune.h - -pslib.o: pslib.c drawtune.h - -position.o: position.c abc.h structs.h sizes.h - -debug.o: debug.c structs.h abc.h - -#objects for abcmatch -# -matchsup.o : matchsup.c abc.h parseabc.h parser2.h - -clean : - rm *.o ${binaries} - -install: abc2midi midi2abc abc2abc mftext midicopy yaps abcmatch - $(INSTALL) -d $(DESTDIR)$(bindir) - $(INSTALL) -m 755 ${binaries} $(DESTDIR)$(bindir) - - # install documentation - $(INSTALL) -d $(DESTDIR)${docdir} - $(INSTALL) -m 644 doc/*.txt $(DESTDIR)$(docdir) - $(INSTALL) -m 644 doc/AUTHORS $(DESTDIR)$(docdir) - $(INSTALL) -m 644 doc/CHANGES $(DESTDIR)$(docdir) - $(INSTALL) -m 644 VERSION $(DESTDIR)$(docdir) - - # install manpages - $(INSTALL) -d $(DESTDIR)${mandir} - $(INSTALL) -m 644 doc/*.1 $(DESTDIR)$(mandir) - - -uninstall: - echo "uninstalling..."; - #rm -f $(DESTDIR)$(bindir)/$(binaries) - rm -f $(DESTDIR)$(bindir)/abc2midi - rm -f $(DESTDIR)$(bindir)/abc2abc - rm -f $(DESTDIR)$(bindir)/yaps - rm -f $(DESTDIR)$(bindir)/midi2abc - rm -f $(DESTDIR)$(bindir)/mftext - rm -f $(DESTDIR)$(bindir)/abcmatch - rm -f $(DESTDIR)$(bindir)/midicopy - rm -f $(DESTDIR)$(docdir)/*.txt - rm -f $(DESTDIR)$(docdir)/AUTHORS - rm -f $(DESTDIR)$(docdir)/CHANGES - rm -f $(DESTDIR)$(docdir)/VERSION - rm -f $(DESTDIR)$(mandir)/*.1 - rmdir $(DESTDIR)$(docdir) - diff --git a/makefiles/makefile.w32 b/makefile.w32 old mode 100755 new mode 100644 similarity index 70% rename from makefiles/makefile.w32 rename to makefile.w32 index d892ebc..883b120 --- a/makefiles/makefile.w32 +++ b/makefile.w32 @@ -18,16 +18,16 @@ all: abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe midicopy.exe abcm abc2midi.exe: parseabc.obj store.obj genmidi.obj midifile.obj queues.obj parser2.obj stresspat.obj - $(link) $(conflags) -out:abc2midi.exe parseabc.obj store.obj genmidi.obj queues.obj parser2.obj midifile.obj stresspat.obj + $(link) $(conflags) -out:abc2midi.exe parseabc.obj store.obj genmidi.obj queues.obj parser2.obj midifile.obj stresspat.obj music.utils.obj abcmatch.exe: abcmatch.obj matchsup.obj parseabc.obj - $(link) $(conflags) -out:abcmatch.exe abcmatch.obj matchsup.obj parseabc.obj + $(link) $(conflags) -out:abcmatch.exe abcmatch.obj matchsup.obj parseabc.obj music.utils.obj midi2abc.exe: midifile.obj midi2abc.obj $(link) $(conflags) -out:midi2abc.exe midifile.obj midi2abc.obj -abc2abc.exe: parseabc.obj toabc.obj - $(link) $(conflags) -out:abc2abc.exe parseabc.obj toabc.obj +abc2abc.exe: parseabc.obj toabc.obj music_utils.obj + $(link) $(conflags) -out:abc2abc.exe parseabc.obj toabc.obj music.utils.obj mftext.exe: midifile.obj mftext.obj crack.obj $(link) $(conflags) -out:mftext.exe midifile.obj mftext.obj crack.obj @@ -35,11 +35,11 @@ mftext.exe: midifile.obj mftext.obj crack.obj midicopy.exe: midicopy.obj $(link) $(conflags) -out:midicopy.exe midicopy.obj -yaps.exe: parseabc.obj yapstree.obj drawtune.obj debug.obj pslib.obj position.obj parser2.obj - $(link) $(conflags) -out:yaps.exe parseabc.obj yapstree.obj drawtune.obj debug.obj position.obj pslib.obj parser2.obj $(conlibs) +yaps.exe: parseabc.obj yapstree.obj drawtune.obj debug.obj pslib.obj position.obj parser2.obj music_utils.obj + $(link) $(conflags) -out:yaps.exe parseabc.obj yapstree.obj drawtune.obj debug.obj position.obj pslib.obj parser2.obj music_utils.obj $(conlibs) -abcmatch.obj: abcmatch.c abc.h +abcmatch.obj: abcmatch.c abc.h parseabc.h music.utils.h $(comp) abcmatch.c crack.obj: crack.c @@ -48,13 +48,13 @@ crack.obj: crack.c debug.obj: debug.c structs.h abc.h $(comp) debug.c -drawtune.obj: drawtune.c structs.h sizes.h abc.h drawtune.h +drawtune.obj: drawtune.c structs.h sizes.h abc.h drawtune.h music.utils.h $(comp) drawtune.c -genmidi.obj: genmidi.c abc.h midifile.h genmidi.h +genmidi.obj: genmidi.c abc.h midifile.h genmidi.h parseabc.h queues.h $(comp) genmidi.c -matchsup.obj: matchsup.c abc.h parseabc.h parser2.h +matchsup.obj: matchsup.c abc.h parseabc.h parser2.h music.utils.h $(comp) matchsup.c mftext.obj: mftext.c midifile.h @@ -66,7 +66,7 @@ midi2abc.obj: midi2abc.c midifile.h midifile.obj: midifile.c midifile.h $(comp) midifile.c -parseabc.obj: parseabc.c abc.h parseabc.h +parseabc.obj: parseabc.c abc.h parseabc.h music_utils.h $(comp) parseabc.c parser2.obj: parser2.c abc.h parseabc.h parser2.h @@ -81,7 +81,7 @@ pslib.obj: pslib.c drawtune.h queues.obj: queues.c genmidi.h $(comp) queues.c -store.obj: store.c abc.h parseabc.h midifile.h genmidi.h +store.obj: store.c abc.h parseabc.h midifile.h genmidi.h music.utils.h $(comp) store.c stresspat.obj: stresspat.c @@ -90,7 +90,7 @@ stresspat.obj: stresspat.c toabc.obj: toabc.c abc.h parseabc.h $(comp) toabc.c -yapstree.obj: yapstree.c abc.h parseabc.h structs.h drawtune.h +yapstree.obj: yapstree.c abc.h parseabc.h parser2.h structs.h drawtune.h music.utils.h $(comp) yapstree.c diff --git a/matchsup.c b/matchsup.c index ac61d34..0270b36 100644 --- a/matchsup.c +++ b/matchsup.c @@ -763,6 +763,9 @@ struct voice_params *vp; if (pastheader) checkbreak(); v = getvoicecontext(n); addfeature(VOICE, v->indexno, 0, 0); + if (vp->gotclef) { + event_octave(vp->new_clef.octave_offset, 1); + } if (vp->gotoctave) { event_octave(vp->octave,1); }; @@ -1349,11 +1352,13 @@ int num, denom; } -void event_note(decorators, accidental, mult, note, xoctave, n, m) +void event_note(decorators, clef, accidental, mult, note, xoctave, n, m) /* handles a note in the abc */ int decorators[DECSIZE]; +cleftype_t *clef; +char accidental; int mult; -char accidental, note; +char note; int xoctave, n, m; { int pitch; @@ -1858,19 +1863,21 @@ static void headerprocess() voicesused = 0; } -void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, gotkey, gotclef, clefname, +void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, + gotkey, gotclef, clefname, clef, octave, transpose, gotoctave, gottranspose, explict) /* handles a K: field */ int sharps; /* sharps is number of sharps in key signature */ -int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ char *s; /* original string following K: */ +int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ char modmap[7]; /* array of accidentals to be applied */ int modmul[7]; /* array giving multiplicity of each accent (1 or 2) */ struct fraction modmicrotone[7]; /* [SS] 2014-01-06 */ int gotkey, gotclef; +char* clefname; +cleftype_t *clef; /* [JA] 2020-10-19 */ int octave, transpose, gotoctave, gottranspose; int explict; -char* clefname; { int minor; strncpy(keysignature,s,16); @@ -1897,6 +1904,9 @@ char* clefname; v = newvoice(1); head = v; }; + if (gotclef) { + event_octave(clef->octave_offset, 0); + } if (gotoctave) { event_octave(octave,0); }; diff --git a/music_utils.c b/music_utils.c new file mode 100644 index 0000000..d82b6e7 --- /dev/null +++ b/music_utils.c @@ -0,0 +1,361 @@ +/* music_utils.c + * + * Copyright James Allwright 2020 + * + * This file provides basic functions for manipulating music + * + * 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; if not, see + */ +#include +#include +#include +#include "music_utils.h" + +typedef struct clef_item +{ + char *name; + basic_cleftype_t basic_clef; + int staveline; + int octave_offset; +} clef_item_t; + +/* entries are name, basic_clef, staveline, octave_offset */ +static const clef_item_t clef_conversion_table[] = { + {"treble", basic_clef_treble, 2, 0}, + {"alto", basic_clef_alto, 3, 0}, + {"bass", basic_clef_bass, 4, 0}, + {"soprano", basic_clef_alto, 1, 0}, + {"mezzosoprano", basic_clef_alto, 2, 0}, + {"tenor", basic_clef_alto, 4, 0}, + {"baritone", basic_clef_bass, 0, 0}, +}; +#define NUM_CLEFS (sizeof(clef_conversion_table)/sizeof(clef_item_t)) + +/* The following 3 are not really clefs, but abc standard + * 2.2 allows them. We treat them as treble clef and only + * allow them after clef= . This ensures that K:none is not + * interpreted as a clef instead of a key signature. + * + * the clef defines how a pitch value maps to a y position + * on the stave. If there is a clef of "none", then you don't + * know where to put the notes! + */ +static const clef_item_t odd_clef_conversion_table[] = { + {"auto", basic_clef_treble, 2, 0}, + {"perc", basic_clef_treble, 2, 0}, + {"none", basic_clef_treble, 2, 0} +}; +#define NUM_ODD_CLEFS (sizeof(odd_clef_conversion_table)/sizeof(clef_item_t)) + + +/* array giving notes in the order used by key_acc array + * This can be used to implement a lookup function which is + * the reverse of note_index(). + */ +const char note_array[] = "cdefgab"; + +/* These are musical modes. Each specifies a scale of notes starting on a + * particular tonic note. Effectively the notes are the same as used in a + * major scale, but the starting note is different. This means that each + * mode can be notated using the standard key signatures used for major + * keys. The abc standard specifies that only the first 3 characters of + * the mode are significant, and further that "minor" can be abbreviated + * as "m" and "major" omitted altogether. The full names are: + * Major, Minor, Aeolian, Locrian, Ionian, Dorian, Phyrgian, Lydian and + * Mixolydian. In addition, we have "exp" short for "explicit" to indicate + * that arbitrary accidentals can be applied to each stave line in the + * key signature and "" the empty string to represent "major" where this + * is inferred as the default value rather than being supplied. + */ +const char *mode[12] = { "maj", "min", "m", + "aeo", "loc", "ion", "dor", "phr", "lyd", "mix", "exp", "" +}; + +/* This is a table for finding the sharps/flats representation of + * a key signature for a given mode. + * Suppose we want to find the sharps/flats representation for + * K:GDor + * If we know the major mode key K:G is 1 sharp, and have the index of the + * mode we want within the mode table, we can work out the new key + * signature as follows: + * + * Original major mode key signature +1 (1 sharp) + * Desired new mode Dorian is at position 6 in table + * modeshift[6] is -2. + * new key signature is 1 - 2 = -1 (1 flat) + * GDor is 1 flat. + */ +const int modeshift[12] = { 0, -3, -3, -3, -5, 0, -2, -4, 1, -1, 0, 0 }; + +/* convert a note a-g to an index into the key signature arrays + * src.key_acc, target.key_acc, src_key_mult, target_key_mult + */ +noteletter_t note_index (char note_ch) +{ + + switch (note_ch) { + case 'c': + case 'C': + return note_c; + case 'd': + case 'D': + return note_d; + case 'e': + case 'E': + return note_e; + case 'f': + case 'F': + return note_f; + case 'g': + case 'G': + return note_g; + case 'a': + case 'A': + return note_a; + case 'b': + case 'B': + return note_b; + default: + printf ("Internal error: note_index called with bad value %c\n", note_ch); + exit (1); + } +} + +/* convert a letter a - g into a note value in semitones */ +int semitone_value_for_note (noteletter_t note) +{ + switch (note) { + case note_c: + return 0; + case note_d: + return 2; + case note_e: + return 4; + case note_f: + return 5; + case note_g: + return 7; + case note_a: + return 9; + case note_b: + return 11; + default: + printf ("Internal error: Unexpected note %d\n", note); + return 0; + } +} + +/* convert an accidental indicator into a semitone shift */ +int semitone_shift_for_acc (char acc) +{ + switch (acc) { + case '_': + case 'b': + return -1; + case '^': + case '#': + return 1; + default: + return 0; + } +} + +/* Given a semitone value 0 - 11, convert to note + accidental. + * This function always returns sharp as the accidental + */ +void note_for_semitone (int semitones, noteletter_t * note, char *accidental) +{ + char note_for_semi[12] = "CCDDEFFGGAAB"; + char acc_for_semi[12] = " # # # # # "; + + if (semitones < 0) { + semitones = -(-semitones) % 12 + 12; + } + if (semitones > 11) { + semitones = semitones % 12; + } + *note = note_index (note_for_semi[semitones]); + *accidental = acc_for_semi[semitones]; +} + +/* look for any octave shift specified after a clef name */ +static int get_clef_octave_offset (char *clef_ending) +{ + if (strncmp (clef_ending, "+8", 2) == 0) { + return 1; + } + if (strncmp (clef_ending, "+15", 2) == 0) { + return 2; + } + if (strncmp (clef_ending, "-8", 2) == 0) { + return -1; + } + if (strncmp (clef_ending, "-15", 2) == 0) { + return -2; + } + return 0; +} + +void init_new_clef (cleftype_t * new_clef) +{ + new_clef->basic_clef = basic_clef_undefined; + new_clef->staveline = 0; + new_clef->octave_offset = 0; + new_clef->named = 0; +} + +/* copy contents of cleftype_t structure */ +void copy_clef (cleftype_t * target_clef, cleftype_t * source_clef) +{ + target_clef->basic_clef = source_clef->basic_clef; + target_clef->staveline = source_clef->staveline; + target_clef->octave_offset = source_clef->octave_offset; + target_clef->named = source_clef->named; +} + +/* use lookup table to get details of clef from it's name string */ +//int get_standard_clef (char *name, basic_cleftype_t * basic_clef, +// int *staveline, int *octave_offset) +int get_standard_clef (char *name, cleftype_t * new_clef) +{ + int i; + int len; + + for (i = 0; i < NUM_CLEFS; i++) { + const clef_item_t *table_row = &clef_conversion_table[i]; + + len = strlen (table_row->name); + if (strncmp (name, table_row->name, len) == 0) { + new_clef->basic_clef = table_row->basic_clef; + new_clef->staveline = table_row->staveline; + new_clef->named = 1; + new_clef->octave_offset = get_clef_octave_offset (name + len); + return 1; /* lookup succeeded */ + } + } + return 0; +} + +/* look for a clef using C, F or G and a number 1 - 5 or + * one of the specials (none, perc, auto) + */ +//int get_extended_clef_details (char *name, basic_cleftype_t * basic_clef, +// int *staveline, int *octave_offset) +int get_extended_clef_details (char *name, cleftype_t * new_clef) +{ + int i; + int len; + int num; + int items_read; + + for (i = 0; i < NUM_ODD_CLEFS; i++) { + const clef_item_t *table_row = &odd_clef_conversion_table[i]; + + len = strlen (table_row->name); + if (strncmp (name, table_row->name, len) == 0) { + new_clef->basic_clef = table_row->basic_clef; + new_clef->staveline = table_row->staveline; + new_clef->octave_offset = table_row->octave_offset; + new_clef->named = 1; + new_clef->octave_offset = get_clef_octave_offset (name + len); + return 1; /* lookup succeeded */ + } + } + new_clef->octave_offset = 0; + /* try [C/F/G]{1-5] format */ + switch (name[0]) { + case 'C': + new_clef->basic_clef = basic_clef_alto; + break; + case 'F': + new_clef->basic_clef = basic_clef_bass; + break; + case 'G': + new_clef->basic_clef = basic_clef_treble; + break; + default: + return 0; /* not recognized */ + } + items_read = sscanf (&name[1], "%d", &num); + if ((items_read == 1) && (num >= 1) && (num <= 5)) { + /* we have a valid clef specification */ + new_clef->staveline = num; + new_clef->named = 0; + new_clef->octave_offset = get_clef_octave_offset (name + 2); + return 1; + } + return 0; +} + +static void append_octave_offset(char * name, int octave_offset) +{ + switch (octave_offset) { + case -2: + strcat(name, "-15"); + break; + case -1: + strcat(name, "-8"); + break; + case 1: + strcat(name, "+8"); + break; + case 2: + strcat(name, "+15"); + break; + default: + break; + } +} + +/* given clef basic type and staveline, we try to work out it's name */ +int get_clef_name (cleftype_t * new_clef, char *name) +{ + int i; + + if (new_clef->named) { + for (i = 0; i < NUM_CLEFS; i++) { + if ((clef_conversion_table[i].basic_clef == new_clef->basic_clef) && + (clef_conversion_table[i].staveline == new_clef->staveline)) { + strcpy (name, clef_conversion_table[i].name); + append_octave_offset(name, new_clef->octave_offset); + return 1; /* lookup succeeded */ + } + } + } + switch (new_clef->basic_clef) { + default: + case basic_clef_undefined: + case basic_clef_none : + return 0; + case basic_clef_auto : + strcpy(name, "auto"); + return 1; + case basic_clef_perc : + strcpy(name, "perc"); + return 1; + case basic_clef_treble: + name[0] = 'G'; + break; + case basic_clef_bass: + name[0] = 'F'; + break; + case basic_clef_alto: + name[0] = 'C'; + break; + } + name[1] = '0' + new_clef->staveline; + name[2] = '\0'; + append_octave_offset(name, new_clef->octave_offset); + return 1; +} diff --git a/music_utils.h b/music_utils.h new file mode 100644 index 0000000..c353e40 --- /dev/null +++ b/music_utils.h @@ -0,0 +1,78 @@ +/* music_utils.h + * + * Copyright James Allwright 2020 + * + * part of abc2abc/Toadflax + * + * header file to export basic music manipulation functions. + * + * 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; if not, see + */ +#ifndef MUSIC_UTILS_H +#define MUSIC_UTILS_H 1 + +extern const char note_array[]; + +typedef enum noteletter { + note_c = 0, + note_d = 1, + note_e = 2, + note_f = 3, + note_g = 4, + note_a = 5, + note_b = 6 +} noteletter_t; + +#define MODE_DEFAULT_MAJOR 11 +#define MODE_EXP 10 + +/* There are only 3 different types of drawn clef. The other clefs are + * obtained by drawing one of the basic clefs, but sitting on a different + * stave line. For convenience, the abc standard 2.2 numbers these lines + * 1 to 5, with the bottom line being 1 and the top line being 5. + */ +typedef enum basic_cleftype { + basic_clef_treble, + basic_clef_bass, + basic_clef_alto, + basic_clef_undefined, /* for when we didn't find a clef */ + basic_clef_auto, /* drawing program has free choice of clef */ + basic_clef_perc, /* percussion */ + basic_clef_none /* from abc standard 2.2 what does this mean ? */ +} basic_cleftype_t; + +typedef struct new_cleftype { + basic_cleftype_t basic_clef; + int staveline; + int octave_offset; + int named; +} cleftype_t; + +extern const char *mode[12]; +extern const int modeshift[12]; + +/* note operations */ +noteletter_t note_index(char note_ch); +int semitone_value_for_note(noteletter_t note); +int semitone_shift_for_acc(char acc); +void note_for_semitone(int semitones, noteletter_t *note, char *accidental); + +/* clef operations */ +void init_new_clef(cleftype_t *new_clef); +void copy_clef(cleftype_t *target_clef, cleftype_t *source_clef); +int get_standard_clef (char *name, cleftype_t *new_clef); +int get_extended_clef_details (char *name, cleftype_t *new_clef); +int get_clef_name (cleftype_t *new_clef, char *name); + +#endif /* MUSIC_UTILS_H 1 */ diff --git a/parseabc.c b/parseabc.c index 72dd4a6..8320cc4 100644 --- a/parseabc.c +++ b/parseabc.c @@ -32,6 +32,7 @@ #define TAB 9 #include "abc.h" #include "parseabc.h" +#include "music_utils.h" #include #include /* [JM] 2018-02-22 to handle strncasecmp() */ @@ -123,13 +124,7 @@ int oldchordconvention = 0; char * abcversion = "2.0"; /* [SS] 2014-08-11 */ char lastfieldcmd = ' '; /* [SS] 2014-08-15 */ -char *mode[10] = { "maj", "min", "m", - "aeo", "loc", "ion", "dor", "phr", "lyd", "mix" -}; - -int modeshift[10] = { 0, -3, -3, - -3, -5, 0, -2, -4, 1, -1 -}; +/* tables mode and modeshift moved to music_utils.c */ int modeminor[10] = { 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 @@ -580,143 +575,35 @@ ismicrotone (p, dir) return 0; } - - - -int -isclef (s, gotoctave, octave, strict) - char *s; - int *gotoctave, *octave; - int strict; /* part of K: parsing - looks for a clef in K: field */ /* format is K:string where string is treble, bass, baritone, tenor, */ /* alto, mezzo, soprano or K:clef=arbitrary */ +/* revised by James Allwright [JA] 2020-10-18 */ +int isclef (char *s, cleftype_t * new_clef, + int *gotoctave, int *octave, int expect_clef) { int gotclef; - s = s; + gotclef = 0; - if (strncmp (s, "bass", 4) == 0) - { - gotclef = 1; - *octave = 0; /* [SS] 2020-05-06 */ - }; - if (strncmp (s, "treble", 6) == 0) - { - gotclef = 1; - /* [SS] 2020-05-06 */ - /*if (fileprogram == ABC2MIDI && *gotoctave != 1 && *octave != 1)*/ - if (fileprogram == ABC2MIDI) - { - /* [SS] 2015-07-02 2019-01-20*/ - /* event_warning ("clef= is overriding octave= setting"); */ - *gotoctave = 1; /* [SS] 2011-12-19 */ - *octave = 0; /* [SS] 2020-05-06 */ - } - }; - if (strncmp (s, "treble+8", 8) == 0) - { - gotclef = 1; - /* [SS] 2020-05-06 */ - /*if (fileprogram == ABC2MIDI && *gotoctave != 1 && *octave != 1)*/ - if (fileprogram == ABC2MIDI) - { - /* event_warning ("clef= is overriding octave= setting"); */ - /* [SS] 2015-07-02 2019-01-20 */ - *gotoctave = 1; - *octave = 1; - } - }; - if (strncmp (s, "treble-8", 8) == 0) - { - gotclef = 1; - /* [SS] 2020-05-06 */ - /*if (fileprogram == ABC2MIDI && *gotoctave == 1 && *octave != -1)*/ - if (fileprogram == ABC2MIDI) - { - /* event_warning ("clef= is overriding octave= setting"); */ - *gotoctave = 1; - *octave = -1; - } - }; - if (strncmp (s, "baritone", 8) == 0) - { - gotclef = 1; - *octave = 0; /* [SS] 2020-05-06 */ - }; - if (strncmp (s, "tenor", 5) == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - }; - if (strncmp (s, "tenor-8", 7) == 0) - { - gotclef = 1; - /* [SS] 2020-05-06 */ - /*if (fileprogram == ABC2MIDI && *gotoctave == 1 && *octave != -1) {*/ - if (fileprogram == ABC2MIDI) { - /*event_warning ("clef= is overriding octave= setting");*/ - *gotoctave = 1; - *octave = -1; - } - }; - if (strncmp (s, "alto", 4) == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - }; - if (strncmp (s, "mezzo", 5) == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - }; - if (strncmp (s, "soprano", 7) == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - }; -/* - * only clef=F or clef=f is allowed, or else - * we get a conflict with the key signature - * indication K:F -*/ - - if (strncmp (s, "f", 1) == 0 && strict == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ + new_clef->octave_offset = 0; + gotclef = get_standard_clef (s, new_clef); + if (!gotclef && expect_clef) { + /* do we have a clef in letter format ? e.g. C1, F3, G3 */ + gotclef = get_extended_clef_details (s, new_clef); + if (new_clef->basic_clef == basic_clef_none) { + event_warning ("Found clef=none, but a clef is required. Ignoring"); + gotclef = 0; } - if (strncmp (s, "F", 1) == 0 && strict == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - } - if (strncmp (s, "g", 1) == 0 && strict == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - } - if (strncmp (s, "G", 1) == 0 && strict == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - } - if (strncmp (s, "perc", 1) == 0 && strict == 0) - { - gotclef = 1; - *octave=0; /* [SS] 2020-05-06 */ - } /* [SS] 2011-04-17 */ - - if (!strict && !gotclef) - { - gotclef = 1; - event_warning ("cannot recognize clef indication"); - } - + } + if (expect_clef && !gotclef) { + char error_message[80]; + + snprintf (error_message, 80, "clef %s not recognized", s); + event_warning (error_message); + } return (gotclef); } - - char * readword (word, s) /* part of parsekey, extracts word from input line */ @@ -910,12 +797,14 @@ int interpret_voice_label (char *s, int num) * s is advanced to point to the next token. */ + int -parseclef (s, word, gotclef, clefstr, gotoctave, octave) +parseclef (s, word, gotclef, clefstr, newclef, gotoctave, octave) char **s; char *word; int *gotclef; - char *clefstr; + char *clefstr; /* [JA] 2020-10-19 */ + cleftype_t * newclef; int *gotoctave, *octave; /* extracts string clef= something */ { @@ -935,14 +824,14 @@ parseclef (s, word, gotclef, clefstr, gotoctave, octave) *s = *s + 1; skipspace (s); *s = readword (clefstr, *s); - if (isclef (clefstr, gotoctave, octave, 0)) + if (isclef (clefstr, newclef, gotoctave, octave, 1)) { *gotclef = 1; }; }; successful = 1; } - else if (isclef (word, gotoctave, octave, 1)) + else if (isclef (word, newclef, gotoctave, octave, 0)) { *gotclef = 1; strcpy (clefstr, word); @@ -1192,8 +1081,13 @@ static void process_microtones (int *parsed, char word[], { *parsed = 1; j = (int) c - 'A'; - if (j > 7) j = (int) c - 'a'; - if (j > 7 || j < 0) {printf("invalid j = %d\n",j); exit(-1);} + if (j > 7) { + j = (int) c - 'a'; + } + if (j > 7 || j < 0) { + event_error ("Not a valid microtone"); + return; + } if (word[0] == '_') a = -a; /* printf("%s fraction microtone %d/%d for %c\n",word,a,b,c); */ } else { @@ -1209,12 +1103,17 @@ static void process_microtones (int *parsed, char word[], } } /* if (parsed ==1) [SS] 2020-09-30 */ - if (success > 0) { - j = (int) c - 'A'; - if (j > 7) j = (int) c - 'a'; - if (j > 7 || j < 0) {printf("invalid j = %d\n",j); exit(-1);} - if (word[0] == '_') a = -a; - modmap[j] = word[0]; + if (success > 0) { + j = (int) c - 'A'; + if (j > 7) { + j = (int) c - 'a'; + } + if (j > 7 || j < 0) { + event_error ("Not a valid microtone"); + return; + } + if (word[0] == '_') a = -a; + modmap[j] = word[0]; modmicrotone[j].num = a; modmicrotone[j].denom = b; /* printf("%c microtone = %d/%d\n",modmap[j],modmicrotone[j].num,modmicrotone[j].denom); */ @@ -1260,6 +1159,7 @@ parsekey (str) int foundmode; int transpose, octave; char clefstr[30]; + cleftype_t newclef; char modestr[30]; char msg[80]; char *moveon; @@ -1286,6 +1186,7 @@ parsekey (str) gotclef = 0; cgotoctave = 0; coctave = 0; + init_new_clef (&newclef); modeindex = 0; explict = 0; modnotes = 0; @@ -1300,7 +1201,11 @@ parsekey (str) word[0] = 0; /* in case of empty string [SDG] 2020-06-04 */ while (*s != '\0') { - parsed = parseclef (&s, word, &gotclef, clefstr, &cgotoctave, &coctave); + parsed = parseclef (&s, word, &gotclef, clefstr, &newclef, &cgotoctave, &coctave); + if (gotclef) { + /* make clef an attribute of current voice */ + copy_clef (&voicecode[voicenum - 1].clef, &newclef); + } /* parseclef also scans the s string using readword(), placing */ /* the next token into the char array word[]. */ if (!parsed) @@ -1492,7 +1397,7 @@ parsekey (str) explict = 1; /* [SS] 2010-07-29 */ } event_key (sf, str, modeindex, modmap, modmul, modmicrotone, gotkey, - gotclef, clefstr, octave, transpose, gotoctave, gottranspose, + gotclef, clefstr, &newclef, octave, transpose, gotoctave, gottranspose, explict); return (gotkey); } @@ -1531,11 +1436,14 @@ parsevoice (s) skiptospace (&s); voicenum = num; skipspace (&s); - while (*s != '\0') - { - parsed = - parseclef (&s, word, &vparams.gotclef, vparams.clefname, &cgotoctave, - &coctave); + while (*s != '\0') { + parsed = + parseclef (&s, word, &vparams.gotclef, vparams.clefname, + &vparams.new_clef, &cgotoctave, &coctave); + if (vparams.gotclef) { + /* make clef an attribute of current voice */ + copy_clef (&voicecode[num - 1].clef, &vparams.new_clef); + } if (!parsed) parsed = parsetranspose (&s, word, &vparams.gottranspose, @@ -1767,7 +1675,7 @@ parsenote (s) else { readlen (&n, &m, s); - event_note (decorators, accidental, mult, note, octave, n, m); + event_note (decorators, &voicecode[voicenum - 1].clef, accidental, mult, note, octave, n, m); if (!microtone) event_normal_tone (); /* [SS] 2014-01-09 */ }; @@ -1920,7 +1828,7 @@ FILE * parse_abc_include (s) char includefilename[80]; FILE *includehandle; int success; - success = sscanf (s, "%%%%abc-include %80s", includefilename); /* [SS] 2014-08-11 */ + success = sscanf (s, "%%%%abc-include %79s", includefilename); /* [SS] 2014-08-11 */ if (success == 1) { /* printf("opening include file %s\n",includefilename); */ includehandle = fopen(includefilename,"r"); diff --git a/parseabc.h b/parseabc.h index 95bcd73..232f08a 100644 --- a/parseabc.h +++ b/parseabc.h @@ -9,6 +9,8 @@ #define KANDR #endif +#include "music_utils.h" + /* the arg list to event_voice keeps growing; if we put the args into a structure and pass that around, routines that don't need the new ones need not be altered. NB. event_voice is *called* from parseabc.c, the actual procedure is linked @@ -16,26 +18,28 @@ in from the program-specific file */ /* added middle= stuff */ #define V_STRLEN 256 /* [SS] 2017-10-11 increase from 64 */ struct voice_params { - int gotclef; - int gotoctave; - int gottranspose; - int gotname; - int gotsname; - int gotmiddle; - int gotother; /* [SS] 2011-04-18 */ - int octave; - int transpose; - char clefname[V_STRLEN+1]; - char namestring[V_STRLEN+1]; - char snamestring[V_STRLEN+1]; - char middlestring[V_STRLEN+1]; + int gotclef; + int gotoctave; + int gottranspose; + int gotname; + int gotsname; + int gotmiddle; + int gotother; /* [SS] 2011-04-18 */ + int octave; + int transpose; + char clefname[V_STRLEN+1]; + cleftype_t new_clef; + char namestring[V_STRLEN+1]; + char snamestring[V_STRLEN+1]; + char middlestring[V_STRLEN+1]; char other[V_STRLEN+1]; /* [SS] 2011-04-18 */ - }; + }; typedef struct voice_context { char label[31]; int expect_repeat; int repeat_count; + cleftype_t clef; } voice_context_t; #define MAX_VOICES 30 @@ -119,7 +123,7 @@ extern void event_info_key(char *key, char *value); extern void event_info(char *s); extern void event_key(int sharps, char *s, int modeindex, char modmap[7], int modmul[7], struct fraction modmicro[7], - int gotkey, int gotclef, char *clefname, + int gotkey, int gotclef, char *clefname, cleftype_t *new_clef, int octave, int transpose, int gotoctave, int gottranspose, int explict); extern void event_microtone(int dir, int a, int b); @@ -145,7 +149,8 @@ extern void event_chordon(int chorddecorators[DECSIZE]); extern void event_chordoff(int, int); extern void event_instruction(char *s); extern void event_gchord(char *s); -extern void event_note(int decorators[DECSIZE], char accidental, int mult, +extern void event_note(int decorators[DECSIZE], cleftype_t *clef, + char accidental, int mult, char note, int xoctave, int n, int m); extern void event_abbreviation(char symbol, char *string, char container); extern void event_acciaccatura(); diff --git a/store.c b/store.c index bf22448..d2d4d44 100644 --- a/store.c +++ b/store.c @@ -185,7 +185,7 @@ int main() */ -#define VERSION "4.43 Ocober 12 2020 abc2midi" +#define VERSION "4.44 Ocober 19 2020 abc2midi" /* enables reading V: indication in header */ #define XTEN1 1 @@ -2972,6 +2972,10 @@ struct voice_params *vp; addfeature(VOICE, v->indexno, 0, 0); dependent_voice[v->indexno] = 0; + if (vp->gotclef) + { + event_octave(vp->new_clef.octave_offset, 1); + } if (vp->gotoctave) { event_octave(vp->octave,1); }; @@ -4262,9 +4266,10 @@ int num, denom; }; } -void event_note(decorators, accidental, mult, note, xoctave, n, m) +void event_note(decorators, clef, accidental, mult, note, xoctave, n, m) /* handles a note in the abc */ int decorators[DECSIZE]; +cleftype_t *clef; /* [JA] 2020-10-19 */ int mult; char accidental, note; int xoctave, n, m; @@ -5842,19 +5847,20 @@ static void headerprocess() voicesused = 0; } -void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, gotkey, gotclef, clefname, +void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, gotkey, gotclef, clefname, clef, octave, transpose, gotoctave, gottranspose, explict) /* handles a K: field */ int sharps; /* sharps is number of sharps in key signature */ -int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ char *s; /* original string following K: */ +int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ char modmap[7]; /* array of accidentals to be applied */ int modmul[7]; /* array giving multiplicity of each accent (1 or 2) */ struct fraction modmicrotone[7]; /* [SS] 2014-01-06 */ int gotkey, gotclef; +char* clefname; +cleftype_t *clef; /* [JA] 2020-10-19 */ int octave, transpose, gotoctave, gottranspose; int explict; -char* clefname; { int minor; minor =0; @@ -5883,6 +5889,10 @@ char* clefname; v = getvoicecontext(1); if (!inbody) v1index = notes; /* save position in case of split voice */ }; + if (gotclef) + { + event_octave(clef->octave_offset, 0); + } if (gotoctave) { event_octave(octave,0); }; diff --git a/structs.h b/structs.h index ecc6680..250a1e7 100644 --- a/structs.h +++ b/structs.h @@ -7,6 +7,8 @@ /* The voice data structure also holds various state variables */ /* to allow processing of voice data as it is read in */ +#include "music_utils.h" + enum tail_type {nostem, single, startbeam, midbeam, endbeam}; /* holds a fraction */ @@ -112,14 +114,8 @@ struct slurtie { int crossline; }; -enum cleftype {noclef, treble, soprano, mezzo, alto, tenor, baritone, bass}; enum linestate {header, midline, newline}; -struct aclef { - enum cleftype type; - int octave; -}; - /* holds calculated vertical spacing for one stave line */ /* associated with PRINTLINE */ struct vertspacing { @@ -181,7 +177,7 @@ struct voice { struct feature* chordplace; enum linestate line; /* following fields are initially inherited from tune */ - struct aclef* clef; + cleftype_t* clef; struct key* keysig; struct fract meter; struct atempo* tempo; @@ -215,7 +211,7 @@ struct tune { struct llist voices; struct voice* cv; struct fract unitlen; - struct aclef clef; + cleftype_t clef; struct llist words; }; diff --git a/toabc.c b/toabc.c index 428b439..0365f56 100644 --- a/toabc.c +++ b/toabc.c @@ -21,7 +21,7 @@ /* back-end for outputting (possibly modified) abc */ -#define VERSION "2.11 October 12 2020 abc2abc" +#define VERSION "2.12 October 19 2020 abc2abc" /* for Microsoft Visual C++ 6.0 or higher */ #ifdef _MSC_VER @@ -29,6 +29,7 @@ #endif #include "abc.h" +#include "music_utils.h" #include "parseabc.h" #include @@ -136,7 +137,6 @@ struct abctext* head; struct abctext* tail; -extern char *mode[]; extern int modekeyshift[]; int basemap[7], workmap[7]; /* for -nokey and pitchof() */ int workmul[7]; @@ -1489,7 +1489,8 @@ return 0; /* end of [SS] 2011-02-15 */ -void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, gotkey, gotclef, clefname, +void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, + gotkey, gotclef, clefname, new_clef, octave, xtranspose, gotoctave, gottranspose, explict) int sharps; char *s; @@ -1499,6 +1500,7 @@ int modmul[7]; struct fraction modmicrotone[7]; /* [SS[ 2014-01-06 */ int gotkey, gotclef; char* clefname; +cleftype_t *new_clef; /* [JA] 2020-10-19 */ int octave, xtranspose, gotoctave, gottranspose; int explict; { @@ -2240,8 +2242,9 @@ int *octave, *mult; -void event_note1(decorators, xaccidental, xmult, xnote, xoctave, n, m) +void event_note1(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m) int decorators[DECSIZE]; +cleftype_t *clef; /* [JA] 2020-10-19 */ int xmult; char xaccidental, xnote; int xoctave, n, m; @@ -2393,9 +2396,10 @@ int accidental_to_code (char xaccidental) } -void event_note2(decorators, xaccidental, xmult, xnote, xoctave, n, m) +void event_note2(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m) /* this function is called if flag nokey is set */ int decorators[DECSIZE]; +cleftype_t *clef; /* [JA] 2020-10-19 */ int xmult; char xaccidental, xnote; int xoctave, n, m; @@ -2454,16 +2458,17 @@ int xoctave, n, m; } -void event_note(decorators, xaccidental, xmult, xnote, xoctave, n, m) +void event_note(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m) int decorators[DECSIZE]; +cleftype_t *clef; /* [JA] 2020-10-19 */ int xmult; char xaccidental, xnote; int xoctave, n, m; { if (nokey) - event_note2(decorators, xaccidental, xmult, xnote, xoctave, n, m); + event_note2(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m); else - event_note1(decorators, xaccidental, xmult, xnote, xoctave, n, m); + event_note1(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m); } diff --git a/yapstree.c b/yapstree.c index 51453fd..146e910 100644 --- a/yapstree.c +++ b/yapstree.c @@ -22,7 +22,7 @@ /* yapstree.c - back-end for abc parser. */ /* generates a data structure suitable for typeset music */ -#define VERSION "1.81 October 12 2020 yaps" +#define VERSION "1.82 October 19 2020 yaps" #include #ifdef USE_INDEX #define strchr index @@ -53,6 +53,9 @@ extern void setup_fonts(); extern void printtune(struct tune *t); extern void set_keysig(struct key *k, struct key *newval); +/* forward definition */ +void event_clef(char* clefstr, cleftype_t * new_clef); + programname fileprogram = YAPS; extern int oldchordconvention; /* for handling +..+ chords */ @@ -202,15 +205,14 @@ static struct chord* newchord() return(f); } -struct aclef* newclef(enum cleftype t, int octave) +cleftype_t *newclef (cleftype_t * source_clef) /* create and initialize clef data structure */ { - struct aclef* f; + cleftype_t *f; /* [JA] 2020-10-19 */ - f = (struct aclef*)checkmalloc(sizeof(struct aclef)); - f->type = t; - f->octave = octave; - return(f); + f = (cleftype_t *) checkmalloc (sizeof (cleftype_t)); + copy_clef (f, source_clef); + return (f); } struct key* newkey(char* name, int sharps, char accidental[], int mult[]) @@ -556,60 +558,37 @@ struct llist* newlist() return(l); } -static int notenum(int octave, char ch, enum cleftype clef, int clefoctave) +static int notenum(int octave, char ch, cleftype_t * clef) /* converts note to number for stave position */ /* note E is zero (bottom line of stave) */ { int n; - n = 5 + (7 + ch -'c')%7 + 7*(octave-1); - switch (clef) { - case treble: - break; - case soprano: - n = n + 2; - break; - case mezzo: - n = n + 4; - break; - case alto: - n = n + 6; - break; - case tenor: - n = n + 8; - break; - case baritone: - n = n + 10; - break; - case bass: - n = n + 12; - break; - case noclef: - break; - }; - switch (clefoctave) { - case -22: - n = n + 21; - break; - case -15: - n = n + 14; - break; - case -8: - n = n + 7; - break; - case 8: - n = n - 7; - break; - case 15: - n = n - 14; - break; - case 22: - n = n - 21; - break; - default: - break; - }; - return(n); + n = 1 + (7 + ch - 'c') % 7 + 7 * (octave - 1); + /* apply shift associated with type of clef */ + switch (clef->basic_clef) { + default: + case basic_clef_treble: + case basic_clef_auto: + case basic_clef_perc: + case basic_clef_none: + case basic_clef_undefined: + /* no shift */ + break; + case basic_clef_bass: + n = n + 8; + break; + case basic_clef_alto: + n = n + 4; + break; + } + /* apply any shift from the placing of the clef */ + n = n + (2 * clef->staveline); + /* We ignore octave shift from the clef. This is understood as an + * instruction to the player to play in a different octave, but + * the written notes do not change position. + */ + return (n); } int count_dots(int *base, int *base_exp, int n, int m) @@ -684,9 +663,10 @@ static char* decstring(int decorators[]) }; } -static struct note* newnote(decorators, xaccidental, xmult, xnote, xoctave, +static struct note* newnote(decorators, clef, xaccidental, xmult, xnote, xoctave, a, b) int decorators[DECSIZE]; +cleftype_t *clef; /* [JA] 2020-10-19 */ int xmult; char xaccidental, xnote; int xoctave; @@ -711,7 +691,7 @@ int a, b; n->mult = xmult; n->octave = xoctave; n->pitch = xnote; - n->y = notenum(xoctave, xnote, cv->clef->type, cv->clef->octave); + n->y = notenum(xoctave, xnote, clef); if (n->y < 4) { n->stemup = 1; } else { @@ -801,7 +781,7 @@ static struct voice* newvoice(int n) v->barno = 0; v->barchecking = thetune.barchecking; setfract(&v->barlen, thetune.meter.num, thetune.meter.denom); - v->clef = newclef(thetune.clef.type, thetune.clef.octave); + v->clef = newclef(&thetune.clef); if (thetune.keysig == NULL) { printf("Trying to set up voice with no key signature\n"); exit(0); @@ -879,8 +859,8 @@ static void init_tune(struct tune* t, int x) setfract(&t->unitlen, 0, 1); t->cv = NULL; t->keysig = NULL; - t->clef.type = treble; - t->clef.octave = 0; + init_new_clef (&t->clef); + get_standard_clef ("treble", &t->clef); /* default to treble clef */ t->tempo = NULL; init_llist(&t->words); }; @@ -1380,7 +1360,7 @@ void event_startmusicline() cv->more_lyrics = 0; }; if ((cv->line == header) || (cv->line == newline)) { - addfeature(CLEF, newclef(cv->clef->type, cv->clef->octave)); + addfeature(CLEF, newclef(cv->clef)); addfeature(KEY, newkey(cv->keysig->name, cv->keysig->sharps, cv->keysig->map, cv->keysig->mult)); if ((cv->line == header)||(cv->changetime)) { @@ -1794,6 +1774,12 @@ struct voice_params *vp; { if (xinbody) { setvoice(n); + if (vp->gotclef) { + event_clef (vp->clefname, &vp->new_clef); + } + if (vp->gotoctave) { + event_octave (vp->octave, 0); + } } else { if (!suppress) { event_error("V: field outside tune body"); @@ -1905,82 +1891,18 @@ int n, m, checkbars; }; } -enum cleftype findclef(clefstr, oct) -char* clefstr; -int* oct; -/* converts a clef name string to an enumerated type */ -/* also looks for +8 +15 +22 -8 -15 -22 octave shift */ -{ - enum cleftype type; - char* p; - int interval; - - type = noclef; - p = clefstr; - if (strncmp(clefstr, "treble", 6)==0) { - type = treble; - p = p + 6; - }; - if (strncmp(clefstr, "bass", 4)==0) { - type = bass; - p = p + 4; - }; - if (strncmp(clefstr, "baritone", 8)==0) { - type = baritone; - p = p + 8; - }; - if (strncmp(clefstr, "tenor", 5)==0) { - type = tenor; - p = p + 5; - }; - if (strncmp(clefstr, "alto", 4)==0) { - type = alto; - p = p + 4; - }; - if (strncmp(clefstr, "mezzo", 5)==0) { - type = mezzo; - p = p + 5; - }; - if (strncmp(clefstr, "mezzo-soprano", 13)==0) { - type = mezzo; - p = p + 13; - }; - if (strncmp(clefstr, "soprano", 7)==0) { - type = soprano; - p = p + 7; - }; - interval = 0; - if ((type != noclef) && ((*p == '+') || (*p == '-'))) { - sscanf(p+1, "%d", &interval); - if ((interval == 8) || (interval == 15) || (interval == 22)) { - if (*p == '-') { - interval = -interval; - }; - } else { - interval = 0; - }; - }; - *oct = interval; - return(type); -} - -void event_clef(char* clefstr) +void event_clef(char* clefstr, cleftype_t * new_clef) /* a clef has been encountered in the abc */ { - enum cleftype clef; - int num; - - clef = findclef(clefstr, &num); + if (new_clef->basic_clef == basic_clef_undefined) { + return; + } if (xinbody) { - cv->clef->type = clef; - cv->clef->octave = num; - addfeature(CLEF, newclef(clef, num)); + copy_clef (cv->clef, new_clef); + addfeature (CLEF, newclef (new_clef)); }; if ((xinhead) && (!xinbody)) { - if (clef != noclef) { - thetune.clef.type = clef; - thetune.clef.octave = num; - }; + copy_clef (&thetune.clef, new_clef); }; } @@ -2117,7 +2039,8 @@ void event_octave(int num, int local) }; } -void event_key(sharps, s, minor, modmap, modmul, modmicrotone, gotkey, gotclef, clefstr, +void event_key(sharps, s, minor, modmap, modmul, modmicrotone, gotkey, + gotclef, clefstr, new_clef, octave, transpose, gotoctave, gottranspose, explict) int sharps; char *s; @@ -2126,21 +2049,26 @@ char modmap[7]; int modmul[7]; struct fraction modmicrotone[7]; /* [SS] 2014-01-06 */ int gotkey, gotclef; -char* clefstr; +char* clefstr; /* [JA] 2020-10-19 */ +cleftype_t * new_clef; int octave, transpose, gotoctave, gottranspose; int explict; /* A key field (K: ) has been encountered */ { if (xinhead || xinbody) { if (gotclef==1) { - event_clef(clefstr); + event_clef(clefstr, new_clef); }; if (gotkey==1) { event_true_key(sharps, s, minor, modmap, modmul); }; }; + if (gotclef) + { + event_octave(new_clef->octave_offset, 0); + } if (gotoctave) { - event_octave(octave,0); + event_octave(octave, 0); }; } @@ -2878,8 +2806,9 @@ char c; /* [SS] 2017-04-19 to distinguish X from Z in abc2abc */ xevent_rest(1, 1, n); } -void event_note(decorators, xaccidental, xmult, xnote, xoctave, n, m) +void event_note(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m) int decorators[DECSIZE]; +cleftype_t *clef; /* [JA] 2020-10-19 */ int xmult; char xaccidental, xnote; int xoctave, n, m; @@ -2890,7 +2819,7 @@ int xoctave, n, m; struct chord* thechord; int pitchval; - nt = newnote(decorators, xaccidental, xmult, xnote, xoctave+cv->octaveshift, + nt = newnote(decorators, clef, xaccidental, xmult, xnote, xoctave, n * cv->unitlen.num, m * cv->unitlen.denom); nt->tuplenotes = cv->tuplenotes; noteplace = addfeature(NOTE, nt); @@ -2905,7 +2834,7 @@ int xoctave, n, m; advance_ties(); } else { thechord = cv->thischord; - pitchval = notenum(xoctave, xnote, cv->clef->type, cv->clef->octave); + pitchval = notenum(xoctave, xnote, clef); if (cv->chordcount == 0) { thechord->ytop = pitchval; thechord->ybot = pitchval; @@ -2961,7 +2890,17 @@ char* value; int num; if (strcmp(key, "clef")==0) { - event_clef(value); + cleftype_t new_clef; /* [JA] 2020-10-19 */ + int valid_clef; + + init_new_clef (&new_clef); + valid_clef = get_standard_clef (value, &new_clef); + if (!valid_clef) { + valid_clef = get_extended_clef_details (value, &new_clef); + } + if (valid_clef) { + event_clef (value, &new_clef); + } }; if (strcmp(key, "octave")==0) { num = readsnumf(value);