From d0661261373b14a657a598a4a1dad324de6a3bd3 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 01:00:18 +0000 Subject: [PATCH] lilypond-1.3.146 --- Documentation/topdocs/INSTALL.texi | 15 + Documentation/user/converters.itely | 271 ++++++++++ Documentation/user/development.itexi | 2 +- GNUmakefile.in | 10 +- buildscripts/GNUmakefile | 8 +- input/test/Cc-chords.ly | 25 + lily/text-item.cc | 2 +- scm/chord-name.scm | 752 ++++++++++++++++----------- stepmake/bin/package-diff.py | 11 +- 9 files changed, 796 insertions(+), 300 deletions(-) create mode 100644 Documentation/user/converters.itely create mode 100644 input/test/Cc-chords.ly diff --git a/Documentation/topdocs/INSTALL.texi b/Documentation/topdocs/INSTALL.texi index 340221e642..c4a9e3b078 100644 --- a/Documentation/topdocs/INSTALL.texi +++ b/Documentation/topdocs/INSTALL.texi @@ -368,6 +368,21 @@ mailing your problems. If you find bugs, please send bug reports to Bugs that are not fault of LilyPond are documented here. +@unnumbered NetBSD + +@itemize @bullet +@item The flex precompiled in NetBSD-1.4.2 is broken. +Download flex-2.5.4a, build, install. + +@item The configuration of Gcc (egcs-2.91.60 19981201 (egcs-1.1.1 +release)) does not include @file{/usr/pkg} paths. Configure using: +@example + +CFLAGS='-I /usr/pkg/include' LDFLAGS='-L/usr/pkg/lib' ./configure + +@end example + +@end itemize @unnumbered Solaris: diff --git a/Documentation/user/converters.itely b/Documentation/user/converters.itely new file mode 100644 index 0000000000..84077b7130 --- /dev/null +++ b/Documentation/user/converters.itely @@ -0,0 +1,271 @@ +@c -*-texinfo-*- + +@node Conversion tools +@chapter Converting to LilyPond format. + + +@menu +* midi2ly:: +* etf2ly:: +* abc2ly:: +* pmx2ly:: +* musedata2ly:: +* mup2ly:: +@end menu + +@node midi2ly +@section midi2ly + +Midi2ly translates a MIDI input file to a LilyPond source file. MIDI +(Music Instrument Digital Interface) is a standard for digital +instruments: it specifies cabling, a serial protocol and a file format. + +It is possible to record a MIDI file using a digital keyboard, and then +convert it to @file{.ly}. However, human players can not rhythmically +exact enough to make a MIDI to .ly conversion trivial. midi2ly tries to +compensate for these timing errors, but is not very good at this. It is +therefore not recommended to use midi2ly for human-generated midi +files. Correcting the quantization mistakes of the human player takes a +lot of time. + +Hackers who know about signal processing are invited to write a more +robust midi2ly. + +MIDI is also a de facto standard format for exporting music from other +programs, so this capability may come in useful when you want to import +files from a program that has no converter for its native format. + +@subsection Invoking midi2ly + +@example + midi2ly [OPTION]... MIDI-FLIE +@end example + +@unnumberedsubsec Options + +@table @code +@item -b, --no-quantify, + Write exact durations, e.g.: `a4*385/384'. +@item -D, --debug, + Print lots of debugging stuff. +@item -h, --help, + Show a summary of usage. +@item -I, --include=@file{DIR}, + Add DIR to search path. +@item -k, --key=ACC[:MINOR], + Set default key. ACC > 0 sets number of sharps; ACC < 0 sets number + of flats. A minor key is indicated by ":1". +@item -n, --no-silly, + Assume no plets or double dots, assume smallest (reciprocal) duration 16. +@item -o, --output=@file{FILE}, + Set @file{FILE} as default output. +@item -p, --no-plets, + Assume no plets. +@item -q, --quiet, + Be quiet. +@item -s, --smallest=N, + Assume no shorter (reciprocal) durations than N. +@item -v, --verbose, + Be verbose. +@item -w, --warranty, + Show the warranty with which midi2ly comes. (It comes with @strong{NO WARRANTY}!) +@item -x, --no-double-dots, + Assume no double dotted notes. +@end table + + +Report bugs to @email{bug-gnu-music@@gnu.org}. + + +Written by @email{Jan Nieuwenhuizen, janneke@@gnu.org}. + + +@node etf2ly +@section etf2ly + + +ETF (Enigma Transport Format) is a format used by Coda Music +Technology's Finale product. This program will convert part of an ETF +file to a ready-to-use LilyPond file. + +@subsection Invoking etf2ly +Usage: + +@example + etf2ly [OPTION]... ETF-FILE +@end example + +Convert ETF to LilyPond. + +@unnumberedsubsec Options +@table @code +@item -h,--help +this help +@item -o,--output=FILE +set output filename to FILE +@item -v,--version +version information +@end table + + +@refbugs + +Known: articulation scripts are buggy. Empty measures confuse etf2ly. +Report bugs to @email{bug-gnu-music@@gnu.org}. + +Written by @email{Han-Wen Nienhuys,hanwen@@cs.uu.nl}. + + +Report bugs to @email{bug-gnu-music@@gnu.org}. + +@node abc2ly +@section abc2ly + +ABC is a fairly simple ASCII based format. It is described at +@uref{http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt}. + +@subsection Invoking abc2ly + +@example + abc2ly [OPTION]... ABC-FILE +@end example + +Convert ABC to LilyPond. + +@unnumberedsubsec Options +@table @code +@item -h,--help +this help +@item -o,--output=FILE +set output filename to FILE +@item -v,--version +version information +@end table + +@refbugs + +The ABC standard is not very "standard". For extended features +(eg. polyphonic music) different conventions exist. + + +Written by @email{Han-Wen Nienhuys,hanwen@@cs.uu.nl}. + + +Report bugs to @email{bug-gnu-music@@gnu.org}. + +@node pmx2ly +@section pmx2ly + +PMX is a Musixtex preprocessor written by Don Simons, see +@uref{http://www.gmd.de/Misc/Music/musixtex/software/pmx/}. + +Report bugs to @email{bug-gnu-music@@gnu.org}. + +@subsection Invoking pmx2ly + +@example + pmx2ly [OPTION]... PMX-FILE +@end example + +Convert PMX to LilyPond. + +@unnumberedsubsec Options + +@table @code +@item -h,--help +this help +@item -o,--output=FILE +set output filename to FILE +@item -v,--version +version information +@end table + +Report bugs to @email{bug-gnu-music@@gnu.org}. + +Written by @email{Han-Wen Nienhuys,hanwen@@cs.uu.nl}. + + +@node musedata2ly +@section musedata2ly + + Musedata (@uref{http://www.musedata.org/}) is an electronic library of +classical music scores, currently comprising about 800 composition +dating from 1700 to 1825. The music is encoded in so-called Musedata +format +(@uref{http://www.ccarh.org/publications/books/beyondmidi/online/musedata}). +musedata2ly converts a set of musedata files to one .ly file, and will +include a \header field if a .ref file is supplied + +@subsection Invoking musedata2ly + +@example + musedata2ly [OPTION]... MUSEDATA-FILE +@end example + +Convert Musedata to LilyPond. + +@unnumberedsubsec Options + +@table @code +@item -h,--help +print help +@item -o,--output=@var{file} +set output filename to @var{file} +@item -v,--version +version information +@item -r,--ref=@var{reffile} + read background information from ref-file +@var{REFFILE} +@end table + +Report bugs to @email{bug-gnu-music@@gnu.org}. + +Written by @email{Han-Wen Nienhuys,hanwen@@cs.uu.nl}. + + +@node mup2ly +@section mup2ly + +MUP (Music Publisher) is a shareware music notation program by Arkkra +Enterprises. It is also the name of the input format. Mup2ly will +convert part of a Mup file to a ready-to-use LilyPond file. + +@subsection Invoking mup2ly + +@example + mup2ly [OPTION]... MUP-FILE +@end example + +Convert Mup to LilyPond. + +@unnumberedsubsec Options + +@table @code +@item -d,--debug +show what constructs are not converted, but skipped. +@item D, --define=@var{NAME}[=@code{EXP}] +define macro @var{NAME} with opt expansion @code{EXP} +@item -E,--pre-process +only run the pre-processor +@item -h,--help +print help +@item -o,--output=FILE +write output to @var{FILE} +@item -v,--version +version information +@item -w,--warranty +print warranty and copyright. Mup2ly comes with absolutlely @strong{NO WARRANTY}. +@end table + + +@refbugs + +Currently, only plain notes (pitches, durations), voices and staffs are +converted. + +Written by @email{Jan Nieuwenhuizen,janneke@@gnu.org}, based on pmx2ly. + +Report bugs to @email{bug-gnu-music@@gnu.org}. + + + diff --git a/Documentation/user/development.itexi b/Documentation/user/development.itexi index b7a994b97c..99b1da6958 100644 --- a/Documentation/user/development.itexi +++ b/Documentation/user/development.itexi @@ -568,7 +568,7 @@ There are also numerous other interesting projects that are more or less related to LilyPond @itemize @bullet -@item Writing convertors, eg. from NIFF and MIDI (we tried writing one with +@item Writing converters, eg. from NIFF and MIDI (we tried writing one with limited success: midi2ly, included with lilypond.) We found that writing them in Python is the easiest. diff --git a/GNUmakefile.in b/GNUmakefile.in index 42da1397ef..81c9024e1c 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -6,11 +6,13 @@ depth = . # -# descent order into subdirectories: -# -SUBDIRS = buildscripts scripts flower lily mf midi2ly po \ - Documentation ly input tex make intl ps scm \ +# descent order into subdirectories +# +SUBDIRS = buildscripts scripts flower lily \ + mf ly tex ps scm \ + midi2ly po make intl \ debian $(builddir)/stepmake \ + Documentation input \ mutopia ports # diff --git a/buildscripts/GNUmakefile b/buildscripts/GNUmakefile index a1d371d022..71fc0d2a82 100644 --- a/buildscripts/GNUmakefile +++ b/buildscripts/GNUmakefile @@ -1,13 +1,19 @@ # bin/Makefile depth = .. -STEPMAKE_TEMPLATES=script install po +STEPMAKE_TEMPLATES=script install install-out po include $(depth)/make/stepmake.make INSTALLATION_FILES=$(outdir)/gettext.py INSTALLATION_DIR=$(datadir)/python +# Should we install these? This should be handled by sysadmin or +# packager but if she forgets... +#INSTALLATION_OUT_SUFFIXES=1 +#INSTALLATION_OUT_DIR1=$(datadir)/scripts +#INSTALLATION_OUT_FILES1=$(outdir)/lilypond-login $(outdir)/lilypond-profile + all: $(outdir)/gettext.py diff --git a/input/test/Cc-chords.ly b/input/test/Cc-chords.ly new file mode 100644 index 0000000000..b92cb37198 --- /dev/null +++ b/input/test/Cc-chords.ly @@ -0,0 +1,25 @@ +\header { + texidoc="Jazz chord names, but with lower case names for minor chords"; +} + +#(assoc-set! chord::names-alist-jazz + '((0 . 0) (2 . -1)) '("")) + +#(assoc-set! chord::names-alist-jazz + '((0 . 0) (2 . -1) (4 . 0) (6 . -1)) '("7")) + +#(define (pitch->chord-name-text-banter pitch additions) + (let ((name (pitch->text-banter pitch))) + (if (member '(2 . -1) (map pitch->note-name additions)) + (cons (string-append + (string-downcase (substring (car name) 0 1)) + (substring (car name) 1)) + (cdr name)) + name))) + +\score { + < + \property ChordNames.ChordName \set #'style = #'jazz + \context ChordNames \chords { c1 c:m c:m7 } + > +} diff --git a/lily/text-item.cc b/lily/text-item.cc index 9c40d40e9e..afd032dfed 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -38,7 +38,7 @@ Text_item::text2molecule (Grob *me, SCM text, SCM alist_chain) { if (gh_string_p (text)) return string2molecule (me, text, alist_chain); - else if (gh_list_p (text)) + else if (gh_list_p (text) && text != SCM_EOL && text != SCM_UNDEFINED) { if (!gh_pair_p (gh_car (text)) && gh_string_p (gh_car (text))) return string2molecule (me, gh_car (text), alist_chain); diff --git a/scm/chord-name.scm b/scm/chord-name.scm index 920875a15b..87a5d543e8 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -24,7 +24,7 @@ ;; TODO ;; -;; * clean split of base/banter/american stuff +;; * clean split of bass/banter/american stuff ;; * text definition is rather ad-hoc ;; * do without format module ;; * finish and check american names @@ -57,6 +57,372 @@ ) chord::names-alist-banter)) +;;;;;;;;;; + + +(define (accidental->text acc) + (if (= acc 0) + '() + (list '(music (font-relative-size . -2)) + (string-append "accidentals-" (number->string acc))))) + +(define (accidental->text-super acc) + (if (= acc 0) + '() + (cons 'super (list (accidental->text acc))))) + +(define (accidental->text-sub acc) + (if (= acc 0) + '() + (cons sub (list accidental->text acc)))) + + +(define (pitch->note-name pitch) + (cons (cadr pitch) (caddr pitch))) + +(define (pitch->text pitch) + (cons + (make-string 1 (integer->char (+ (modulo (+ (cadr pitch) 2) 7) 65))) + (accidental->text-super (caddr pitch)))) + + +;;; Hooks to override chord names and note names, +;;; see input/tricks/german-chords.ly + +(define (pitch->text-banter pitch) + (pitch->text pitch)) + +;; We need also steps, to allow for Cc name override, +;; see input/test/Cc-chords.ly +(define (pitch->chord-name-text-banter pitch steps) + (pitch->text-banter pitch)) + +(define (pitch->note-name-text-banter pitch) + (pitch->text-banter pitch)) + +(define (step->text pitch) + (list (string-append + (number->string (+ (cadr pitch) (if (= (car pitch) 0) 1 8))) + (case (caddr pitch) + ((-2) "--") + ((-1) "-") + ((0) "") + ((1) "+") + ((2) "++"))))) + +(define (step->text-banter pitch) + (if (= (cadr pitch) 6) + (case (caddr pitch) + ((-2) '("7-")) + ((-1) '("7")) + ((0) '("maj7")) + ((1) '("7+")) + ((2) '("7+"))) + (step->text pitch))) + +(define pitch::semitone-vec (list->vector '(0 2 4 5 7 9 11))) + +(define (pitch::semitone pitch) + (+ (* (car pitch) 12) + (vector-ref pitch::semitone-vec (modulo (cadr pitch) 7)) + (caddr pitch))) + +(define (pitch::transpose pitch delta) + (let ((simple-octave (+ (car pitch) (car delta))) + (simple-notename (+ (cadr pitch) (cadr delta)))) + (let ((octave (+ simple-octave (quotient simple-notename 7))) + (notename (modulo simple-notename 7))) + (let ((accidental (- (+ (pitch::semitone pitch) (pitch::semitone delta)) + (pitch::semitone `(,octave ,notename 0))))) + `(,octave ,notename ,accidental))))) + +(define (pitch::diff pitch tonic) + (let ((simple-octave (- (car pitch) (car tonic))) + (simple-notename (- (cadr pitch) (cadr tonic)))) + (let ((octave (+ simple-octave (quotient simple-notename 7) + (if (< simple-notename 0) -1 0))) + (notename (modulo simple-notename 7))) + (let ((accidental (- (pitch::semitone pitch) + (pitch::semitone tonic) + (pitch::semitone `(,octave ,notename 0))))) + `(,octave ,notename ,accidental))))) + +(define (pitch::note-pitch pitch) + (+ (* (car pitch) 7) (cadr pitch))) + + +(define (write-me n x) + (display n) + (write x) + (newline) + x) + +(define (empty? x) + (equal? x '())) + +(define (chord::text? text) + (not (or (not text) (empty? text) (unspecified? text)))) + +;; recursively remove '() #f, and # from text +(define (chord::text-cleanup dirty) + (if (pair? dirty) + (let ((r (car dirty))) + (if (chord::text? r) + (cons (if (pair? r) (chord::text-cleanup r) r) + (chord::text-cleanup (cdr dirty))) + (chord::text-cleanup (cdr dirty)))) + (if (chord::text? dirty) + dirty + '()))) + +(define (chord::text-append l . r) + (if (not (chord::text? r)) + l + (if (not (chord::text? l)) + r + (cons l r)))) + +(define (chord::step tonic pitch) + (- (pitch::note-pitch pitch) (pitch::note-pitch tonic))) + +;; text: list of word +;; word: string + optional list of property +;; property: align, kern, font (?), size + +(define chord::minor-major-vec (list->vector '(0 -1 -1 0 -1 -1 0))) + +;; compute the relative-to-tonic pitch that goes with 'step' +(define (chord::step-pitch tonic step) + ;; urg, we only do this for thirds + (if (= (modulo step 2) 0) + '(0 0 0) + (let loop ((i 1) (pitch tonic)) + (if (= i step) pitch + (loop (+ i 2) + (pitch::transpose + pitch `(0 2 ,(vector-ref chord::minor-major-vec + ;; -1 (step=1 -> vector=0) + 7 = 6 + (modulo (+ i 6) 7))))))))) + +;; find the pitches that are not part of `normal' chord +(define (chord::additions chord-pitches) + (let ((tonic (car chord-pitches))) + ;; walk the chord steps: 1, 3, 5 + (let loop ((step 1) (pitches chord-pitches) (additions '())) + (if (pair? pitches) + (let* ((pitch (car pitches)) + (p-step (+ (- (pitch::note-pitch pitch) + (pitch::note-pitch tonic)) + 1))) + ;; pitch is an addition if + (if (or + ;; it comes before this step or + (< p-step step) + ;; its step is even or + (= (modulo p-step 2) 0) + ;; has same step, but different accidental or + (and (= p-step step) + (not (equal? pitch (chord::step-pitch tonic step)))) + ;; is the last of the chord and not one of base thirds + (and (> p-step 5) + (= (length pitches) 1))) + (loop step (cdr pitches) (cons pitch additions)) + (if (= p-step step) + (loop step (cdr pitches) additions) + (loop (+ step 2) pitches additions)))) + (reverse additions))))) + +;; find the pitches that are missing from `normal' chord +(define (chord::subtractions chord-pitches) + (let ((tonic (car chord-pitches))) + (let loop ((step 1) (pitches chord-pitches) (subtractions '())) + (if (pair? pitches) + (let* ((pitch (car pitches)) + (p-step (+ (- (pitch::note-pitch pitch) + (pitch::note-pitch tonic)) + 1))) + ;; pitch is an subtraction if + ;; a step is missing or + (if (> p-step step) + (loop (+ step 2) pitches + (cons (chord::step-pitch tonic step) subtractions)) + ;; there are no pitches left, but base thirds are not yet done and + (if (and (<= step 5) + (= (length pitches) 1)) + ;; present pitch is not missing step + (if (= p-step step) + (loop (+ step 2) pitches subtractions) + (loop (+ step 2) pitches + (cons (chord::step-pitch tonic step) subtractions))) + (if (= p-step step) + (loop (+ step 2) (cdr pitches) subtractions) + (loop step (cdr pitches) subtractions))))) + (reverse subtractions))))) + + +(define (chord::additions->text-banter additions subtractions) + (if (pair? additions) + (cons (apply append + (chord::text-cleanup + (list + (cons 'super (step->text-banter (car additions))) + (if (or (pair? (cdr additions)) + (pair? subtractions)) + '(super "/"))))) + (chord::additions->text-banter (cdr additions) subtractions)) + '())) + +(define (chord::subtractions->text-banter subtractions) + (if (pair? subtractions) + (cons (apply append + (chord::text-cleanup + (list + '(super "no") + (cons 'super (step->text-banter (car subtractions))) + (if (pair? (cdr subtractions)) + '(super "/"))))) + (chord::subtractions->text-banter (cdr subtractions))) + '())) + + +(define (chord::bass-and-inversion->text-banter bass-and-inversion) + (if (and (pair? bass-and-inversion) + (or (car bass-and-inversion) + (cdr bass-and-inversion))) + (list "/" (if (car bass-and-inversion) + (pitch->note-name-text-banter + (car bass-and-inversion)) + (pitch->note-name-text-banter + (cdr bass-and-inversion))) + '()) + '())) + +;; Banter style +;; Combine tonic, exception-part of chord name, +;; additions, subtractions and bass or inversion into chord name +(define (chord::inner-name-banter tonic exception-part additions subtractions + bass-and-inversion steps) + ;; ugh + (apply + append + (chord::text-cleanup + (list '(rows) + (pitch->chord-name-text-banter tonic steps) + exception-part + ;; why does list->string not work, format seems only hope... + (if (and (string-match "super" (format "~s" exception-part)) + (or (pair? additions) + (pair? subtractions))) + '((super "/"))) + (chord::additions->text-banter additions subtractions) + (chord::subtractions->text-banter subtractions) + (chord::bass-and-inversion->text-banter bass-and-inversion))))) + +(define (chord::name-banter tonic exception-part unmatched-steps + bass-and-inversion steps) + (let ((additions (chord::additions unmatched-steps)) + (subtractions (chord::subtractions unmatched-steps))) + (chord::inner-name-banter tonic exception-part additions subtractions + bass-and-inversion steps))) + + +(define (c++-pitch->scm p) + (if (pitch? p) + (list (pitch-octave p) (pitch-notename p) (pitch-alteration p)) + #f)) + +(define (chord::name-banter tonic exception-part unmatched-steps + bass-and-inversion steps) + (let ((additions (chord::additions unmatched-steps)) + (subtractions (chord::subtractions unmatched-steps))) + (chord::inner-name-banter tonic exception-part additions subtractions + bass-and-inversion steps))) + +(define (chord::restyle name style) + (ly-eval (string->symbol + (string-append (symbol->string name) + (symbol->string style))))) + +;; check exceptions-alist for biggest matching part of try-steps +;; return (MATCHED-EXCEPTION . UNMATCHED-STEPS) +(define (chord::exceptions-lookup-helper + exceptions-alist try-steps unmatched-steps exception-part) + (if (pair? try-steps) + ;; FIXME: junk '(0 . 0) from exceptions lists + ;; + ;; FIXME: either format exceptions list as real pitches, ie, + ;; including octave '((0 2 -1) ..), or drop octave + ;; from rest of calculations, + (let ((entry (assoc + (map (lambda (x) (pitch->note-name x)) + (append '((0 0 0)) try-steps)) + exceptions-alist))) + (if entry + (chord::exceptions-lookup-helper + #f '() unmatched-steps (cdr entry)) + (let ((r (reverse try-steps))) + (chord::exceptions-lookup-helper + exceptions-alist + (reverse (cdr r)) + (cons (car r) unmatched-steps) #f)))) + (cons exception-part unmatched-steps))) + +;; return (MATCHED-EXCEPTION . BASE-CHORD-WITH-UNMATCHED-STEPS) +;; BASE-CHORD-WITH-UNMATCHED-STEPS always includes (tonic 3 5) +(define (chord::exceptions-lookup style steps) + (let* ((result (chord::exceptions-lookup-helper + (chord::restyle 'chord::names-alist- style) + steps '() #f)) + (exception-part (car result)) + (unmatched-steps (cdr result)) + (matched-steps (if (= (length unmatched-steps) 0) + 3 + (+ 1 (- (length steps) + (length unmatched-steps))))) + (unmatched-with-1-3-5 + (append (do ((i matched-steps (- i 1)) + (base '() (cons `(0 ,(* (- i 1) 2) 0) base))) + ((= i 0) base) + ()) + unmatched-steps))) + (list exception-part unmatched-with-1-3-5))) + + +(define (chord::name->text style tonic steps bass-and-inversion) + (let* ((lookup (chord::exceptions-lookup style steps)) + (exception-part (car lookup)) + (unmatched-steps (cadr lookup))) + ((chord::restyle 'chord::name- style) + tonic exception-part unmatched-steps bass-and-inversion steps))) + +;; C++ entry point +;; +;; Check for each subset of chord, full chord first, if there's a +;; user-override. Split the chord into user-overridden and to-be-done +;; parts, complete the missing user-override matched part with normal +;; chord to be name-calculated. +;; +;; CHORD: (pitches (bass . inversion)) +(define (default-chord-name-function style chord) + (let* ((pitches (map c++-pitch->scm (car chord))) + (modifiers (cdr chord)) + (bass-and-inversion (if (pair? modifiers) + (cons (c++-pitch->scm (car modifiers)) + (c++-pitch->scm (cdr modifiers))) + '(() . ()))) + (diff (pitch::diff '(0 0 0) (car pitches))) + (steps (if (cdr pitches) (map (lambda (x) + (pitch::transpose x diff)) + (cdr pitches)) + '()))) + (chord::name->text style (car pitches) steps bass-and-inversion))) + + + +;;; +;;; American style +;;; + ;; NOTE: Duplicates of chord names defined elsewhere occur in this list ;; in order to prevent spurious superscripting of various chord names, @@ -89,6 +455,7 @@ ;; Common seventh chords (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ("" (super "o") "7")) (((0 . 0) (2 . 0) (4 . 0) (6 . 0)) . ("maj7")) + ;; urg! should use (0 . 0 2 . -1) -> "m", and add "7" to that!! (((0 . 0) (2 . -1) (4 . 0) (6 . -1)) . ("m7")) (((0 . 0) (2 . 0) (4 . 0) (6 . -1)) . ("7")) (((0 . 0) (2 . -1) (4 . 0) (6 . 0)) . ("m(maj7)")) @@ -114,8 +481,26 @@ ) chord::names-alist-american)) + +;; American style chordnames use no "no", +;; but otherwise very similar to banter for now +(define (chord::name-american tonic exception-part unmatched-steps + bass-and-inversion steps) + (let ((additions (chord::additions unmatched-steps)) + (subtractions #f)) + (chord::inner-name-banter tonic exception-part additions subtractions + bass-and-inversion steps))) + + + +;;; +;;; Jazz style +;;; + + + ;; Jazz chords, by Atte Andr'e Jensen -;; NBs: This uses the american list as a base. +;; NBs: This uses the american list as a bass. ;; Some defs take up more than one line, ;; be carefull when messing with ;'s!! @@ -251,297 +636,84 @@ ) chord::names-alist-american)) -;;;;;;;;;; - - -(define (pitch->note-name pitch) - (cons (cadr pitch) (caddr pitch))) - -(define (accidental->text acc) - (if (= acc 0) - '() - (list - (append '(music) - (list - (append '(named) - (list - (append '((font-relative-size . -2)) - (list (append '((raise . 0.6)) - (list - (string-append "accidentals-" - (number->string acc)))))))))))) -) - -(define (pitch->text pitch) +(define (step->text-alternate-jazz pitch) (cons - (make-string 1 (integer->char (+ (modulo (+ (cadr pitch) 2) 7) 65))) - (accidental->text (caddr pitch)) - ) -) - -;;; Hooks to override chord names and note names, -;;; see input/tricks/german-chords.ly - -(define (pitch->text-banter pitch) - (pitch->text pitch)) - -(define (pitch->chord-name-text-banter pitch) - (pitch->text-banter pitch)) + (accidental->text (caddr pitch)) + (list (number->string (+ (cadr pitch) (if (= (car pitch) 0) 1 8)))))) -(define (pitch->note-name-text-banter pitch) - (pitch->text-banter pitch)) - -(define (step->text pitch) - (string-append - (number->string (+ (cadr pitch) (if (= (car pitch) 0) 1 8))) - (case (caddr pitch) - ((-2) "--") - ((-1) "-") - ((0) "") - ((1) "+") - ((2) "++")))) - -(define (step->text-banter pitch) +(define (step->text-jazz pitch) (if (= (cadr pitch) 6) (case (caddr pitch) - ((-2) "7-") - ((-1) "7") - ((0) "maj7") - ((1) "7+") - ((2) "7+")) - (step->text pitch))) - -(define pitch::semitone-vec (list->vector '(0 2 4 5 7 9 11))) - -(define (pitch::semitone pitch) - (+ (* (car pitch) 12) - (vector-ref pitch::semitone-vec (modulo (cadr pitch) 7)) - (caddr pitch))) - -(define (pitch::transpose pitch delta) - (let ((simple-octave (+ (car pitch) (car delta))) - (simple-notename (+ (cadr pitch) (cadr delta)))) - (let ((octave (+ simple-octave (quotient simple-notename 7))) - (notename (modulo simple-notename 7))) - (let ((accidental (- (+ (pitch::semitone pitch) (pitch::semitone delta)) - (pitch::semitone `(,octave ,notename 0))))) - `(,octave ,notename ,accidental))))) - -(define (pitch::diff pitch tonic) - (let ((simple-octave (- (car pitch) (car tonic))) - (simple-notename (- (cadr pitch) (cadr tonic)))) - (let ((octave (+ simple-octave (quotient simple-notename 7) - (if (< simple-notename 0) -1 0))) - (notename (modulo simple-notename 7))) - (let ((accidental (- (pitch::semitone pitch) - (pitch::semitone tonic) - (pitch::semitone `(,octave ,notename 0))))) - `(,octave ,notename ,accidental))))) - -(define (pitch::note-pitch pitch) - (+ (* (car pitch) 7) (cadr pitch))) - -(define (chord::step tonic pitch) - (- (pitch::note-pitch pitch) (pitch::note-pitch tonic))) - -;; text: list of word -;; word: string + optional list of property -;; property: align, kern, font (?), size - -(define chord::minor-major-vec (list->vector '(0 -1 -1 0 -1 -1 0))) - -;; compute the relative-to-tonic pitch that goes with 'step' -(define (chord::step-pitch tonic step) - ;; urg, we only do this for thirds - (if (= (modulo step 2) 0) - '(0 0 0) - (let loop ((i 1) (pitch tonic)) - (if (= i step) pitch - (loop (+ i 2) - (pitch::transpose - pitch `(0 2 ,(vector-ref chord::minor-major-vec - ;; -1 (step=1 -> vector=0) + 7 = 6 - (modulo (+ i 6) 7))))))))) - -;; find the pitches that are not part of `normal' chord -(define (chord::additions chord-pitches) - (let ((tonic (car chord-pitches))) - ;; walk the chord steps: 1, 3, 5 - (let loop ((step 1) (pitches chord-pitches) (additions '())) - (if (pair? pitches) - (let* ((pitch (car pitches)) - (p-step (+ (- (pitch::note-pitch pitch) - (pitch::note-pitch tonic)) - 1))) - ;; pitch is an addition if - (if (or - ;; it comes before this step or - (< p-step step) - ;; its step is even or - (= (modulo p-step 2) 0) - ;; has same step, but different accidental or - (and (= p-step step) - (not (equal? pitch (chord::step-pitch tonic step)))) - ;; is the last of the chord and not one of base thirds - (and (> p-step 5) - (= (length pitches) 1))) - (loop step (cdr pitches) (cons pitch additions)) - (if (= p-step step) - (loop step (cdr pitches) additions) - (loop (+ step 2) pitches additions)))) - (reverse additions))))) - -;; find the pitches that are missing from `normal' chord -(define (chord::subtractions chord-pitches) - (let ((tonic (car chord-pitches))) - (let loop ((step 1) (pitches chord-pitches) (subtractions '())) - (if (pair? pitches) - (let* ((pitch (car pitches)) - (p-step (+ (- (pitch::note-pitch pitch) - (pitch::note-pitch tonic)) - 1))) - ;; pitch is an subtraction if - ;; a step is missing or - (if (> p-step step) - (loop (+ step 2) pitches - (cons (chord::step-pitch tonic step) subtractions)) - ;; there are no pitches left, but base thirds are not yet done and - (if (and (<= step 5) - (= (length pitches) 1)) - ;; present pitch is not missing step - (if (= p-step step) - (loop (+ step 2) pitches subtractions) - (loop (+ step 2) pitches - (cons (chord::step-pitch tonic step) subtractions))) - (if (= p-step step) - (loop (+ step 2) (cdr pitches) subtractions) - (loop step (cdr pitches) subtractions))))) - (reverse subtractions))))) - -;; combine tonic, user-specified chordname, -;; additions, subtractions and base or inversion to chord name -;; -(define (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion) - (apply append - '(rows) - (pitch->chord-name-text-banter tonic) - (if user-name user-name '()) - ;; why does list->string not work, format seems only hope... - (if (and (string-match "super" (format "~s" user-name)) - (or (pair? additions) - (pair? subtractions))) - '((super "/")) - '()) - (let loop ((from additions) (to '())) - (if (pair? from) - (let ((p (car from))) - (loop (cdr from) - (append to - (cons - (list 'super (step->text-banter p)) - (if (or (pair? (cdr from)) - (pair? subtractions)) - '((super "/")) - '()))))) - to)) - (let loop ((from subtractions) (to '())) - (if (pair? from) - (let ((p (car from))) - (loop (cdr from) - (append to - (cons '(super "no") - (cons - (list 'super (step->text-banter p)) - (if (pair? (cdr from)) - '((super "/")) - '())))))) ; nesting? - to)) - (if (and (pair? base-and-inversion) - (or (car base-and-inversion) - (cdr base-and-inversion))) - (cons "/" (append - (if (car base-and-inversion) - (pitch->note-name-text-banter - (car base-and-inversion)) - (pitch->note-name-text-banter - (cdr base-and-inversion))) - '())) - '()) - '())) - -(define (chord::name-banter tonic user-name pitches base-and-inversion) - (let ((additions (chord::additions pitches)) - (subtractions (chord::subtractions pitches))) - (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion))) - -;; american chordnames use no "no", -;; but otherwise very similar to banter for now -(define (chord::name-american tonic user-name pitches base-and-inversion) - (let ((additions (chord::additions pitches)) - (subtractions #f)) - (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion))) + ;; sharp 7 only included for completeness? + ((-2) (cons (accidental->text -1) '("7"))) + ((-1) '("7")) + ((0) '("maj7")) + ((1) (cons (accidental->text-super 1) '("7"))) + ((2) (cons (accidental->text-super 2) '("7")))) + (step->text-alternate-jazz pitch))) + +(define (chord::additions->text-jazz additions subtractions) + (if (pair? additions) + (cons (apply append + (chord::text-cleanup + (list + (cons 'super (step->text-jazz (car additions))) + (if (or (pair? (cdr additions)) + (pair? subtractions)) + '(super "/"))))) + (chord::additions->text-jazz (cdr additions) subtractions)) + '())) + +(define (chord::subtractions->text-jazz subtractions) + (if (pair? subtractions) + (cons (apply append + (chord::text-cleanup + (list + '(super "omit") + (cons 'super (step->text-jazz (car subtractions))) + (if (pair? (cdr subtractions)) + '(super "/"))))) + (chord::subtractions->text-jazz (cdr subtractions))) + '())) + + +;; TODO: maybe merge with inner-name-banter +;; Combine tonic, exception-part of chord name, +;; additions, subtractions and bass or inversion into chord name +(define (chord::inner-name-jazz tonic exception-part additions subtractions + bass-and-inversion steps) + + ;; ugh + (apply + append + + (chord::text-cleanup + (list '(rows) + (pitch->chord-name-text-banter tonic steps) + exception-part + ;; why does list->string not work, format seems only hope... + (if (and (string-match "super" (format "~s" exception-part)) + (or (pair? additions) + (pair? subtractions))) + '((super "/"))) + (chord::additions->text-jazz additions subtractions) + (chord::subtractions->text-jazz subtractions) + (chord::bass-and-inversion->text-banter bass-and-inversion))))) ;; Jazz style--basically similar to american with minor changes -(define (chord::name-jazz tonic user-name pitches base-and-inversion) - (let ((additions (chord::additions pitches)) - (subtractions #f)) - (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion))) - -(define (new-to-old-pitch p) - (if (pitch? p) - (list (pitch-octave p) (pitch-notename p) (pitch-alteration p)) - #f - )) - - - -;; C++ entry point -;; -;; Check for each subset of chord, full chord first, if there's a -;; user-override. Split the chord into user-overridden and to-be-done -;; parts, complete the missing user-override matched part with normal -;; chord to be name-calculated. -;; -;; CHORD: (pitches (base . inversion)) -(define (default-chord-name-function style chord) - (let* ((style-string (symbol->string style)) - (pitches (map new-to-old-pitch (car chord))) - (modifiers (cdr chord)) - (base-and-inversion (if (pair? modifiers) - (cons (new-to-old-pitch (car modifiers)) - (new-to-old-pitch (cdr modifiers))) - '(() . ()))) - (diff (pitch::diff '(0 0 0) (car pitches))) - (name-func - (ly-eval (string->symbol (string-append "chord::name-" style-string)))) - (names-alist - (ly-eval (string->symbol (string-append "chord::names-alist-" style-string))))) - (let loop ((note-names (reverse pitches)) - (chord '()) - (user-name #f)) - (if (pair? note-names) - (let ((entry (assoc - (reverse - (map (lambda (x) - (pitch->note-name (pitch::transpose x diff))) - note-names)) - names-alist))) - (if entry - ;; urg? found: break loop - (loop '() chord (cdr entry)) - (loop (cdr note-names) (cons (car note-names) chord) #f))) - (let* ((transposed (if pitches - (map (lambda (x) (pitch::transpose x diff)) chord) - '())) - (matched (if (= (length chord) 0) - 3 - (- (length pitches) (length chord)))) - (completed - (append (do ((i matched (- i 1)) - (base '() (cons `(0 ,(* (- i 1) 2) 0) base))) - ((= i 0) base) - ()) - transposed))) - (name-func (car pitches) user-name completed base-and-inversion)))))) - - +(define (chord::name-jazz tonic exception-part unmatched-steps + bass-and-inversion steps) + (let ((additions (chord::additions unmatched-steps)) + ;; get no 'omit' or 'no' + ;; (subtractions #f)) + (subtractions (chord::subtractions unmatched-steps))) + (chord::inner-name-jazz tonic exception-part additions subtractions + bass-and-inversion steps))) + +;; wip (set! chord::names-alist-jazz +(define amy-chord::names-alist-jazz + (append + '( + (((0 . 0) (2 . -1)) . ("m")) + ) + chord::names-alist-american)) diff --git a/stepmake/bin/package-diff.py b/stepmake/bin/package-diff.py index bc2c8a8eba..da16975bf0 100644 --- a/stepmake/bin/package-diff.py +++ b/stepmake/bin/package-diff.py @@ -6,11 +6,14 @@ import find +import fnmatch import sys import os +import re import string import getopt import pipes + topdir = '' def gulp_file(f): try: @@ -90,12 +93,14 @@ def remove_automatic (dirnames): cleanup () sys.exit (1) - dirs = map (lambda d: find.find ('out', d), dirnames) + dirs = map (lambda d: find.find ('out*', d), dirnames) dirs = reduce (lambda x,y: x + y, dirs) - print dirs + #print dirs + for d in dirs: - files = files + find.find ('*', d) + if os.path.isdir (d): + files = files + find.find ('*', d) for f in files: try: -- 2.39.5