From: Han-Wen Nienhuys Date: Tue, 23 Oct 2001 16:37:23 +0000 (+0200) Subject: release: 1.5.19 X-Git-Tag: release/1.5.19 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0817e0513d1016ff22a633b6fee20ddba2a062f2;p=lilypond.git release: 1.5.19 =========== * Moved python modules to ./python. * Better python module stepmake support. * Bugfix ly2dvi etc: LILYPONDPREFIX should override datadir. 1.5.18.h --- diff --git a/CHANGES b/CHANGES index ae84c1a5bb..e9710f65b3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,29 +1,40 @@ ---- ../lilypond-1.5.18/CHANGES Sat Oct 27 08:12:57 2001 -++ b/CHANGES Sat Oct 27 07:46:59 2001 -@@ -1,3 +1,12 @@ -1.5.18.moh1 +1.5.18.jcn1 =========== -* Further work on more flexible control of lyric alignment. - - new properties "alignment", "ignore-length-mismatch", "begin-alignment" and "end-alignment" to control non-centered lyric alignment +* Moved python modules to ./python. -1.5.18 -====== +* Better python module stepmake support. - 1.5.17.jcn6 - aka: `pgwit! Ah, dacht dat-i zo wel aardig was.' - =========== - 1.5.18.jcn1 +* Bugfix ly2dvi etc: LILYPONDPREFIX should override datadir. + +1.5.18.hwn2 =========== -* Moved python modules to ./python. +* Put lilylib back into ly2dvi -* Better python module stepmake support. +* Cache symbols for {get,set}_{grob,music}_property and +{get,set}_property. Speedup: about 20 percent. -* Bugfix ly2dvi etc: LILYPONDPREFIX should override datadir. +* Remove C++ version of midi2ly + +* Inline Grob::parent_l (Axis), String::String() speedup 2 % + +* First try at Sketch (sketch.sourceforge.net) output. + + +1.5.18.rz1 +========== + +* subdivideBeams fix - setting property right after beam definition no + longer affects that beam. + +* Minor docu updates, accidental cleanups and example updates + +* Added Accidental grob properties paren-cautionaries and + cautionary-size controlling the appearance of cautionary accidentals 1.5.18 ====== - 1.5.17.jcn6 - aka: `pgwit! Ah, dacht dat-i zo wel aardig was.' =========== diff --git a/Documentation/bibliography/computer-notation.bib b/Documentation/bibliography/computer-notation.bib index 00a3e9cd8d..c5a2505371 100644 --- a/Documentation/bibliography/computer-notation.bib +++ b/Documentation/bibliography/computer-notation.bib @@ -655,3 +655,19 @@ general rules, similar to\cite{parrish87-simultaneities}}, note = {Placement of accidentals crystallised in an enormous set of rules. Same remarks as for \cite{grover89-twovoices} applies} } + +@TechReport{, + author = {Michael Droettboom}, + title = {Study of music Notation Description Languages}, + year = {2000}, + OPTkey = {}, + OPTvolume = {}, + OPTnumber = {}, + OPTpages = {}, + OPTmonth = {}, + OPTnote = {}, + OPTannote = {} +html= {http://gigue.peabody.jhu.edu/~mdboom/format.pdf} +annote ={Author compares GUIDO and lilypond. LilyPond wins on practical issues as usability and availability of tools, GUIDO wins on implementation simplicity.} +} + diff --git a/GNUmakefile.in b/GNUmakefile.in index 2f578fcd5e..c6d7264a0c 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -8,10 +8,9 @@ depth = . # descent order into subdirectories # -SUBDIRS = buildscripts python scripts \ - flower lily \ +SUBDIRS = buildscripts scripts flower lily \ mf ly tex ps scm \ - midi2ly po make intl \ + modules python po make intl \ debian $(builddir)/stepmake \ Documentation input \ mutopia ports diff --git a/NEWS b/NEWS index bd0d47aa84..6dad565384 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ New features in 1.5 +* Many speedups + * Figured bass support * Improved grace notes diff --git a/VERSION b/VERSION index 8211834251..3403135ed7 100644 --- a/VERSION +++ b/VERSION @@ -1,8 +1,8 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 -PATCH_LEVEL=18 -MY_PATCH_LEVEL=moh1 +PATCH_LEVEL=19 +MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/buildscripts/gettext.py.in b/buildscripts/gettext.py.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/buildscripts/lilylib.py.in b/buildscripts/lilylib.py.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/debian/changelog b/debian/changelog index 37cfe0df1a..7329576d36 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,44 @@ +lilypond (1.4.8-1) unstable; urgency=high + + * New upstream release. (Closes: Bug#111132) + * Stopped using $(PWD) in make, as it doesn't seems to work on + potato systems with older "make". Reverted to `pwd`. + Thanks to Wolfgang Schnitker for notifying me this problem. + * Changed the lilypond1.3 dummy package's Architecture from "all" + to "arm i386 m68k powerpc sparc". Also, as upstream updated + config.sub and config.guess to recognize ia64 and hppa. + Thanks to Anthony Towns for the bug report. (Closes: Bug#114266) + * Versioned Build-Depends: flex (>= 2.5.4a-14) to ensure gcc-3.0 + compatibility. + + -- Anthony Fok Sun, 14 Oct 2001 18:28:45 +0800 + +lilypond (1.4.5-1) unstable; urgency=low + + * New upstream release. + * Upstream includes lexer-gcc-3.0.patch which should fix compilation + problems with g++-3.0. (Closes: Bug#105001) + * Hurray! texinfo-4.0b is finally in Debian! Thanks, Josip! :-) + Updated Build-Depends. + + -- Anthony Fok Wed, 25 Jul 2001 03:04:37 +0800 + +lilypond (1.4.3-1) unstable; urgency=high + + * New upstream release. + * Urgency high because Lilypond-1.2.17 is too buggy and yet it has + been stuck in testing forever. Lilypond-1.4.x fixes multiple + serious bugs. :-) + * Ah, silly me, lilypond was conflicting against itself! I forgot + to remove this relics during the switch from lilypond1.3 to lilypond. + * Fixed a new bug in lily/main.cc which caused lilypond to skip over every + other command-line argument. + * [configure.in]: Added -mieee to CFLAGS and CXXFLAGS when building on + Alpha to prevent FP exception. Thanks to Christopher C. Chimelis + for the fix! + + -- Anthony Fok Fri, 15 Jun 2001 00:42:46 -0600 + lilypond (1.4.2-1) unstable; urgency=low * New upstream release. diff --git a/debian/control b/debian/control index 7998422c27..c856770ec1 100644 --- a/debian/control +++ b/debian/control @@ -1,10 +1,10 @@ Source: lilypond -Build-Depends: debhelper (>= 3.0.5), python-base (>= 1.5.2-4), libguile-dev (>= 1:1.4-9), tetex-bin, libkpathsea-dev, tetex-extra, flex, bison, texinfo (>= 4.0-1), groff, m4, gettext (>= 0.10.36-1) +Build-Depends: debhelper (>= 3.0.5), python-base (>= 1.5.2-4), libguile-dev (>= 1:1.4-9), tetex-bin, libkpathsea-dev, tetex-extra, flex (>= 2.5.4a-14), bison, texinfo (>= 4.0b-2), groff, m4, gettext (>= 0.10.36-1) Build-Depends-Indep: bibtex2html, gs | gs-aladdin, netpbm (>= 2:9.10-1) Section: tex Priority: optional Maintainer: Anthony Fok -Standards-Version: 3.5.4 +Standards-Version: 3.5.5 Package: lilypond Architecture: any @@ -12,7 +12,7 @@ Replaces: lilypond1.3 Provides: lilypond1.3 Depends: ${shlibs:Depends}, tetex-bin (>= 1.0.5-1), python-base (>= 1.5.2-4), guile Recommends: lilypond-doc, tetex-extra (>= 1.0-1) -Conflicts: lilypond, lilypond1.3 (<= 1.3.132-1), musixtex-fonts +Conflicts: lilypond1.3 (<= 1.3.132-1), musixtex-fonts Description: A program for printing sheet music. LilyPond is a music typesetter. It produces beautiful sheet music using a high level description file as input. LilyPond is part of @@ -28,15 +28,14 @@ Description: A program for printing sheet music. Package: lilypond-doc Section: doc Architecture: all -Suggests: lilypond (>= 1.4.1-1) -Suggests: postscript-viewer, www-browser +Suggests: lilypond (>= 1.4.8-1), postscript-viewer, www-browser Description: LilyPond Documentation in HTML, PS and DVI formats This package contains the HTML, PostScript and DVI documentation for the LilyPond music typestting software. Package: lilypond1.3 -Architecture: all -Depends: lilypond (>= 1.3.150-1) +Architecture: arm i386 m68k powerpc sparc +Depends: lilypond (>= 1.4.8-1) Description: Dummy package for transition to new stable lilypond. This dummy package provides a transition from the previous lilypond1.3 package back to a newer lilypond because the stable 1.4 series has arrived. diff --git a/debian/control.foka b/debian/control.foka index 78f5b60f09..c856770ec1 100644 --- a/debian/control.foka +++ b/debian/control.foka @@ -1,10 +1,10 @@ Source: lilypond -Build-Depends: debhelper (>= 3.0.5), python-base (>= 1.5.2-4), libguile-dev (>= 1:1.4-9), tetex-bin, libkpathsea-dev, tetex-extra, flex, bison, texinfo (>= 4.0-1), groff, m4, gettext (>= 0.10.36-1) +Build-Depends: debhelper (>= 3.0.5), python-base (>= 1.5.2-4), libguile-dev (>= 1:1.4-9), tetex-bin, libkpathsea-dev, tetex-extra, flex (>= 2.5.4a-14), bison, texinfo (>= 4.0b-2), groff, m4, gettext (>= 0.10.36-1) Build-Depends-Indep: bibtex2html, gs | gs-aladdin, netpbm (>= 2:9.10-1) Section: tex Priority: optional Maintainer: Anthony Fok -Standards-Version: 3.5.4 +Standards-Version: 3.5.5 Package: lilypond Architecture: any @@ -12,7 +12,7 @@ Replaces: lilypond1.3 Provides: lilypond1.3 Depends: ${shlibs:Depends}, tetex-bin (>= 1.0.5-1), python-base (>= 1.5.2-4), guile Recommends: lilypond-doc, tetex-extra (>= 1.0-1) -Conflicts: lilypond, lilypond1.3 (<= 1.3.132-1), musixtex-fonts +Conflicts: lilypond1.3 (<= 1.3.132-1), musixtex-fonts Description: A program for printing sheet music. LilyPond is a music typesetter. It produces beautiful sheet music using a high level description file as input. LilyPond is part of @@ -28,15 +28,14 @@ Description: A program for printing sheet music. Package: lilypond-doc Section: doc Architecture: all -Suggests: lilypond (>= 1.4.1-1) -Suggests: postscript-viewer, www-browser -Description: LilyPond Documentation in HTML and PS formats - This package contains the HTML and PostScript documentation for the +Suggests: lilypond (>= 1.4.8-1), postscript-viewer, www-browser +Description: LilyPond Documentation in HTML, PS and DVI formats + This package contains the HTML, PostScript and DVI documentation for the LilyPond music typestting software. Package: lilypond1.3 -Architecture: all -Depends: lilypond (>= 1.3.150-1) +Architecture: arm i386 m68k powerpc sparc +Depends: lilypond (>= 1.4.8-1) Description: Dummy package for transition to new stable lilypond. This dummy package provides a transition from the previous lilypond1.3 package back to a newer lilypond because the stable 1.4 series has arrived. diff --git a/debian/control.potato b/debian/control.potato index 0a3ff854e5..c7bd20e761 100644 --- a/debian/control.potato +++ b/debian/control.potato @@ -12,7 +12,7 @@ Replaces: lilypond1.3 Provides: lilypond1.3 Depends: ${shlibs:Depends}, tetex-bin (>= 1.0.5-1), python-base (>= 1.5.2-4), guile Recommends: lilypond-doc, tetex-extra (>= 1.0-1) -Conflicts: lilypond, lilypond1.3 (<= 1.3.132-1), musixtex-fonts +Conflicts: lilypond1.3 (<= 1.3.132-1), musixtex-fonts Description: A program for printing sheet music. LilyPond is a music typesetter. It produces beautiful sheet music using a high level description file as input. LilyPond is part of @@ -28,18 +28,7 @@ Description: A program for printing sheet music. Package: lilypond-doc Section: doc Architecture: all -Suggests: lilypond (>= 1.4.1-1) -Suggests: postscript-viewer, www-browser +Suggests: lilypond (>= 1.4.8-1), postscript-viewer, www-browser Description: LilyPond Documentation in HTML, PS and DVI formats This package contains the HTML, PostScript and DVI documentation for the LilyPond music typestting software. - -Package: lilypond1.3 -Architecture: all -Depends: lilypond (>= 1.3.150-1) -Description: Dummy package for transition to new stable lilypond. - This dummy package provides a transition from the previous lilypond1.3 - package back to a newer lilypond because the stable 1.4 series has arrived. - . - Please feel free to remove this dummy package after you have upgraded - to the latest lilypond. diff --git a/debian/lilypond1.3.copyright b/debian/lilypond1.3.copyright index 0366d2af74..29e3390e68 100644 --- a/debian/lilypond1.3.copyright +++ b/debian/lilypond1.3.copyright @@ -3,27 +3,6 @@ This is a dummy package to aid the transition from the old It was created by Anthony Fok Mon, 16 Apr 2001 22:17:10 -0600 -Copyright: - - 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 with - the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL; - if not, write to the Free Software Foundation, Inc., 59 Temple Place, - Suite 330, Boston, MA 02111-1307 USA -This is a dummy package to aid the transition from the old -"lilypond1.3" package to the newer "lilypond" package. -It was created by Anthony Fok -Mon, 16 Apr 2001 22:17:10 -0600 - Copyright: This program is free software; you can redistribute it and/or modify diff --git a/debian/rules b/debian/rules index 15dbc650d6..d854c688eb 100755 --- a/debian/rules +++ b/debian/rules @@ -64,7 +64,6 @@ clean: # Still not clean enough? Let's use... BRUTE STRENGTH! :-) find . -type d -name 'out' -o -name 'out-www' | xargs rm -rf - rm -f debian/doc-base debian/TODO dh_clean diff --git a/flower/include/string.icc b/flower/include/string.icc index f53586f5b5..8ce2211a79 100644 --- a/flower/include/string.icc +++ b/flower/include/string.icc @@ -30,6 +30,12 @@ String::String () { } +INLINE +String::String (char const* source) +{ + assert (source); + strh_ = source; +} #endif /* STRING_ICC */ diff --git a/flower/string.cc b/flower/string.cc index 8ee89d0c5f..4659807f0c 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -62,11 +62,6 @@ String::operator = (String const&source) return *this; } -String::String (char const* source) -{ - assert (source); - strh_ = source; -} String::String (Byte const* byte_l, int length_i) { diff --git a/input/bugs/RondoAllaTurca.ly b/input/bugs/RondoAllaTurca.ly new file mode 100644 index 0000000000..2e0299e49d --- /dev/null +++ b/input/bugs/RondoAllaTurca.ly @@ -0,0 +1,225 @@ +\include "paper20.ly" +\version "1.4.7" +\header { + title = "Rondo Alla Turca" + subtitle = "Turkish March" + composer = "W. A. Mozart" + piece = "\\quad \\quad \\quad \\quad \\quad Allegretto" + mutopiatitle = "Rondo Alla Turca" + mutopiacomposer = "W. A. Mozart (1756-1791)" + mutopiainstrument = "Piano" + style = "classical" + copyright = "Public Domain" + maintainer = "Rune Zedeler" + maintainerEmail = "rz@daimi.au.dk" + lastupdated = "2001/sep/15" + tagline = "\\parbox{\hsize}{\\thefooter\\quad\\small \\\\This music is part of the Mutopia project, \\texttt{http://www.mutopiaproject.org/}\\\\It has been typeset and placed in the public domain by " + \maintainer + " (" + \maintainerEmail + ").\\\\Unrestricted modification and redistribution is permitted and encouraged---copy this music and share it!}" +} + +volta = "volta" + +\include "deutsch.ly"; + +#(define (remove-scripts music) + (let* ((es (ly-get-mus-property music 'elements)) + (e (ly-get-mus-property music 'element)) + (body (ly-get-mus-property music 'body)) + (alts (ly-get-mus-property music 'alternatives))) + + (if (pair? es) + (begin + (ly-set-mus-property + music 'elements + (map (lambda (x) (remove-scripts x)) es)) + (let recurse ((elts (ly-get-mus-property music 'elements))) + (if (and (pair? elts) (pair? (cdr elts))) + (let ((name (ly-music-name (cadr elts)))) + (if (or (equal? name "Articulation_req") (equal? name "Text_script_req")) + (begin + (set-cdr! elts (cddr elts)) + (recurse elts)) + (recurse (cdr elts)))))))) + + (if (music? alts) + (ly-set-mus-property + music 'alternatives + (remove-scripts alts))) + + (if (music? body) + (ly-set-mus-property + music 'body + (remove-scripts body))) + + (if (music? e) + (ly-set-mus-property + music 'element + (remove-scripts e))) + music)) + +righta = \notes \transpose c''' { + \scriptUp + \property Staff.Fingering \override #'direction = #1 + \partial 4 h,16-4-\p( a, gis, a,-1 | )c8-3 r d16-4( c h, c-1 | )e8-3 r f16-4( e dis e-1 | h-4 a gis a h a gis a | )c'4-\accent + a8-.-3 c'-.-5 | \grace {[g!32( )a]} h8-.-5-\sfz | \grace {[g32( )a]} h8-.-\sfz | \grace {[g32( )a]} h8-.-\sfz e4-- +} +rightaa = \notes \transpose c''' { + \partial 4 h,16-4-\p( a, gis, a,-1 | )c8-3 r d16-4( c h, c-1 | )e8-3 r f16-4( e dis e-1 | h-4 a gis a h \< a gis a | \! )c'4-\accent + a8-.-3 h-. | c'-.-\accent \> h-. a-.-1 \! gis-.-2 a-. e-. f-.-4 d-.-2 | c4-- h,8.-2-\trill( a,32 h, | )a,4-- +} + +rightb = \notes \transpose c''' { + [ ] | a16-4( g f )e | \stemUp \stemBoth + | a16-4( g f )e | + | f16-4( e d )c | \stemUp \stemBoth + | f16( e d )c | +} + +rightca = \notes \context Voice = voicea \relative c''' { a8-.-\f h-. | cis4-\accent a8-. h-. cis-.-\accent h-. a-. gis-. | fis-. gis-. a-. h-. gis-4( )e-. +a8-. h-. | cis4-\accent a8-. h cis-.-\accent h-. a-. gis-. | fis-. h-. gis-. e-. a4 +} +rightc = \notes < \apply #remove-scripts \rightca \transpose c \rightca > +rightco = \notes \relative c'' +{ \stemDown + a16-\f( a' h, h' | cis,-\accent )cis' r8 a,16( a' h, h' cis, cis' h, h' a, a' gis, )gis' | fis,( fis' gis, gis' a, a' h, h' gis, gis' e, )e' + a,16( a' h, h' | cis,-\accent )cis' r8 a,16( a' h, h' cis, cis' h, h' a, a' gis, )gis' | fis,( fis' h, h' gis, gis' e, e' +} +rightcoa = \notes \context Voice < )a'4 a'' > + +rightd = \notes \relative c''' { + cis16-3-\p( d cis h a h a gis-3 fis-2 a gis fis | eis fis gis eis cis-2 dis eis cis-1 | fis-4 eis-1 fis gis a gis a-1 h | cis his cis his + cis d cis )h | a( h a gis-3 fis a gis fis | e fis gis e cis-2 dis e cis | dis-3 e fis dis his-1 cis dis his | )cis4 +} +righte = \notes \relative c''' { + e,16-5(-\f d! cis h! | a h cis d-1 e fis gis a | )a-\accent-4( gis fis )e e-5( d cis h | )a-1( h cis d-1 e fis gis a ais8-\accent-3 )h-.-4 + e,16-5( d cis h | a h cis d-1 e fis gis a | )a-\accent-4( gis fis )e e-5( d cis h | cis-3 e a,-1 cis-4 h d gis,-2 h | )a4-- + cis'16-3-\p( d cis h a h a gis-3 fis-2 a gis fis | eis fis gis eis cis-2 dis eis )cis-1 | fis-4( \< eis-1 fis gis a gis a-1 \! h | cis his cis his + cis his cis ais-2 | )d-4( \> cis d cis d cis d cis | d cis h a gis-2 a h \! gis | a-\p h cis fis,-2 eis fis gis eis )fis4-- +} + +strum = \notes \transpose c' { < + \context Voice = strumUp {\stemUp cis'2-\arpeggio-\accent} + \context Voice = strumDown {\stemDown < cis4-\arpeggio e a> } +> +\stemBoth +} + +rightf = \notes \transpose c''' { + < {\stemUp cis'8. cis'16} \context Voice = another {\stemDown cis4} > + \strum \strum d'16-4( )cis'-. h-. cis'-. d'( )cis'-. h-. cis' + \repeat unfold 4 { \grace{d'8( } < )cis'8-. a e> } | < {\stemUp \slurUp h4.-3()e'8-. \stemBoth} \context Voice = another > + \strum \strum d'16-4( )cis'-. h-. cis'-. d'( )cis'-. h-. cis' \grace{d'8( } < )cis'2-. a e> + \repeat unfold 4 { \grace{cis'8( } < )h8-. gis e> } + + a4-\p-- \grace {[e32()a]} cis'8.-.-4 cis'16 \repeat unfold 2 { \grace {[e32()a]} cis'2-\accent } | + d'16-4( )cis'-. h-. cis'-. d'( )cis'-. h-. cis' | d'2-\accent | \repeat unfold 4 { \grace{d'8( } ) cis'8-. } h4.-2()e'8-. + <\strum s2-\f> \strum d'16-4( )cis'-. h-. cis'-. d'( )cis'-. h-. cis' \grace{d'8( } < )cis'2-. a e> + \repeat unfold 4 { \grace{cis'8( } < )h8-. gis e> } + + <) a,4-. cis e a-. > r4 +} + + +lefta = \notes { + \partial 4 r4 | a8-5( <)c' e'-.> | a8( <)c' e'-.> | a8-. a8-. | a8( <)c' e'-.> | + e-. | e-. | e-. h, h | e4-- +} +leftaa = \notes { \partial 4 + r4 | a8-5( <)c' e'-.> | a8( <)c' e'-.> | a8-. a8-. | f8( <)a dis'-.> | + e-. d!-. c-. d-. +} +leftb = \notes { \partial 4 + \repeat unfold 2 {r4 | c8-. c'-. e-. e'-. | g4 } + \repeat unfold 2 {r4 | a,8-. a-. c-. c'-. | e4 } +} + +stra = \notes { \grace {[a,32( cis )e]} a8-. a-. } +strd = \notes { \grace {[d,32( fis, )a,]} d8-. d-. } +strdis = \notes { \grace {[dis,32( fis, )a,]} dis8-. dis-. } +stre = \notes { \grace {[e,32( gis, )h,]} e8-. e-. } +stral = \notes { \stra a8-. a-. } +strdl = \notes { \strd d8-. d-. } +strel = \notes { \stre e8-. e-. } + +leftc = \notes { \partial 4 + r4 \stral \stral \strd \strdis \strel \stral \stral \strd \stre +} + +leftd = \notes \relative c { \partial 4 + r4 | fis8-5( <)a cis-.> | + gis8-4( <)h cis-.> | + fis8( <)a cis-.> | + eis8( <)gis cis-.> | + fis8( <)a cis-.> | + gis8( <)cis e-.> | + gis8( <)dis' fis-.> | + +} + +lefte = \notes \relative c' { \partial 4 + r4 | a8( <)cis e-.> | + h-. gis,-. | + a8( <)cis e-.> | + e,8( <)gis d'-.> | + a8( <)cis e-.> | + h-. gis,-. | + a-. fis-. d-. e-. a,-. a'-. r4 | + + fis8( <)a cis-.> | + gis8( <)h cis-.> | + fis8( <)a cis-.> | + cis,( <)gis' cis-.> | + h,8( <)fis' h-.> | + h,8( <)gis'! h-.> | + cis,-. cis-. +} + +leftf = \notes { + a8-. a8-. \stral \stral \stral \strdl \stral \strel \stral \stral \stral \strdl \stral \strel + a16( e' cis' e' a e' cis' )e' \repeat unfold 6 { a16 e' cis' e' } \repeat unfold 2 { a16 fis' d' fis' } \repeat unfold 2 { a16 e' cis' e' } \repeat unfold 2 { e16 e' gis e' } + \stral \stral \stral \strdl \stral \strel \stral \stral \stral \stra \stra a,4-. < )a, cis e a-. > r4 +} + +global = \notes {\time 2/4 } + +right = \notes { + \global \clef G \repeat \volta 2 \righta \repeat \volta 2 {\rightb \rightaa } \key a \major \repeat \volta 2 \rightc + \repeat \volta 2 \rightd \repeat \volta 2 \righte \repeat \volta 2 \rightc + \key a \minor \repeat \volta 2 \righta \repeat \volta 2 {\rightb \rightaa } \key a \major \repeat \volta 2 \rightco \alternative { \rightcoa {\partial 4 \rightcoa } } + \rightf \bar "|." +} + +left = \notes { + \global \clef F \repeat \volta 2 \lefta \repeat \volta 2 { \leftb \leftaa } \key a \major \repeat \volta 2 { \leftc a,4 } + \repeat \volta 2 \leftd \repeat \volta 2 \lefte \repeat \volta 2 { \leftc a,4 } + \key a \minor \repeat \volta 2 \lefta \repeat \volta 2 { \leftb \leftaa } \key a \major \repeat \volta 2 \leftc \alternative { a,4 {\partial 2 \stra} } + \leftf \bar "|." +} + + +\score { \notes + \context GrandStaff < + \property GrandStaff.connectArpeggios = ##t + \context Staff = up { + \right + } + \context Staff = down { + \property Staff.VoltaBracket = \turnOff + \left + } + > + \paper { + \translator { + \GraceContext + Slur \override #'direction = #-1 + } + \translator { + \ScoreContext + SpacingSpanner \override #'arithmetic-basicspace = #1.8 + GraceAlignment \override #'horizontal-space = #-0.4 + PaperColumn \override #'before-grace-spacing-factor = #1.0 + + } + interscoreline = 6.0 \pt + + } +} diff --git a/input/paddy.abc b/input/paddy.abc index 1492ea2089..0aadebc63c 100644 --- a/input/paddy.abc +++ b/input/paddy.abc @@ -1,47 +1,16 @@ -\header { - composer = "Trad." - crossRefNumber = "1" - footnotes = "" - tagline = "Lily was here (unknown version) -- automatically converted from ABC" - title = "Paddy O'Rafferty" -} -voicedefault = \notes { -\property Score.defaultBarType="empty" +% +% This is NOT a lilypond input file. It is an ABC file, see +% http://www.gre.ac.uk/~c.walshaw/abc/ +% +% LilyPond includes import tools for Finale, Musedata, ABC, MIDI and PMX +% +X:1 +T:Paddy O'Rafferty +C:Trad. +M:6/8 +K:D +dff cee|def gfe|dff cee|dfe dBA|dff cee|def gfe|faf gfe|1 dfe dBA:|2 dfe dcB|| +~A3 B3|gfe fdB|AFA B2c|dfe dcB|~A3 ~B3|efe efg|faf gfe|1 dfe dcB:|2 dfe dBA|| +fAA eAA|def gfe|fAA eAA|dfe dBA|fAA eAA|def gfe|faf gfe|dfe dBA:| -% This is NOT a lilypond input file. It is an ABC file, see - % http://www.gre.ac.uk/~c.walshaw/abc/ - % - % LilyPond includes import tools for Finale, Musedata, ABC, MIDI and PMX - \time 6/8 \key d \major d''8 fis''8 fis''8 cis''8 e''8 e''8 -\bar "|" d''8 e''8 fis''8 g''8 fis''8 e''8 \bar "|" d''8 -fis''8 fis''8 cis''8 e''8 e''8 \bar "|" d''8 fis''8 e''8 - d''8 b'8 a'8 \bar "|" d''8 fis''8 fis''8 cis''8 e''8 -e''8 \bar "|" d''8 e''8 fis''8 g''8 fis''8 e''8 \bar "|" -fis''8 a''8 fis''8 g''8 fis''8 e''8 \bar "|" d''8 fis''8 - e''8 d''8 b'8 a'8 \bar ":|" d''8 fis''8 e''8 d''8 -cis''8 b'8 \bar "||" a'4. ^"~" b'4. \bar "|" g''8 fis''8 -e''8 fis''8 d''8 b'8 \bar "|" a'8 fis'8 a'8 b'4 cis''8 -\bar "|" d''8 fis''8 e''8 d''8 cis''8 b'8 \bar "|" a'4. -^"~" b'4. ^"~" \bar "|" e''8 fis''8 e''8 e''8 fis''8 g''8 -\bar "|" fis''8 a''8 fis''8 g''8 fis''8 e''8 \bar "|" d''8 - fis''8 e''8 d''8 cis''8 b'8 \bar ":|" d''8 fis''8 e''8 - d''8 b'8 a'8 \bar "||" fis''8 a'8 a'8 e''8 a'8 a'8 -\bar "|" d''8 e''8 fis''8 g''8 fis''8 e''8 \bar "|" fis''8 - a'8 a'8 e''8 a'8 a'8 \bar "|" d''8 fis''8 e''8 d''8 - b'8 a'8 \bar "|" fis''8 a'8 a'8 e''8 a'8 a'8 \bar "|" -d''8 e''8 fis''8 g''8 fis''8 e''8 \bar "|" fis''8 a''8 -fis''8 g''8 fis''8 e''8 \bar "|" d''8 fis''8 e''8 d''8 -b'8 a'8 \bar ":|" -}\score{ - \notes < - \context Staff="default" - { - \voicedefault - } - - > - \paper { - } - \midi {} -} diff --git a/input/regression/lyric-align.ly b/input/regression/lyric-align.ly deleted file mode 100644 index a660e4ce7e..0000000000 --- a/input/regression/lyric-align.ly +++ /dev/null @@ -1,73 +0,0 @@ -\version "1.3.146" -\header{ - texidoc="Lyric alignment - - Lyric alignment is adjustable both interms of alignment between stanzas and on notehead. - - If the property alignment is not set, there is automatic determination of alignment type based on punctuation. (ee lyric-phrasing.ly) - -" -} - -%\paper { linewidth = -1. } -\score { - \addlyrics - \context Voice = "v" \notes \relative c'' { - \property Staff.automaticMelismata = ##t - \cadenzaOn - a\breve \bar "||" a1 \bar "|" a \bar "|" a \bar "||" \break a \bar "|" a \bar "|" a \bar "|" a \bar "||" \break a \bar "|" a \bar "|." - } - \context Lyrics < - \context LyricsVoice = "v-1" \lyrics { -% \property LyricsVoice . stanza = "1:" - \property Lyrics . LyricText \override #'ignore-length-mismatch = ##t - \property Lyrics . LyricText \override #'alignment = #-1 - \property Lyrics . LyricText \override #'begin-alignment = #8 - - "Particularly useful for reciting notes " - left - - \property Lyrics . LyricText \override #'alignment = #0 - - centered - - \property Lyrics . LyricText \override #'alignment = #1 - - right - - \property Lyrics . LyricText \override #'alignment = #-1 - \property Lyrics . LyricText \override #'begin-alignment = #2 - - left_half_way - - \property Lyrics . LyricText \override #'begin-alignment = #4 - - left_one_quarter - - \property Lyrics . LyricText \override #'begin-alignment = #10 - - left_one_tenth - - \property Lyrics . LyricText \override #'begin-alignment = #1 - - left_one_whole - - \property Lyrics . LyricText \override #'ignore-length-mismatch = ##f - \property Lyrics . LyricText \override #'begin-alignment = #4 - - Very_short_lyrics_remain_in_touch_with_their_note - - \property Lyrics . LyricText \override #'alignment = #1 - \property Lyrics . LyricText \override #'end-alignment = #1.1 - \property Lyrics . LyricText \override #'ignore-length-mismatch = ##t - - - Unless_ignore-length-mismatch_is_true - - } - \context LyricsVoice = "v-2" \lyrics { -% \property LyricsVoice . stanza = "2:" - " with many syllables under them." l c r l l l x x x note' true' - } - > -} diff --git a/input/regression/lyric_align.ly b/input/regression/lyric_align.ly new file mode 100644 index 0000000000..a660e4ce7e --- /dev/null +++ b/input/regression/lyric_align.ly @@ -0,0 +1,73 @@ +\version "1.3.146" +\header{ + texidoc="Lyric alignment + + Lyric alignment is adjustable both interms of alignment between stanzas and on notehead. + + If the property alignment is not set, there is automatic determination of alignment type based on punctuation. (ee lyric-phrasing.ly) + +" +} + +%\paper { linewidth = -1. } +\score { + \addlyrics + \context Voice = "v" \notes \relative c'' { + \property Staff.automaticMelismata = ##t + \cadenzaOn + a\breve \bar "||" a1 \bar "|" a \bar "|" a \bar "||" \break a \bar "|" a \bar "|" a \bar "|" a \bar "||" \break a \bar "|" a \bar "|." + } + \context Lyrics < + \context LyricsVoice = "v-1" \lyrics { +% \property LyricsVoice . stanza = "1:" + \property Lyrics . LyricText \override #'ignore-length-mismatch = ##t + \property Lyrics . LyricText \override #'alignment = #-1 + \property Lyrics . LyricText \override #'begin-alignment = #8 + + "Particularly useful for reciting notes " + left + + \property Lyrics . LyricText \override #'alignment = #0 + + centered + + \property Lyrics . LyricText \override #'alignment = #1 + + right + + \property Lyrics . LyricText \override #'alignment = #-1 + \property Lyrics . LyricText \override #'begin-alignment = #2 + + left_half_way + + \property Lyrics . LyricText \override #'begin-alignment = #4 + + left_one_quarter + + \property Lyrics . LyricText \override #'begin-alignment = #10 + + left_one_tenth + + \property Lyrics . LyricText \override #'begin-alignment = #1 + + left_one_whole + + \property Lyrics . LyricText \override #'ignore-length-mismatch = ##f + \property Lyrics . LyricText \override #'begin-alignment = #4 + + Very_short_lyrics_remain_in_touch_with_their_note + + \property Lyrics . LyricText \override #'alignment = #1 + \property Lyrics . LyricText \override #'end-alignment = #1.1 + \property Lyrics . LyricText \override #'ignore-length-mismatch = ##t + + + Unless_ignore-length-mismatch_is_true + + } + \context LyricsVoice = "v-2" \lyrics { +% \property LyricsVoice . stanza = "2:" + " with many syllables under them." l c r l l l x x x note' true' + } + > +} diff --git a/input/test/cautionaries.ly b/input/test/cautionaries.ly new file mode 100644 index 0000000000..e4f4161295 --- /dev/null +++ b/input/test/cautionaries.ly @@ -0,0 +1,15 @@ +\version "1.5.17" + +\score { \notes \context Staff \transpose c''' { + \key d \major + \property Staff.autoReminders = #'cautionary + \property Staff.Accidentals \override #'font-relative-size = #0 + cis2 d + \property Staff.Accidentals \override #'cautionary-size = #-1 + cis2 d + \property Staff.Accidentals \override #'paren-cautionaries = ##f + cis2 d + +} +} + diff --git a/input/test/drums.ly b/input/test/drums.ly index 93a0a9e700..f329913966 100644 --- a/input/test/drums.ly +++ b/input/test/drums.ly @@ -4,7 +4,7 @@ \include "drumpitch-init.ly" -\version "1.3.146" +\version "1.5.1" drh = \notes { cymc4.^"crash" hhc16^"h.h." hh \repeat "unfold" 5 {hhc8 hho hhc8 hh16 hh} hhc4 r4 r2 } drl = \notes {\repeat "unfold" 3 {bd4 sn8 bd bd4 } bd8 tommh tommh bd toml toml bd tomfh16 tomfh } diff --git a/input/test/music-box.ly b/input/test/music-box.ly index 2ff6c639e4..de0b47e9f0 100644 --- a/input/test/music-box.ly +++ b/input/test/music-box.ly @@ -22,6 +22,7 @@ using Scheme functions to save typing work. } \include "deutsch.ly" +\version "1.5.18" #(define (transform music) (let* ((es (ly-get-mus-property music 'elements)) @@ -48,25 +49,13 @@ using Scheme functions to save typing work. #(define ((trans pitches) music) (let* ((es (ly-get-mus-property music 'elements)) (e (ly-get-mus-property music 'element)) - (p (ly-get-mus-property music 'pitch)) - (body (ly-get-mus-property music 'body)) - (alts (ly-get-mus-property music 'alternatives))) + (p (ly-get-mus-property music 'pitch))) (if (pair? es) (ly-set-mus-property music 'elements (map (trans pitches) es))) - (if (music? alts) - (ly-set-mus-property - music 'alternatives - ((trans pitches) alts))) - - (if (music? body) - (ly-set-mus-property - music 'body - ((trans pitches) body))) - (if (music? e) (ly-set-mus-property music 'element diff --git a/input/test/smart-transpose.ly b/input/test/smart-transpose.ly index 24d70d3cb1..3674d81008 100644 --- a/input/test/smart-transpose.ly +++ b/input/test/smart-transpose.ly @@ -1,4 +1,4 @@ -\version "1.3.146" +\version "1.5.18" \header { texidoc=" @@ -42,25 +42,13 @@ how useful these enharmonic modifications are. Mats B. #(define (simplify music) (let* ((es (ly-get-mus-property music 'elements)) (e (ly-get-mus-property music 'element)) - (p (ly-get-mus-property music 'pitch)) - (body (ly-get-mus-property music 'body)) - (alts (ly-get-mus-property music 'alternatives))) + (p (ly-get-mus-property music 'pitch))) (if (pair? es) (ly-set-mus-property music 'elements (map (lambda (x) (simplify x)) es))) - (if (music? alts) - (ly-set-mus-property - music 'alternatives - (simplify alts))) - - (if (music? body) - (ly-set-mus-property - music 'body - (simplify body))) - (if (music? e) (ly-set-mus-property music 'element diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index e9daee13c3..cb87b5edb3 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -39,7 +39,6 @@ protected: virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); virtual void initialize (); - virtual int number_accidentals (SCM sig, Note_req *); virtual void create_grobs (); virtual void finalize (); public: @@ -74,17 +73,18 @@ Accidental_engraver::initialize () daddy_trans_l_->set_property ("lazyKeySignature", last_keysig_); } -/** calculates the number of accidentals on basis of the current local time sig +/** calculates the number of accidentals on basis of the current local key sig * (passed as argument). * Returns number of accidentals (0, 1 or 2). * Negative (-1 or -2) if accidental has changed. **/ -int -Accidental_engraver::number_accidentals (SCM sig, Note_req * note_l) +static int +number_accidentals (SCM sig, Note_req * note_l) { - int n = unsmob_pitch (note_l->get_mus_property ("pitch"))->notename_i_; - int o = unsmob_pitch (note_l->get_mus_property ("pitch"))->octave_i () ; - int a = unsmob_pitch (note_l->get_mus_property ("pitch"))->alteration_i_; + Pitch *pitch = unsmob_pitch (note_l->get_mus_property ("pitch")); + int n = pitch->notename_i_; + int o = pitch->octave_i () ; + int a = pitch->alteration_i_; SCM prev = scm_assoc (gh_cons (gh_int2scm (o), gh_int2scm (n)), sig); if (prev == SCM_BOOL_F) @@ -189,20 +189,21 @@ Accidental_engraver::create_grobs () always do the correct thing? (???? -Rune ) */ - int n = unsmob_pitch (note_l->get_mus_property ("pitch"))->notename_i_; - int o = unsmob_pitch (note_l->get_mus_property ("pitch"))->octave_i () ; - int a = unsmob_pitch (note_l->get_mus_property ("pitch"))->alteration_i_; - SCM ON = gh_cons (gh_int2scm (o), gh_int2scm (n)); + + Pitch *pitch = unsmob_pitch (note_l->get_mus_property ("pitch")); + int n = pitch->notename_i_; + int o = pitch->octave_i () ; + int a = pitch->alteration_i_; + SCM on = gh_cons (gh_int2scm (o), gh_int2scm (n)); bool forget = to_boolean (get_property ("forgetAccidentals")); if (tie_changes) { /* Remember an alteration that is different both from that of the tied note and of the key signature. - (????? -Rune ) */ - localsig = scm_assoc_set_x (localsig, ON, SCM_BOOL_T); - lazysig = scm_assoc_set_x (lazysig, ON, SCM_BOOL_T); + localsig = scm_assoc_set_x (localsig, on, SCM_BOOL_T); + lazysig = scm_assoc_set_x (lazysig, on, SCM_BOOL_T); } else if (!forget) { @@ -210,8 +211,8 @@ Accidental_engraver::create_grobs () not really really correct if there are more than one noteheads with the same notename. */ - localsig = scm_assoc_set_x (localsig, ON, gh_int2scm (a)); - lazysig = scm_assoc_set_x (lazysig, ON, gh_int2scm (a)); + localsig = scm_assoc_set_x (localsig, on, gh_int2scm (a)); + lazysig = scm_assoc_set_x (lazysig, on, gh_int2scm (a)); } } @@ -319,5 +320,5 @@ events. Due to interaction with ties (which don't come together with note heads), this needs to be in a context higher than Tie_engraver. FIXME", /* creats*/ "Accidentals", /* acks */ "rhythmic-head-interface tie-interface arpeggio-interface", -/* reads */ "localKeySignature forgetAccidentals noResetKey", +/* reads */ "localKeySignature forgetAccidentals noResetKey autoReminders", /* write */ ""); diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 2044f88500..8d13e857df 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -61,6 +61,8 @@ private: Moment extend_mom_; Moment beam_start_moment_; Moment beam_start_location_; + + bool subdivide_beams_; // We act as if beam were created, and start a grouping anyway. Beaming_info_list*grouping_p_; @@ -247,8 +249,7 @@ Auto_beam_engraver::begin_beam () grouping_p_ = new Beaming_info_list; beam_start_moment_ = now_mom (); beam_start_location_ = *unsmob_moment (get_property ("measurePosition")); - - + subdivide_beams_ = gh_scm2bool(get_property("subdivideBeams")); } @@ -292,7 +293,7 @@ Auto_beam_engraver::typeset_beam () if (finished_beam_p_) { finished_grouping_p_->beamify(*unsmob_moment (get_property ("beatLength")), - (bool)gh_scm2bool(get_property("subdivideBeams"))); + subdivide_beams_); Beam::set_beaming (finished_beam_p_, finished_grouping_p_); typeset_grob (finished_beam_p_); finished_beam_p_ = 0; @@ -480,5 +481,5 @@ stemRightBeamCount. ", /* creats*/ "Beam", /* acks */ "stem-interface rest-interface beam-interface bar-line-interface", -/* reads */ "noAutoBeaming autoBeamSettings", +/* reads */ "noAutoBeaming autoBeamSettings subdivideBeams", /* write */ ""); diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index b9e7eb63fe..e17a1e8e73 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -38,7 +38,9 @@ class Beam_engraver : public Engraver /// moment (global time) where beam started. Moment beam_start_mom_; - + + bool subdivide_beams_; + void typeset_beam (); void set_melisma (bool); protected: @@ -63,6 +65,7 @@ Beam_engraver::Beam_engraver () beam_info_p_ =0; reqs_drul_[LEFT] = reqs_drul_[RIGHT] =0; prev_start_req_ =0; + } bool @@ -182,7 +185,7 @@ Beam_engraver::typeset_beam () if (finished_beam_p_) { finished_beam_info_p_->beamify(*unsmob_moment (get_property ("beatLength")), - (bool)gh_scm2bool(get_property("subdivideBeams"))); + subdivide_beams_); Beam::set_beaming (finished_beam_p_, finished_beam_info_p_); typeset_grob (finished_beam_p_); @@ -204,6 +207,7 @@ Beam_engraver::start_translation_timestep () if (to_boolean (m) && to_boolean (b)) { set_melisma (true); } + subdivide_beams_ = gh_scm2bool(get_property("subdivideBeams")); } } @@ -292,5 +296,5 @@ ENTER_DESCRIPTION(Beam_engraver, printed with flags instead of beams.", /* creats*/ "Beam", /* acks */ "stem-interface rest-interface", -/* reads */ "beamMelismaBusy", +/* reads */ "beamMelismaBusy subdivideBeams", /* write */ ""); diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index b47d5b0358..8349ce5e63 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -152,8 +152,8 @@ Break_align_interface::do_alignment (Grob *me) symbol_list = ly_cdr (scm_reverse (symbol_list)); for (int i=0; i set_grob_property (ly_car (symbol_list), - scm_cons (gh_double2scm (0), + elems[i]->internal_set_grob_property (ly_car (symbol_list), + scm_cons (gh_double2scm (0), gh_double2scm (dists[i+1]))); symbol_list = ly_cdr (symbol_list); diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 8c0d543487..5595759236 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -48,8 +48,8 @@ Chord_name::brew_molecule (SCM smob) if (!gh_symbol_p (style)) style = ly_symbol2scm ("banter"); - SCM chord = me-> get_grob_property ("chord"); - SCM func = me->get_grob_property (ly_symbol2scm ("chord-name-function")); + SCM chord = me->get_grob_property ("chord"); + SCM func = me->get_grob_property ("chord-name-function"); SCM text = gh_call2 (func, style, chord); SCM properties = Font_interface::font_alist_chain (me); diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index a04db27dac..6a4646f6cd 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -98,8 +98,10 @@ Clef_engraver::create_clef () clef_p_ = c; } - Staff_symbol_referencer::set_position (clef_p_, - gh_scm2int (get_property ("clefPosition"))); + SCM cpos = get_property ("clefPosition"); + + if (gh_number_p (cpos)) + Staff_symbol_referencer::set_position (clef_p_, gh_scm2int (cpos)); SCM oct = get_property ("clefOctavation"); if (gh_number_p (oct) && gh_scm2int (oct)) diff --git a/lily/directional-element-interface.cc b/lily/directional-element-interface.cc index 7f986d51ee..ac2c40927d 100644 --- a/lily/directional-element-interface.cc +++ b/lily/directional-element-interface.cc @@ -10,27 +10,19 @@ #include "directional-element-interface.hh" -SCM Directional_element_interface::direction_sym; - -static void -init_functions () -{ - Directional_element_interface::direction_sym = scm_permanent_object (ly_symbol2scm ("direction")); -} -ADD_SCM_INIT_FUNC (Directional, init_functions); bool Directional_element_interface::has_interface (Grob*me) { - return isdir_b (me->get_grob_property (direction_sym)); + return isdir_b (me->get_grob_property ("direction")); } Direction Directional_element_interface::get (Grob*me) { // return dir_; - SCM d= me->get_grob_property (direction_sym); + SCM d= me->get_grob_property ("direction"); if (!isdir_b (d)) return CENTER; @@ -42,6 +34,6 @@ Directional_element_interface::set (Grob*me, Direction d) { SCM sd = gh_int2scm (d); - if (me->get_grob_property (direction_sym) != sd) - me->set_grob_property (direction_sym, sd); + if (me->get_grob_property ("direction") != sd) + me->set_grob_property ("direction", sd); } diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 32dd5b23a4..3241671974 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -253,8 +253,8 @@ Dynamic_engraver::process_music () cresc_p_->set_interface (ly_symbol2scm ("dynamic-interface")); cresc_p_->set_grob_property ("type", s); - daddy_trans_l_->set_property (start_type - + "Spanner", SCM_UNDEFINED); + daddy_trans_l_->set_property ((start_type + + "Spanner").ch_C(), SCM_UNDEFINED); s = get_property ((start_type + "Text").ch_C ()); /* FIXME: use markup_p () to check type. @@ -263,7 +263,7 @@ Dynamic_engraver::process_music () { cresc_p_->set_grob_property ("edge-text", gh_cons (s, ly_str02scm (""))); - daddy_trans_l_->set_property (start_type + "Text", + daddy_trans_l_->set_property ((start_type + "Text").ch_C(), SCM_UNDEFINED); } } diff --git a/lily/engraver-group-engraver.cc b/lily/engraver-group-engraver.cc index 8dd6e1a4ce..c0cc4eb51d 100644 --- a/lily/engraver-group-engraver.cc +++ b/lily/engraver-group-engraver.cc @@ -41,7 +41,7 @@ Engraver_group_engraver::acknowledge_grobs () if (!announce_info_arr_.size ()) return ; - SCM tab =get_property (ly_symbol2scm ("acknowledgeHashTable")); + SCM tab = get_property ("acknowledgeHashTable"); SCM name_sym = ly_symbol2scm ("name"); SCM meta_sym = ly_symbol2scm ("meta"); @@ -50,7 +50,7 @@ Engraver_group_engraver::acknowledge_grobs () { Grob_info info = announce_info_arr_[j]; - SCM meta = info.grob_l_->get_grob_property (meta_sym); + SCM meta = info.grob_l_->internal_get_grob_property (meta_sym); SCM nm = scm_assoc (name_sym, meta); if (gh_pair_p (nm)) nm = ly_cdr (nm); @@ -135,7 +135,7 @@ void Engraver_group_engraver::initialize () { SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F); // magic -> - set_property (ly_symbol2scm ("acknowledgeHashTable"), tab); + set_property ("acknowledgeHashTable", tab); Translator_group::initialize (); } diff --git a/lily/global-translator.cc b/lily/global-translator.cc index 4e4208bd82..7ca91a5ad3 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -104,7 +104,7 @@ Global_translator::run_iterator_on_me (Music_iterator * iter) if (first) { first = false; - set_property (ly_symbol2scm ("measurePosition"), w.smobbed_copy ()); + set_property ("measurePosition", w.smobbed_copy ()); } prepare (w); diff --git a/lily/grob.cc b/lily/grob.cc index bd716106db..3f35eb86b8 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -122,14 +122,7 @@ Grob::~Grob () SCM -Grob::get_grob_property (const char *nm) const -{ - SCM sym = ly_symbol2scm (nm); - return get_grob_property (sym); -} - -SCM -Grob::get_grob_property (SCM sym) const +Grob::internal_get_grob_property (SCM sym) const { SCM s = scm_sloppy_assq (sym, mutable_property_alist_); if (s != SCM_BOOL_F) @@ -153,13 +146,8 @@ Grob::remove_grob_property (const char* key) return val; } -void -Grob::set_grob_property (const char* k, SCM v) -{ - SCM s = ly_symbol2scm (k); - set_grob_property (s, v); -} +#if 0 /* Puts the k, v in the immutable_property_alist_, which is convenient for storing variables that are needed during the breaking process. (eg. @@ -178,8 +166,11 @@ Grob::set_immutable_grob_property (SCM s, SCM v) immutable_property_alist_ = gh_cons (gh_cons (s,v), mutable_property_alist_); mutable_property_alist_ = scm_assq_remove_x (mutable_property_alist_, s); } +#endif + + void -Grob::set_grob_property (SCM s, SCM v) +Grob::internal_set_grob_property (SCM s, SCM v) { mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v); } @@ -640,13 +631,6 @@ Grob::extent (Grob * refp, Axis a) const return ext; } - -Grob* -Grob::parent_l (Axis a) const -{ - return dim_cache_[a].parent_l_; -} - Grob * Grob::common_refpoint (Grob const* s, Axis a) const { @@ -786,15 +770,14 @@ Grob::mark_smob (SCM ses) { scm_gc_mark (s->dim_cache_[a].offset_callbacks_); scm_gc_mark (s->dim_cache_[a].dimension_); + Grob *p = s->parent_l (Y_AXIS); + if (p) + scm_gc_mark (p->self_scm ()); } - if (s->parent_l (Y_AXIS)) - scm_gc_mark (s->parent_l (Y_AXIS)->self_scm ()); - if (s->parent_l (X_AXIS)) - scm_gc_mark (s->parent_l (X_AXIS)->self_scm ()); - if (s->original_l_) scm_gc_mark (s->original_l_->self_scm ()); + return s->do_derived_mark (); } @@ -834,7 +817,7 @@ ly_set_grob_property (SCM elt, SCM sym, SCM val) if (sc) { - sc->set_grob_property (sym, val); + sc->internal_set_grob_property (sym, val); } else { @@ -853,7 +836,7 @@ ly_get_grob_property (SCM elt, SCM sym) if (sc) { - return sc->get_grob_property (sym); + return sc->internal_get_grob_property (sym); } else { @@ -879,12 +862,10 @@ spanner_get_bound (SCM slur, SCM dir) -static SCM interfaces_sym; + static void init_functions () { - interfaces_sym = scm_permanent_object (ly_symbol2scm ("interfaces")); - scm_c_define_gsubr ("ly-get-grob-property", 2, 0, 0, (Scheme_function_unknown)ly_get_grob_property); scm_c_define_gsubr ("ly-set-grob-property", 3, 0, 0, @@ -896,7 +877,7 @@ init_functions () bool Grob::has_interface (SCM k) { - SCM ifs = get_grob_property (interfaces_sym); + SCM ifs = get_grob_property ("interfaces"); return scm_memq (k, ifs) != SCM_BOOL_F; } @@ -908,8 +889,8 @@ Grob::set_interface (SCM k) return ; else { - set_grob_property (interfaces_sym, - gh_cons (k, get_grob_property (interfaces_sym))); + set_grob_property ("interfaces", + gh_cons (k, get_grob_property ("interfaces"))); } } diff --git a/lily/include/directional-element-interface.hh b/lily/include/directional-element-interface.hh index 81685e377a..233e3d9e44 100644 --- a/lily/include/directional-element-interface.hh +++ b/lily/include/directional-element-interface.hh @@ -15,7 +15,7 @@ struct Directional_element_interface { public: - static SCM direction_sym ; + static void set (Grob*,Direction d); static Direction get (Grob*) ; static bool has_interface (Grob*) ; diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 0cabf6e0e1..e9665ea31b 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -28,6 +28,10 @@ enum Grob_status { typedef void (Grob::*Grob_method_pointer) (void); + +#define get_grob_property(x) internal_get_grob_property(ly_symbol2scm(x)) +#define set_grob_property(x,y) internal_set_grob_property(ly_symbol2scm(x),y) + /* Basic output object. */ @@ -62,12 +66,14 @@ public: /* properties */ - SCM get_grob_property (const char*) const; - SCM get_grob_property (SCM) const; - void set_grob_property (const char * , SCM val); + SCM internal_get_grob_property (SCM) const; + void internal_set_grob_property (SCM, SCM val); + +#if 0 void set_immutable_grob_property (const char * , SCM val); - void set_immutable_grob_property (SCM key, SCM val); - void set_grob_property (SCM , SCM val); + void set_immutable_grob_property (SCM key, SCM val); +#endif + void set_elt_pointer (const char*, SCM val); friend class Property_engraver; // UGHUGHUGH. SCM remove_grob_property (const char* nm); @@ -170,7 +176,7 @@ public: */ void set_parent (Grob* e, Axis); - Grob *parent_l (Axis a) const; + Grob *parent_l (Axis a) const { return dim_cache_[a].parent_l_; } DECLARE_SCHEME_CALLBACK (fixup_refpoint, (SCM)); }; diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh index e2303633dc..7a07bccd6d 100644 --- a/lily/include/group-interface.hh +++ b/lily/include/group-interface.hh @@ -13,8 +13,8 @@ #include "lily-proto.hh" #include "string.hh" #include "lily-guile.hh" -#include "smobs.hh" +#include "grob.hh" /** Look at Score element ELT as thing which has a list property called NAME_. Normally the list would contain Grobs, but diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 54c9decd29..e67293e06f 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -9,6 +9,8 @@ #ifndef LILY_GUILE_HH #define LILY_GUILE_HH +#define SCM_VOIDP_TEST + #include /* @@ -89,6 +91,8 @@ SCM ly_truncate_list (int k, SCM l ); #define CACHE_SYMBOLS #ifdef CACHE_SYMBOLS +SCM my_gh_symbol2scm (const char* x); + // #warning: CACHE_SYMBOLS /* @@ -102,10 +106,11 @@ SCM ly_truncate_list (int k, SCM l ); */ #define ly_symbol2scm(x) ({ static SCM cached; \ SCM value = cached; /* We store this one locally, since G++ -O2 fucks up else */ \ - if (__builtin_constant_p (x))\ - value = cached = scm_permanent_object (gh_symbol2scm((char*)x));\ - else\ - value = gh_symbol2scm ((char*)x); \ + if ( __builtin_constant_p ((x)))\ + { if (!cached)\ + value = cached = scm_gc_protect_object (my_gh_symbol2scm((char*) (x)));\ + } else\ + value = gh_symbol2scm ((char*) (x)); \ value; }) #else inline SCM ly_symbol2scm(char const* x) { return gh_symbol2scm((char*)x); } diff --git a/lily/include/music.hh b/lily/include/music.hh index 500eb003dc..d89c24f70e 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -19,6 +19,9 @@ #include "music-constructor.hh" +#define get_mus_property(x) internal_get_mus_property(ly_symbol2scm(x)) +#define set_mus_property(x,y) internal_set_mus_property(ly_symbol2scm (x), y) + /** Music is anything that has duration and supports both time compression and transposition. @@ -36,15 +39,16 @@ class Music { public: Input *origin () const; void set_spot (Input); - - SCM get_mus_property (const char*) const; - SCM get_mus_property (SCM) const; - void set_mus_property (const char * , SCM val); + + SCM internal_get_mus_property (SCM) const; + void internal_set_mus_property (SCM , SCM val); +#if 0 void set_immutable_mus_property (const char * , SCM val); - void set_immutable_mus_property (SCM key, SCM val); - void set_mus_property (SCM , SCM val); - void set_mus_pointer (const char*, SCM val); + void set_immutable_mus_property (SCM key, SCM val); + SCM remove_mus_property (const char* nm); +#endif + virtual Pitch to_relative_octave (Pitch); diff --git a/lily/include/protected-scm.hh b/lily/include/protected-scm.hh index 10ba29c8e8..7a13b24b1f 100644 --- a/lily/include/protected-scm.hh +++ b/lily/include/protected-scm.hh @@ -10,7 +10,8 @@ #ifndef PROTECTED_SCM_HH #define PROTECTED_SCM_HH -#include + +#include "lily-guile.hh" /* Mix GUILE GC with C++ ctors and dtors. diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 1e61749356..50a713be69 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -19,6 +19,7 @@ // egcs typedef void (Translator::*Method_pointer) (void); +#define set_property(x,y) internal_set_property(ly_symbol2scm(x),y) class Scheme_hash_table; @@ -37,10 +38,10 @@ protected: public: SCM add_translator (SCM, Translator*); void execute_single_pushpop_property (SCM prop, SCM sym, SCM val); - SCM get_property (SCM name_sym) const; - void set_property (String var_name, SCM value); + SCM internal_get_property (SCM name_sym) const; + void unset_property (SCM var_sym); - void set_property (SCM var_sym, SCM value); + void internal_set_property (SCM var_sym, SCM value); Translator_group *where_defined (SCM name_sym) const; String id_str_; diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 6c1ff11327..1e1109d99c 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -19,6 +19,9 @@ #include "input.hh" #include "smobs.hh" +#define get_property(x) internal_get_property(ly_symbol2scm(x)) + + #define TRANSLATOR_DECLARATIONS(NAME) \ public: \ NAME();\ @@ -53,8 +56,7 @@ public: */ Music_output_def *output_def_l () const; - SCM get_property (const char *) const; - SCM get_property (SCM symbol) const; + SCM internal_get_property (SCM symbol) const; virtual Moment now_mom () const; diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 77c3ce5506..ccca4cee06 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -542,3 +542,8 @@ ly_truncate_list (int k, SCM l ) } return l; } + +SCM my_gh_symbol2scm (const char* x) +{ + return gh_symbol2scm (x); +} diff --git a/lily/line-group-group-engraver.cc b/lily/line-group-group-engraver.cc index 14f55b6742..a324aef2d8 100644 --- a/lily/line-group-group-engraver.cc +++ b/lily/line-group-group-engraver.cc @@ -35,7 +35,7 @@ Line_group_engraver_group::finalize () { Engraver_group_engraver::finalize (); Grob * it - = unsmob_grob (get_property (ly_symbol2scm ("currentCommandColumn"))); + = unsmob_grob (get_property ("currentCommandColumn")); staffline_p_->set_bound (RIGHT,it); Engraver_group_engraver::typeset_grob (staffline_p_); @@ -47,7 +47,7 @@ Line_group_engraver_group::initialize () { create_line_spanner (); Grob * it - = unsmob_grob (get_property (ly_symbol2scm ("currentCommandColumn"))); + = unsmob_grob (get_property ("currentCommandColumn")); staffline_p_->set_bound (LEFT,it); Engraver::announce_grob (staffline_p_,0); diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index 1ffc2c696c..52e7a65f77 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -171,8 +171,20 @@ Local_key_item::brew_molecule (SCM smob) oct_b = true; } + lastoct = p.octave_i () ; + bool cautionary = (scm_memq (ly_symbol2scm ("cautionary"), opts) != SCM_BOOL_F); + SCM font_rel_siz = me->get_grob_property("font-relative-size"); + SCM caut_siz = me->get_grob_property("cautionary-size"); + int frs = (gh_exact_p(font_rel_siz) ? gh_scm2int(font_rel_siz) : 0); + int cs = (gh_exact_p(caut_siz) ? gh_scm2int(caut_siz) : 0); + + + // Ugh. This will only work if only called once on each grob. --rz + if (cautionary && caut_siz!=0) + me->set_grob_property ("font-relative-size",gh_int2scm(frs+cs)); + SCM c0 = me->get_grob_property ("c0-position"); Real dy = (gh_number_p (c0) ? gh_scm2int (c0) : 0 + p.notename_i_) * note_distance; @@ -189,8 +201,8 @@ Local_key_item::brew_molecule (SCM smob) acc.add_at_edge (X_AXIS, LEFT, Molecule (prefix), 0); } - if (scm_memq (ly_symbol2scm ("cautionary"), opts) != SCM_BOOL_F) - acc = parenthesize (me, acc); + if (cautionary && to_boolean(me->get_grob_property("paren-cautionaries"))) + acc = parenthesize (me, acc); acc.translate_axis (dy, Y_AXIS); octave_mol.add_at_edge (X_AXIS, RIGHT, acc, 0); diff --git a/lily/music.cc b/lily/music.cc index d3f5cdb4a8..178a602aa7 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -142,14 +142,7 @@ IMPLEMENT_DEFAULT_EQUAL_P (Music); /****************************/ SCM -Music::get_mus_property (const char *nm) const -{ - SCM sym = ly_symbol2scm (nm); - return get_mus_property (sym); -} - -SCM -Music::get_mus_property (SCM sym) const +Music::internal_get_mus_property (SCM sym) const { SCM s = scm_sloppy_assq (sym, mutable_property_alist_); if (s != SCM_BOOL_F) @@ -159,6 +152,7 @@ Music::get_mus_property (SCM sym) const return (s == SCM_BOOL_F) ? SCM_EOL : ly_cdr (s); } +#if 0 /* Remove the value associated with KEY, and return it. The result is that a next call will yield SCM_EOL (and not the underlying @@ -173,18 +167,18 @@ Music::remove_mus_property (const char* key) return val; } -void -Music::set_mus_property (const char* k, SCM v) +SCM +Music::get_mus_property (const char *nm) const { - SCM s = ly_symbol2scm (k); - set_mus_property (s, v); + SCM sym = ly_symbol2scm (nm); + return get_mus_property (sym); } void -Music::set_immutable_mus_property (const char*k, SCM v) +Music::set_mus_property (const char* k, SCM v) { SCM s = ly_symbol2scm (k); - set_immutable_mus_property (s, v); + set_mus_property (s, v); } void @@ -193,8 +187,10 @@ Music::set_immutable_mus_property (SCM s, SCM v) immutable_property_alist_ = gh_cons (gh_cons (s,v), mutable_property_alist_); mutable_property_alist_ = scm_assq_remove_x (mutable_property_alist_, s); } +#endif + void -Music::set_mus_property (SCM s, SCM v) +Music::internal_set_mus_property (SCM s, SCM v) { mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v); } @@ -232,7 +228,7 @@ ly_get_mus_property (SCM mus, SCM sym) if (sc) { - return sc->get_mus_property (sym); + return sc->internal_get_mus_property (sym); } else { @@ -258,7 +254,7 @@ ly_set_mus_property (SCM mus, SCM sym, SCM val) if (sc) { - sc->set_mus_property (sym, val); + sc->internal_set_mus_property (sym, val); } else { diff --git a/lily/note-head.cc b/lily/note-head.cc index bda7f38c2d..b58c23cf20 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -98,12 +98,14 @@ Note_head::brew_molecule (SCM smob) UGH: use grob-property. */ - Molecule out = Font_interface::get_default_font (me)->find_by_name (String ("noteheads-") + - ly_scm2string (scm_primitive_eval (scm_list_n (ly_symbol2scm ("find-notehead-symbol"), - me->get_grob_property ("duration-log"), - ly_quote_scm (style), - SCM_UNDEFINED)))); + SCM log = me->get_grob_property ("duration-log"); + SCM exp = scm_list_n (ly_symbol2scm ("find-notehead-symbol"), log, + ly_quote_scm (style), + SCM_UNDEFINED); + String name = "noteheads-" + ly_scm2string (scm_primitive_eval (exp)); + Molecule out = Font_interface::get_default_font (me)->find_by_name (name); + if (streepjes_i) { Direction dir = (Direction)sign (p); diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 527b0c103a..e852d666fa 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -65,7 +65,7 @@ Output_property_engraver::acknowledge_grob (Grob_info inf) { SCM sym = o->get_mus_property ("grob-property"); SCM val = o->get_mus_property ("grob-value"); - inf.grob_l_->set_grob_property (sym, val); + inf.grob_l_->internal_set_grob_property (sym, val); } } } diff --git a/lily/parser.yy b/lily/parser.yy index 27e3e1cdec..f5425dc2ef 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -101,7 +101,7 @@ set_music_properties (Music *p, SCM a) { for (SCM k = a; gh_pair_p (k); k = ly_cdr (k)) { - p->set_mus_property (ly_caar (k), ly_cdar (k)); + p->internal_set_mus_property (ly_caar (k), ly_cdar (k)); } } diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index bd18cb347b..16098a4cbe 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -148,7 +148,7 @@ Part_combine_music_iterator::get_state (Moment) Translator_group *first_translator = first_iter_p_->report_to_l ()->find_create_translator_l (w, "one" + suffix_); - SCM s = first_translator->get_property (ly_symbol2scm ("changeMoment")); + SCM s = first_translator->get_property ("changeMoment"); if (!gh_pair_p (s)) return state; @@ -277,7 +277,7 @@ Part_combine_music_iterator::get_state (Moment) if (gh_number_p (interval)) { - SCM s = first_translator->get_property (ly_symbol2scm ("splitInterval")); + SCM s = first_translator->get_property ("splitInterval"); int i = gh_scm2int (interval); if (gh_pair_p (s) && gh_number_p (ly_car (s)) diff --git a/lily/property-engraver.cc b/lily/property-engraver.cc index 775da363b4..25ca3af774 100644 --- a/lily/property-engraver.cc +++ b/lily/property-engraver.cc @@ -58,7 +58,7 @@ Property_engraver::initialize () { prop_dict_ = new Scheme_hash_table; - SCM plist = get_property (ly_symbol2scm ("Generic_property_list")); + SCM plist = get_property ("Generic_property_list"); for (; gh_pair_p (plist); plist = ly_cdr (plist)) { SCM elt_props = ly_car (plist); @@ -106,14 +106,14 @@ Property_engraver::apply_properties (SCM p, Grob *e, Translator_group*origin) if (preset != SCM_BOOL_F) continue; - SCM val = get_property (prop_sym); + SCM val = internal_get_property (prop_sym); if (val == SCM_EOL) ; // Not defined in context. else if (gh_apply (type_p, scm_list_n (val, SCM_UNDEFINED)) == SCM_BOOL_T) // defined and right type: do it { - e->set_grob_property (elt_prop_sym, val); + e->internal_set_grob_property (elt_prop_sym, val); SCM meta = e->get_grob_property ("meta"); SCM name = scm_assoc (ly_symbol2scm ("name"), meta); diff --git a/lily/property-iterator.cc b/lily/property-iterator.cc index cea57f3dc3..9589804ecf 100644 --- a/lily/property-iterator.cc +++ b/lily/property-iterator.cc @@ -26,7 +26,7 @@ Property_iterator::process (Moment m) if (val != SCM_EOL) ok = type_check_assignment (val, sym, ly_symbol2scm ("translation-type?")); if (ok) - report_to_l ()->set_property (sym, val); + report_to_l ()->internal_set_property (sym, val); } Simple_music_iterator::process (m); } diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 814bd4d448..9189ee71eb 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -40,8 +40,8 @@ Score_engraver::make_columns () if (!command_column_l_) // || *unsmob_moment (command_column_l_->get_grob_property ("when")) != w) { - set_columns (new Paper_column (get_property (ly_symbol2scm ("NonMusicalPaperColumn"))), - new Paper_column (get_property (ly_symbol2scm ("PaperColumn")))); + set_columns (new Paper_column (get_property ("NonMusicalPaperColumn")), + new Paper_column (get_property ("PaperColumn"))); command_column_l_->set_grob_property ("breakable", SCM_BOOL_T); @@ -87,7 +87,7 @@ Score_engraver::initialize () pscore_p_ = new Paper_score; pscore_p_->paper_l_ = dynamic_cast (output_def_l_); - SCM props = get_property (ly_symbol2scm ("LineOfScore")); + SCM props = get_property ("LineOfScore"); pscore_p_->typeset_line (new Line_of_score (props)); @@ -106,7 +106,7 @@ Score_engraver::finalize () Engraver_group_engraver::finalize (); Grob * cc - = unsmob_grob (get_property (ly_symbol2scm ("currentCommandColumn"))); + = unsmob_grob (get_property ("currentCommandColumn")); scoreline_l_->set_bound (RIGHT, cc); cc->set_grob_property ("breakable", SCM_BOOL_T); @@ -116,7 +116,7 @@ Score_engraver::finalize () void Score_engraver::one_time_step () { - if (!to_boolean (get_property (ly_symbol2scm("skipTypesetting")))) + if (!to_boolean (get_property ("skipTypesetting"))) { process_music (); announces (); diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 66b317e5b1..43fc872e2f 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -73,9 +73,9 @@ Span_bar_engraver::stop_translation_timestep () Span_bar::add_bar (spanbar_p_,bar_l_arr_[i]); SCM vissym =ly_symbol2scm ("visibility-lambda"); - SCM vis = bar_l_arr_[0]->get_grob_property (vissym); - if (scm_equal_p (spanbar_p_->get_grob_property (vissym), vis) != SCM_BOOL_T) - spanbar_p_->set_grob_property (vissym, vis); + SCM vis = bar_l_arr_[0]->internal_get_grob_property (vissym); + if (scm_equal_p (spanbar_p_->internal_get_grob_property (vissym), vis) != SCM_BOOL_T) + spanbar_p_->internal_set_grob_property (vissym, vis); typeset_grob (spanbar_p_); spanbar_p_ =0; diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 1700d181fc..0e5d6e2f7b 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -63,7 +63,7 @@ Span_bar::brew_molecule (SCM smobbed_me) } Span_bar::evaluate_glyph(me); - SCM glyph = me->get_grob_property (ly_symbol2scm ("glyph")); + SCM glyph = me->get_grob_property ("glyph"); /* glyph may not be a string, when ME is killed by Hara Kiri in @@ -182,7 +182,7 @@ Span_bar::evaluate_glyph (Grob*me) while (gh_pair_p (elts)) { - gl = unsmob_grob (gh_car (elts))->get_grob_property (glyph_symbol); + gl = unsmob_grob (gh_car (elts))->internal_get_grob_property (glyph_symbol); if (gh_string_p (gl)) break; elts =gh_cdr (elts); @@ -209,8 +209,8 @@ Span_bar::evaluate_glyph (Grob*me) } gl = ly_str02scm (type.ch_C ()); - if (scm_equal_p (me->get_grob_property (glyph_symbol), gl) != SCM_BOOL_T) - me->set_grob_property (glyph_symbol, gl); + if (scm_equal_p (me->internal_get_grob_property (glyph_symbol), gl) != SCM_BOOL_T) + me->internal_set_grob_property (glyph_symbol, gl); } Interval diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 24418337d1..a0ff443430 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -126,10 +126,10 @@ String Staff_performer::new_instrument_str () { // mustn't ask Score for instrument: it will return piano! - SCM minstr = get_property (ly_symbol2scm ("midiInstrument")); + SCM minstr = get_property ("midiInstrument"); if (!gh_string_p (minstr)) - minstr = get_property (ly_symbol2scm ("instrument")); + minstr = get_property ("instrument"); if (!gh_string_p (minstr) || ly_scm2string (minstr) == instrument_str_) diff --git a/lily/syllable-group.cc b/lily/syllable-group.cc index 65aa936a37..84a3f7fa48 100644 --- a/lily/syllable-group.cc +++ b/lily/syllable-group.cc @@ -131,7 +131,7 @@ Syllable_group::set_lyric_align (const char *punc, Grob *default_notehead_l) /** determine the distance to translate lyrics to get correct alignment Rules: If alignment is centre, translate = 0 Otherwise, - If (length of longest lyric) < (property {begin,end}-alignment) * (length of shortest lyric), + If (length of longest lyric) < property("end-alignment") * (length of shortest lyric), - centre longest lyric on notehead Otherwise - move so shortest lyric just reaches notehead centre @@ -141,20 +141,11 @@ Syllable_group::amount_to_translate () { Real translate = 0.0; if (alignment_i_ != CENTER) { - switch (alignment_i_) { - // FIXME: do we really know the lyric extent here? Some font sizing comes later? - case LEFT: - translate = longest_lyric_l_->extent (longest_lyric_l_, X_AXIS).length () / gh_scm2double (longest_lyric_l_->get_grob_property("begin-alignment")); - break; - case RIGHT: - translate = longest_lyric_l_->extent (longest_lyric_l_, X_AXIS).length () / gh_scm2double (longest_lyric_l_->get_grob_property("end-alignment")); - break; - } - if (!gh_scm2bool(longest_lyric_l_->get_grob_property("ignore-length-mismatch"))) { - Real l = shortest_lyric_l_->extent (shortest_lyric_l_, X_AXIS).length (); - translate = l extent (longest_lyric_l_, X_AXIS).length () / gh_scm2double (longest_lyric_l_->get_grob_property("end-alignment")); + Real l2 = shortest_lyric_l_->extent (shortest_lyric_l_, X_AXIS).length (); + + translate = l1 set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); diff --git a/lily/translator-def.cc b/lily/translator-def.cc index 200e0513cc..9c8ffb0d3a 100644 --- a/lily/translator-def.cc +++ b/lily/translator-def.cc @@ -277,7 +277,7 @@ Translator_def::apply_property_operations (Translator_group*tg) } else if (type == assign_sym) { - tg->set_property (ly_car (entry), ly_cadr (entry)); + tg->internal_set_property (ly_car (entry), ly_cadr (entry)); } } } diff --git a/lily/translator-group.cc b/lily/translator-group.cc index bb7f8cb187..aac575c38b 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -277,27 +277,21 @@ Translator_group::where_defined (SCM sym) const return SCM_EOL when not found. */ SCM -Translator_group::get_property (SCM sym) const +Translator_group::internal_get_property (SCM sym) const { SCM val =SCM_EOL; if (properties_dict ()->try_retrieve (sym, &val)) return val; if (daddy_trans_l_) - return daddy_trans_l_->get_property (sym); + return daddy_trans_l_->internal_get_property (sym); return val; } -void -Translator_group::set_property (String id, SCM val) -{ - set_property (ly_symbol2scm (id.ch_C ()), val); -} - void -Translator_group::set_property (SCM sym, SCM val) +Translator_group::internal_set_property (SCM sym, SCM val) { properties_dict ()->set (sym, val); } @@ -323,18 +317,16 @@ Translator_group::execute_single_pushpop_property (SCM prop, SCM eltprop, SCM va { if (val != SCM_UNDEFINED) { - SCM prev = get_property (prop); + SCM prev = internal_get_property (prop); if (gh_pair_p (prev) || prev == SCM_EOL) { bool ok = type_check_assignment (val, eltprop, ly_symbol2scm ("backend-type?")); - - if (ok) { prev = gh_cons (gh_cons (eltprop, val), prev); - set_property (prop, prev); + internal_set_property (prop, prev); } } else @@ -345,7 +337,7 @@ Translator_group::execute_single_pushpop_property (SCM prop, SCM eltprop, SCM va } else { - SCM prev = get_property (prop); + SCM prev = internal_get_property (prop); SCM newprops= SCM_EOL ; while (gh_pair_p (prev) && ly_caar (prev) != eltprop) @@ -357,7 +349,7 @@ Translator_group::execute_single_pushpop_property (SCM prop, SCM eltprop, SCM va if (gh_pair_p (prev)) { newprops = scm_reverse_x (newprops, ly_cdr (prev)); - set_property (prop, newprops); + internal_set_property (prop, newprops); } } } @@ -448,7 +440,7 @@ ly_get_trans_property (SCM context, SCM name) warning (_ ("ly-get-trans-property: expecting a Translator_group argument")); return SCM_EOL; } - return tr->get_property (name); + return tr->internal_get_property (name); } SCM @@ -459,7 +451,7 @@ ly_set_trans_property (SCM context, SCM name, SCM val) Translator_group* tr= dynamic_cast (t); if (tr) { - tr->set_property (name, val); + tr->internal_set_property (name, val); } return SCM_UNSPECIFIED; } diff --git a/lily/translator.cc b/lily/translator.cc index ef5f4b100a..ddac9aae3c 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -97,17 +97,18 @@ Translator::output_def_l () const { return output_def_l_; } - +#if 0 SCM Translator::get_property (char const * id) const { return daddy_trans_l_->get_property (ly_symbol2scm (id)); } +#endif SCM -Translator::get_property (SCM sym) const +Translator::internal_get_property (SCM sym) const { - return daddy_trans_l_->get_property (sym); + return daddy_trans_l_->internal_get_property (sym); } void diff --git a/lily/unfolded-repeat-iterator.cc b/lily/unfolded-repeat-iterator.cc index 315149a478..7dd93bd1dc 100644 --- a/lily/unfolded-repeat-iterator.cc +++ b/lily/unfolded-repeat-iterator.cc @@ -296,7 +296,7 @@ Unfolded_repeat_iterator::add_repeat_command (SCM what) && current_reps == SCM_EOL || gh_pair_p (current_reps)) { current_reps = gh_cons (what, current_reps); - where->set_property (reps, current_reps); + where->internal_set_property (reps, current_reps); } } diff --git a/ly/drumpitch-init.ly b/ly/drumpitch-init.ly index b55e8bb1f4..211246f081 100644 --- a/ly/drumpitch-init.ly +++ b/ly/drumpitch-init.ly @@ -47,7 +47,7 @@ (mutehiconga cghm ,(make-pitch 0 1 0)) (openhiconga cgho ,(make-pitch 0 1 1)) (hiconga cgh ,(make-pitch 0 2 -1)) - (openloconga cglo ,(make-pitch 0 1 2)) + (openloconga cglo ,(make-pitch 0 1 2)) (loconga cgl ,(make-pitch 0 2 0)) (hitimbale timh ,(make-pitch 0 3 0)) (lotimbale timl ,(make-pitch 0 3 1)) diff --git a/make/mutopia-targets.make b/make/mutopia-targets.make index 09168cb9cd..3504259fb5 100644 --- a/make/mutopia-targets.make +++ b/make/mutopia-targets.make @@ -10,7 +10,9 @@ include $(stepdir)/www-targets.make all: $(OUT_FILES) -local-WWW: $(ly_examples) $(fly_examples) $(ps_examples) $(png_examples) +# we want dvi_examples as well, because they get thrown away otherwise +# incurring another costly lilypond run. +local-WWW: $(ly_examples) $(dvi_examples) $(ps_examples) $(png_examples) tar: mkdir -p $(outdir)/$(tarball) diff --git a/make/mutopia-vars.make b/make/mutopia-vars.make index 0eb68b09db..2132fab757 100644 --- a/make/mutopia-vars.make +++ b/make/mutopia-vars.make @@ -11,11 +11,8 @@ LYM4_FILES = $(wildcard *.lym4) EXTRA_DIST_FILES += $(M4_FILES) $(LYM4_FILES) ly_examples=$(addprefix $(outdir)/, $(addsuffix .ly.txt, $(examples))) -fly_examples=$(addprefix $(outdir)/, $(addsuffix .fly.txt, $(flexamples))) -sly_examples=$(addprefix $(outdir)/, $(addsuffix .sly.txt, $(slexamples))) - -all_examples=$(flexamples) $(slexamples) $(examples) - +all_examples=$(examples) +dvi_examples=$(addprefix $(outdir)/, $(addsuffix .dvi, $(all_examples))) ps_examples=$(addprefix $(outdir)/, $(addsuffix .ps.gz, $(all_examples))) gif_examples=$(addprefix $(outdir)/, $(addsuffix .gif, $(all_examples))) png_examples=$(addprefix $(outdir)/, $(addsuffix .png, $(all_examples))) diff --git a/make/out/lilypond.lsm b/make/out/lilypond.lsm index 71d5ff6301..f81ccc5f15 100644 --- a/make/out/lilypond.lsm +++ b/make/out/lilypond.lsm @@ -1,15 +1,15 @@ Begin3 Title: LilyPond -Version: 1.5.18 -Entered-date: 18OKT01 +Version: 1.5.19 +Entered-date: 23OKT01 Description: @BLURB@ Keywords: music notation typesetting midi fonts engraving Author: hanwen@cs.uu.nl (Han-Wen Nienhuys) janneke@gnu.org (Jan Nieuwenhuizen) Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys) Primary-site: sunsite.unc.edu /pub/Linux/apps/sound/convert - 1000k lilypond-1.5.18.tar.gz + 1000k lilypond-1.5.19.tar.gz Original-site: ftp.cs.uu.nl /pub/GNU/LilyPond/development/ - 1000k lilypond-1.5.18.tar.gz + 1000k lilypond-1.5.19.tar.gz Copying-policy: GPL End diff --git a/make/out/lilypond.mandrake.spec b/make/out/lilypond.mandrake.spec index 1019348b8d..225ce98450 100644 --- a/make/out/lilypond.mandrake.spec +++ b/make/out/lilypond.mandrake.spec @@ -1,5 +1,5 @@ %define name lilypond -%define version 1.5.18 +%define version 1.5.19 %define release 1mdk Name: %{name} diff --git a/make/out/lilypond.redhat.spec b/make/out/lilypond.redhat.spec index 857d62c67e..96197d0358 100644 --- a/make/out/lilypond.redhat.spec +++ b/make/out/lilypond.redhat.spec @@ -1,11 +1,11 @@ %define info yes Name: lilypond -Version: 1.5.18 +Version: 1.5.19 Release: 1 License: GPL Group: Applications/Publishing -Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.18.tar.gz +Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.19.tar.gz Summary: Create and print music notation URL: http://www.lilypond.org/ BuildRoot: /tmp/lilypond-install diff --git a/make/out/lilypond.suse.spec b/make/out/lilypond.suse.spec index e4dfe7649b..5dd26d69b5 100644 --- a/make/out/lilypond.suse.spec +++ b/make/out/lilypond.suse.spec @@ -14,11 +14,11 @@ Distribution: SuSE Linux 7.0 (i386) Name: lilypond -Version: 1.5.18 +Version: 1.5.19 Release: 2 Copyright: GPL Group: Applications/Publishing -Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.18.tar.gz +Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.19.tar.gz # music notation software for.. ? Summary: A program for printing sheet music. URL: http://www.lilypond.org/ diff --git a/midi2ly/GNUmakefile b/midi2ly/GNUmakefile deleted file mode 100644 index 9982b30164..0000000000 --- a/midi2ly/GNUmakefile +++ /dev/null @@ -1,22 +0,0 @@ -# title makefile for midi2ly -# file midi2ly/Makefile - -depth = .. - -NAME = midi2ly-old -MODULE_NAME = midi2ly-old - -SUBDIRS = include -MODULE_LIBS=$(depth)/flower -HELP2MAN_EXECS = midi2ly-old -STEPMAKE_TEMPLATES=c++ executable po help2man - -include $(depth)/make/stepmake.make - -# explicit dependencies: (how to do auto?) -# -midi-lexer.l: $(outdir)/midi-parser.hh - - -$(outdir)/midi2ly-version.o: $(outdir)/version.hh - diff --git a/midi2ly/duration-convert.cc b/midi2ly/duration-convert.cc deleted file mode 100644 index ee53cf47c4..0000000000 --- a/midi2ly/duration-convert.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* - duration-convert.cc -- implement Duration_convert - - source file of the LilyPond music typesetter - - (c) 1997--2001 Han-Wen Nienhuys - Jan Nieuwenhuizen -*/ -#include -#include "duration-convert.hh" -#include "warn.hh" - -// statics Duration_convert -bool Duration_convert::no_quantify_b_s = false; -bool Duration_convert::no_double_dots_b_s = false; -bool Duration_convert::no_tuplets_b_s = false; -int Duration_convert::no_smaller_than_i_s = 0; -Array Duration_convert::dur_array_s; - -String -Duration_convert::dur2_str (Duration dur) -{ - if (dur.ticks_i_) - return String ("[") + to_str (dur.ticks_i_) + "]"; - - String str; - if (dur.durlog_i_ >= 0) - str = to_str ( type2_i (dur.durlog_i_) ); - else if (dur.durlog_i_ == -1) - str = "\\breve"; - else if (dur.durlog_i_ <= -2) - { - str = "\\longa"; - if (dur.durlog_i_ < -2) - { - dur.plet_.iso_i_ *= 1 << (-2 - dur.durlog_i_); - } - } - str += to_str ('.', dur.dots_i_); - if (dur.plet_b ()) - { - str += String ("*") + to_str (dur.plet_.iso_i_); - if (dur.plet_.type_i_ != 1) - str += String ("/") + to_str (dur.plet_.type_i_); - } - return str; -} - -int -Duration_convert::dur2ticks_i (Duration dur) -{ - if (dur.ticks_i_) - return dur.ticks_i_; - return dur2_mom (dur) * Rational (Duration::division_1_i_s); -} - -int -Duration_convert::i2_type (int i) -{ - int t=0; - while (i && !(i & 1)) { - i >>= 1; - t++; - } - return t; -} - -int -Duration_convert::type2_i (int type) -{ - if (type<0) - return 0; - else - return 1 << type; -} - -Rational -Duration_convert::dur2_mom (Duration dur) -{ - if (dur.ticks_i_) - return Rational (dur.ticks_i_, Duration::division_1_i_s); - - // or simply assert? - if (dur.durlog_i_<-10) - return Rational (0); - Rational mom; - if (dur.durlog_i_<0) - mom = Rational (type2_i (-dur.durlog_i_), 1); - else - mom = Rational (1 , type2_i (dur.durlog_i_)); - - Rational delta = mom; - while (dur.dots_i_--) - { - delta /= 2.0; - mom += delta; - } - - return mom * plet_factor_mom (dur); -} - -Duration -Duration_convert::mom2_dur (Rational mom) -{ - if (!mom) - { - Duration dur; - dur.set_plet (0,1); - return dur; - } - - return mom2standardised_dur (mom); -} - - -Duration -Duration_convert::mom2standardised_dur (Rational mom) -{ - Duration dur; - - if (mom == Rational (0)) - return dur; - - int d = no_smaller_than_i_s ? no_smaller_than_i_s : 7; - int i = type2_i (d); - int n = (mom / Rational (1, i)).to_int (); - - int tuplet = 1; - if (!no_tuplets_b_s) - { - // ugh: 8 - int m = n; - int tup = 1; - while (tup < 8 && - mom != Rational (m, i * tup)) - { - tup += 2; - m = (mom / Rational (1, i * tup)).to_int (); - } - - if (tuplet < 8) - { - n = m; - tuplet = tup; - } - } - - if (!n) - return dur; - - if (mom - Rational (n, i) - > Rational (1, i * 2 * tuplet)) - n++; - - while (!(n & 1)) - { - n >>= 1; - d--; - } - - dur.durlog_i_ = d; - dur.plet_.iso_i_ = n; - dur.plet_.type_i_ = tuplet; - return dur; -} - -Rational -Duration_convert::plet_factor_mom (Duration dur) -{ - return dur.plet_.mom (); -} - -Real -Duration_convert::sync_f (Duration dur, Rational mom) -{ - return mom / dur2_mom (dur); -} - -Duration -Duration_convert::ticks2_dur (int ticks_i) -{ - Rational mom (ticks_i, Duration::division_1_i_s); - return mom2standardised_dur (mom); -} - -Duration -Duration_convert::ticks2standardised_dur (int ticks_i) -{ - Rational mom (ticks_i, Duration::division_1_i_s); - Duration dur = mom2standardised_dur (mom); - return dur; -} diff --git a/midi2ly/duration.cc b/midi2ly/duration.cc deleted file mode 100644 index 391537af3a..0000000000 --- a/midi2ly/duration.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* - duration.cc -- implement Duration, Plet, - - source file of the LilyPond music typesetter - - (c) 1997--2001 Jan Nieuwenhuizen - Han-Wen Nienhuys - - - UGH. Duration is broken. -*/ - -#include - -#include "flower-proto.hh" -#include "string.hh" -#include "source-file.hh" -#include "source.hh" -#include "rational.hh" -#include "duration.hh" -#include "duration-convert.hh" - -// statics Duration -int Duration::division_1_i_s = 384 * 4; - - -Duration::Duration () -{ - durlog_i_ = 0; - dots_i_ = 0; - ticks_i_ = 0; -} - -bool -Duration::duration_type_b (int t) -{ - /* - ugh. Assuming behavior of conversion funcs on broken input. - */ - return t == Duration_convert::type2_i (Duration_convert::i2_type (t)); -} - -void -Duration::compress (Rational m) -{ - plet_.iso_i_ *= m.num (); - plet_.type_i_ *= m.den (); -} - -Rational -Duration::length_mom () const -{ - return Duration_convert::dur2_mom (*this); -} - -void -Duration::set_plet (int i, int t) -{ - plet_.iso_i_ = i; - plet_.type_i_ = t; -} - -/* -void -Duration::set_plet (Duration d) -{ - plet_.iso_i_ = d.plet_.iso_i_; - plet_.type_i_ = d.plet_.type_i_; -} -*/ - -void -Duration::set_ticks (int ticks_i) -{ - assert (durlog_i_ <10); - assert (!dots_i_); - ticks_i_ = ticks_i; -} - -String -Duration::str () const -{ - return Duration_convert::dur2_str (*this); -} - - -bool -Duration::plet_b () -{ - return !plet_.unit_b (); -} - diff --git a/midi2ly/include/GNUmakefile b/midi2ly/include/GNUmakefile deleted file mode 100644 index 1a19230204..0000000000 --- a/midi2ly/include/GNUmakefile +++ /dev/null @@ -1,6 +0,0 @@ -# lib/include/Makefile - -depth = ../.. -STEPMAKE_TEMPLATES=c++ -include $(depth)/make/stepmake.make - diff --git a/midi2ly/include/dummy.icc b/midi2ly/include/dummy.icc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/midi2ly/include/dummy.tcc b/midi2ly/include/dummy.tcc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/midi2ly/include/duration-convert.hh b/midi2ly/include/duration-convert.hh deleted file mode 100644 index db6818e2f2..0000000000 --- a/midi2ly/include/duration-convert.hh +++ /dev/null @@ -1,78 +0,0 @@ -/* - duration-convert.hh -- declare Duration_convert - - source file of the LilyPond music typesetter - - (c) 1997--2001 Han-Wen Nienhuys -*/ - - -#ifndef DURATION_CONVERT_HH -#define DURATION_CONVERT_HH -#include "duration.hh" -#include "string.hh" -#include "array.hh" - -/** - Duration_convert handles all conversions to -n fro Duration (dur). - That is including (integer + division) representation for MIDI, - and conversion from unexact time representation (best guess :-). - - A Rational (mom) is a Rational that holds the time fraction - compared to a whole note (before also called wholes). - - [todo] - move all statics to real members, instantiate Duration_convert - object (s). -*/ -struct Duration_convert { - - /* Urgh. statics. - */ - static bool no_quantify_b_s; - static bool no_double_dots_b_s; - static bool no_tuplets_b_s; - static int no_smaller_than_i_s; - static Array dur_array_s; - - /// Return number of ticks in (ticks, division_1) representation - static int dur2ticks_i (Duration dur ); - - /// Return the type_i representation of note length i - static int i2_type (int i); - - /// Return the note length corresponding to the type_i representation - /// Return 0 if longer than whole note. - static int type2_i (int type); - - /// Return Rational representation (fraction of whole note). - static Rational dur2_mom (Duration dur ); - - /// Return Lilypond string representation. - static String dur2_str (Duration dur ); - - /// Return duration from Rational (fraction of whole) representation. - static Duration mom2_dur (Rational mom ); - - /// Return standardised duration, best guess if not exact. - static Duration mom2standardised_dur (Rational mom ); - - /// Return plet factor (not a Rational: should use Rational?). - static Rational plet_factor_mom (Duration dur ); - - static void set_array (); - - /** Return synchronisation factor for mom, so that - mom2_dur (mom / sync_f ) will return the duration dur. - */ - static Real sync_f (Duration dur, Rational mom ); - - /// Return exact duration, in midi-ticks if not-exact. - static Duration ticks2_dur (int ticks_i ); - - /// Return standardised duration, best guess if not exact. - static Duration ticks2standardised_dur (int ticks_i ); -}; - - -#endif // DURATION_CONVERT_HH diff --git a/midi2ly/include/duration.hh b/midi2ly/include/duration.hh deleted file mode 100644 index 22f4fb4530..0000000000 --- a/midi2ly/include/duration.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - duration.hh -- declare Duration - - source file of the LilyPond music typesetter - - (c) 1997--2001 Jan Nieuwenhuizen - -*/ - -// split into 4? - -#ifndef DURATION_HH -#define DURATION_HH - -#include "flower-proto.hh" -#include "rational.hh" -#include "plet.hh" - -/** - Handle "musical" durations. This means: balltype 1,2,4,etc. and dots. - - (dur) - */ -struct Duration { - Duration (); - /// is the "plet factor" of this note != 1 ? - bool plet_b (); - String str () const; - void set_plet (int,int ); - void compress (Rational); - - static bool duration_type_b (int t); - void set_ticks (int ticks_i ); - Rational length_mom () const ; - static int division_1_i_s; - - /// Logarithm of the base duration. - int durlog_i_; - int dots_i_; - Plet plet_; - int ticks_i_; -}; -#endif // DURATION_HH - diff --git a/midi2ly/include/lilypond-column.hh b/midi2ly/include/lilypond-column.hh deleted file mode 100644 index b7422c2c67..0000000000 --- a/midi2ly/include/lilypond-column.hh +++ /dev/null @@ -1,29 +0,0 @@ -// -// lilypond-column.hh -- declare Lilypond_column -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#ifndef LILYPOND_COLUMN_HH -#define LILYPOND_COLUMN_HH - -#include "flower-proto.hh" -#include "midi2ly-proto.hh" -#include "rational.hh" -#include "cons.hh" - -/// (lilypond_column) -class Lilypond_column -{ -public: - Lilypond_column (Lilypond_score* lilypond_score_l, Rational mom); - - void add_item (Lilypond_item* lilypond_item_l); - Rational at_mom (); - - Cons_list lilypond_item_l_list_; - Rational at_mom_; - Lilypond_score* lilypond_score_l_; -}; - -#endif // LILYPOND_COLUMN_HH - diff --git a/midi2ly/include/lilypond-item.hh b/midi2ly/include/lilypond-item.hh deleted file mode 100644 index 5855725d2a..0000000000 --- a/midi2ly/include/lilypond-item.hh +++ /dev/null @@ -1,130 +0,0 @@ -// -// lilypond-item.hh -- declare lilypond_item -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#ifndef LILYPOND_ITEM_HH -#define LILYPOND_ITEM_HH - -#include "midi2ly-proto.hh" -#include "string.hh" -#include "rational.hh" -#include "duration.hh" - -// should these: -// * be Lilypond_items -// * be Voice_elements/requests -// * get a name-change -// ? - -/// (lilypond_item) -class Lilypond_item -{ -public: - Lilypond_item (Lilypond_column* lilypond_column_l); - virtual ~Lilypond_item (); - - virtual Rational at_mom (); - virtual Rational duration_mom (); - void output (Lilypond_stream& lilypond_stream_r); - virtual String str () = 0; - - Lilypond_column* lilypond_column_l_; -}; - -class Lilypond_key : public Lilypond_item -{ -public: - Lilypond_key (int accidentals_i, int minor_i); - - String notename_str (int pitch_i); - virtual String str (); - - //private: - int accidentals_i_; - int minor_i_; -}; - -class Lilypond_time_signature : public Lilypond_item -{ -public: - Lilypond_time_signature (int num_i, int den_i, int division_4_i, int count_32_i); - - Duration i2_dur (int time_i, int division_1_i); - int clocks_1_i (); - int den_i (); - int num_i (); - virtual String str (); - Rational bar_mom (); - -private: - Real sync_f_; - Duration sync_dur_; - int clocks_1_i_; - int num_i_; - int den_i_; -}; - -class Lilypond_note : public Lilypond_item -{ -public: - Lilypond_note (Lilypond_column* lilypond_column_l, int channel_i, int pitch_i, int dyn_i); - - Duration duration (); - virtual Rational duration_mom (); - virtual String str (); - - // int const c0_pitch_i_c_ = 60; // huh? - static int const c0_pitch_i_c_ = 48; - - static bool const simple_plet_b_s = false; - int channel_i_; - int pitch_i_; - Lilypond_column* end_column_l_; -}; - -class Lilypond_skip : public Lilypond_item -{ -public: - Lilypond_skip (Lilypond_column* lilypond_column_l, Rational skip_mom); - - Duration duration (); - virtual Rational duration_mom (); - virtual String str (); - -private: - Rational mom_; -}; - - -class Lilypond_tempo : public Lilypond_item -{ -public: - Lilypond_tempo (int useconds_per_4_i); - - int get_tempo_i (Rational rational); - virtual String str (); - int useconds_per_4_i (); - -private: - int useconds_per_4_i_; - Rational seconds_per_1_mom_; -}; - -class Lilypond_text : public Lilypond_item -{ -public: - enum Type { - TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, - MARKER, CUE_POINT - }; - Lilypond_text (Lilypond_text::Type type, String str); - virtual String str (); - - //private: - Type type_; - String text_str_; -}; - -#endif // LILYPOND_ITEM_HH - diff --git a/midi2ly/include/lilypond-score.hh b/midi2ly/include/lilypond-score.hh deleted file mode 100644 index d8996e82f0..0000000000 --- a/midi2ly/include/lilypond-score.hh +++ /dev/null @@ -1,51 +0,0 @@ -// -// lilypond-score.hh -- declare Lilypond_score -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#ifndef LILYPOND_SCORE_HH -#define LILYPOND_SCORE_HH - -#include "midi2ly-proto.hh" -#include "flower-proto.hh" -#include "cons.hh" -#include "parray.hh" - -/// (lilypond_score) -class Lilypond_score { -public: - Lilypond_score (int format_i, int tracks_i, int tempo_i); - ~Lilypond_score (); - - void add_item (Lilypond_item* lilypond_item_p); - void add_staff (Lilypond_staff* lilypond_staff_p); - - Lilypond_column* find_column_l (Rational mom); - Lilypond_column* get_column_l (Rational mom); - - void output (String filename_str); - void process (); - - // ugh - Lilypond_key* lilypond_key_l_; - Lilypond_time_signature* lilypond_time_signature_l_; - Lilypond_tempo* lilypond_tempo_l_; - Lilypond_staff * last_staff_l_; -private: - void filter_tempo (); - void quantify_columns (); - void quantify_durations (); - void settle_columns (); - - Cons_list lilypond_staff_p_list_; - Link_array column_l_array_; - - // ugh, ugh, ugh -public: - int format_i_; - int tracks_i_; - int tempo_i_; -}; - -#endif // LILYPOND_SCORE_HH - diff --git a/midi2ly/include/lilypond-staff.hh b/midi2ly/include/lilypond-staff.hh deleted file mode 100644 index d9e4580c29..0000000000 --- a/midi2ly/include/lilypond-staff.hh +++ /dev/null @@ -1,43 +0,0 @@ -// -// lilypond-staff.hh -- declare lilypond_staff -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#ifndef LILYPOND_STAFF_HH -#define LILYPOND_STAFF_HH - -#include "midi2ly-proto.hh" -#include "flower-proto.hh" -#include "cons.hh" -#include "string.hh" - -/// (lilypond_staff) -class Lilypond_staff -{ -public: - Lilypond_staff (int number_i, String copyright_str, String track_name_str, String instrument_str); - - void add_item (Lilypond_item* lilypond_item_p); - void eat_voice (Cons_list& items); - String id_str (); - String name_str (); - void output (Lilypond_stream& lilypond_stream_r); - void process (); - - String copyright_str_; - String instrument_str_; - String name_str_; - Lilypond_key* lilypond_key_l_; - Lilypond_time_signature* lilypond_time_signature_l_; - Lilypond_tempo* lilypond_tempo_l_; - int number_i_; - -private: - void output_lilypond_begin_bar (Lilypond_stream& lilypond_stream_r, Rational now_mom, int bar_i); - - Cons_list lilypond_voice_p_list_; - Cons_list lilypond_item_p_list_; -}; - -#endif // LILYPOND_STAFF_HH - diff --git a/midi2ly/include/lilypond-stream.hh b/midi2ly/include/lilypond-stream.hh deleted file mode 100644 index 2e6429907f..0000000000 --- a/midi2ly/include/lilypond-stream.hh +++ /dev/null @@ -1,42 +0,0 @@ -// -// lilypond-stream.hh -- part of LilyPond -// -// (c) 1997--2001 Jan Nieuwenhuizen - -// should i be named Lilypond_stream? - -#ifndef LILYPOND_STREAM_HH -#define LILYPOND_STREAM_HH - -#include "midi2ly-proto.hh" -#include "string.hh" -//#include "scalar.hh" - -/// Lily output -class Lilypond_stream { -public: - Lilypond_stream (String filename_str); - ~Lilypond_stream(); - - Lilypond_stream& operator << (char c); - Lilypond_stream& operator << (String s); - Lilypond_stream& operator << (Lilypond_item& lilypond_item_r); - -private: - void handle_pending_indent(); - void header(); - void open(); - void output (String str); - void output_wrapped (String str); - - ostream* os_p_; - String filename_str_; - int indent_i_; - int column_i_; - int pending_indent_i_; - int wrap_column_i_; - bool comment_mode_b_; -}; - -#endif // LILYPOND_STREAM_HH - diff --git a/midi2ly/include/lilypond-voice.hh b/midi2ly/include/lilypond-voice.hh deleted file mode 100644 index dff2528881..0000000000 --- a/midi2ly/include/lilypond-voice.hh +++ /dev/null @@ -1,30 +0,0 @@ -// -// lilypond-voice.hh -- declare Lilypond_voice -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#ifndef LILYPOND_VOICE_HH -#define LILYPOND_VOICE_HH - -#include "midi2ly-proto.hh" -//#include "flower-proto.hh" -#include "parray.hh" -#include "cons.hh" - -/// (lilypond_voice) -class Lilypond_voice -{ -public: - Lilypond_voice (Lilypond_staff* lilypond_staff_l); - void add_items (Link_array& items); - void output (Lilypond_stream& lilypond_stream_r); - String get_clef () const; - -private: - Lilypond_staff* lilypond_staff_l_; - Link_array < Cons_list > threads_; - Rational mom_; -}; - -#endif // LILYPOND_VOICE_HH - diff --git a/midi2ly/include/midi-parser.hh b/midi2ly/include/midi-parser.hh deleted file mode 100644 index 670ff5ea7e..0000000000 --- a/midi2ly/include/midi-parser.hh +++ /dev/null @@ -1,106 +0,0 @@ -/* - midi-parser.hh -- declare Midi_parser - - source file of the GNU LilyPond music typesetter - - (c) 1997--1998 Jan Nieuwenhuizen -*/ - - -#ifndef MIDI_PARSER_HH -#define MIDI_PARSER_HH - -// must, gcc 2.7.2{,.1} hits ico on midi-track-parser.cc:134 (@Midi_note) -#define INLINES - -#ifdef INLINES - -#define next_byte() (inline_next_byte (__FUNCTION__)) -#define peek_byte() (inline_peek_byte (__FUNCTION__)) -#define forward_byte_L(n) (inline_forward_byte_L (__FUNCTION__, n)) - -#else - -#define next_byte()\ - ((info_l_->byte_L_ < info_l_->end_byte_L_ ?\ - *info_l_->byte_L_++\ - : (Byte const)exit (__FUNCTION__": unexpected EOF"))); - -#define peek_byte()\ - ((info_l_->byte_L_ < info_l_->end_byte_L_ ?\ - *info_l_->byte_L_\ - : (Byte const)exit (__FUNCTION__": unexpected EOF"))); - -#define forward_byte_L(n) (inline_forward_byte_L (__FUNCTION__, n)) - -#endif - -#include "flower-proto.hh" -#include "rational.hh" -#include "midi2ly-proto.hh" - -struct Midi_parser_info -{ - Midi_parser_info(); - int division_1_i_; - int format_i_; - int tracks_i_; - int errorlevel_i_; - Byte const* byte_L_; - Byte const* end_byte_L_; - Source_file* source_l_; - Lilypond_score* score_l_; - Rational bar_mom_; -}; - -#include "string.hh" - -class Midi_parser -{ -public: - Midi_parser (); - - Midi_parser_info* info_l_; - -protected: - Byte const* inline_forward_byte_L (char const* fun, int n) - { - if (info_l_->byte_L_ + n < info_l_->end_byte_L_ ) - { - Byte const* p = info_l_->byte_L_; - info_l_->byte_L_ += n; - return p; - } - exit (String (fun) + ": unexpected EOF"); - return 0; - } - -#ifdef INLINES - Byte inline_next_byte (char const* fun) - { - if (info_l_->byte_L_ < info_l_->end_byte_L_) - return *info_l_->byte_L_++; - exit (String (fun) + ": unexpected EOF"); - return 0; - } - - Byte inline_peek_byte (char const* fun) - { - if (info_l_->byte_L_ < info_l_->end_byte_L_) - return *info_l_->byte_L_; - exit (String (fun) + ": unexpected EOF"); - return 0; - } -#endif - - int get_i (int); - String get_str (int); - unsigned get_u (int); - int get_var_i (); - int exit (String); - void error (String); - String message (String); - void warning (String); -}; - -#endif // MIDI_PARSER_HH diff --git a/midi2ly/include/midi-score-parser.hh b/midi2ly/include/midi-score-parser.hh deleted file mode 100644 index 25d6758883..0000000000 --- a/midi2ly/include/midi-score-parser.hh +++ /dev/null @@ -1,31 +0,0 @@ -/* - midi-score-parser.hh -- declare Midi_score_parser - - source file of the GNU LilyPond music typesetter - - (c) 1997--1998 Jan Nieuwenhuizen -*/ - - -#ifndef MIDI_SCORE_PARSER_HH -#define MIDI_SCORE_PARSER_HH - -#include "midi-parser.hh" -#include "flower-proto.hh" -#include "midi2ly-proto.hh" -#include "parray.hh" - -class Midi_score_parser : public Midi_parser -{ -public: - Lilypond_score* parse (String filename_str, Sources*); - -private: - void open (String filename_str, Sources*); - - void parse_header (); - int find_earliest_i (Link_array& tracks); - Lilypond_score* parse_score (); -}; - -#endif // MIDI_SCORE_PARSER_HH diff --git a/midi2ly/include/midi-track-parser.hh b/midi2ly/include/midi-track-parser.hh deleted file mode 100644 index 89e6363d3d..0000000000 --- a/midi2ly/include/midi-track-parser.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - midi-track-parser.hh -- declare - - source file of the GNU LilyPond music typesetter - - (c) 1997--1998 Jan Nieuwenhuizen -*/ - - -#ifndef MIDI_TRACK_PARSER_HH -#define MIDI_TRACK_PARSER_HH - -#include "flower-proto.hh" -#include "cons.hh" -#include "rational.hh" -#include "midi2ly-proto.hh" -#include "midi-parser.hh" - -class Midi_track_parser : public Midi_parser -{ -public: - - Midi_track_parser (Midi_parser_info* info_l, int i); - ~Midi_track_parser (); - - Rational at_mom (); - Lilypond_staff* parse (Lilypond_column* col_l); - -private: - bool eot (); - void note_end (Lilypond_column* col_l, int channel_i, int pitch_i, int aftertouch_i ); - void note_end_all (Lilypond_column* col_l) ; - void parse_delta_time (); - Lilypond_item* parse_event (Lilypond_column* col_l); - void parse_header (); - - Rational at_mom_; - Byte running_byte_; - Cons_list open_note_l_list_; - Lilypond_staff* lilypond_staff_p_; - Midi_parser_info* track_info_p_; -}; - -#endif // MIDI_TRACK_PARSER_HH diff --git a/midi2ly/include/midi2ly-global.hh b/midi2ly/include/midi2ly-global.hh deleted file mode 100644 index 2b06890921..0000000000 --- a/midi2ly/include/midi2ly-global.hh +++ /dev/null @@ -1,36 +0,0 @@ -// -// midi2ly-global.hh -- declare global stuff for midi2ly -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#ifndef MIDI2LY_GLOBAL_HH -#define MIDI2LY_GLOBAL_HH - -#include - -#include "string.hh" -#include "flower-proto.hh" - -#define monitor_p_g &cout -enum Verbose { QUIET_ver, BRIEF_ver, NORMAL_ver, VERBOSE_ver, DEBUG_ver }; -extern Verbose level_ver; -#if 0 // NPRINT - // not what i want, all output goes through tors. - // set verbosity level. - #define LOGOUT(threshold) if (0) *monitor_p_g -#else - #define LOGOUT(threshold) if (level_ver >= threshold) *monitor_p_g -#endif - -extern Sources* source_l_g; -// huh? -void message (String message_str); //, char const* context_ch_C); -void warning (String message_str); //, char const* context_ch_C); -void error (String message_str); //, char const* context_ch_C); - -String midi2ly_version_str(); -extern bool no_timestamps_b_g;; -extern bool no_rests_b_g;; - -#endif // MIDI2LY_GLOBAL_HH - diff --git a/midi2ly/include/midi2ly-proto.hh b/midi2ly/include/midi2ly-proto.hh deleted file mode 100644 index dac1d8d1a1..0000000000 --- a/midi2ly/include/midi2ly-proto.hh +++ /dev/null @@ -1,29 +0,0 @@ -/* - midi2ly-proto.hh -- declare type names in midi2ly - - source file of midi2ly, part of the GNU LilyPond package, - - (c) 1997--1998 Han-Wen Nienhuys -*/ - - -#ifndef MIDI2LY_PROTO_HH -#define MIDI2LY_PROTO_HH - -class Midi_parser; -struct Midi_parser_info; -class Midi_score_parser; -class Midi_track_parser; -class Lilypond_stream; -class Lilypond_item; -class Lilypond_key; -class Lilypond_time_signature; -class Lilypond_note; -class Lilypond_tempo; -class Lilypond_text; -class Lilypond_score; -class Lilypond_staff; -class Lilypond_voice; -class Lilypond_column; - -#endif // MIDI2LY_PROTO_HH diff --git a/midi2ly/include/plet.hh b/midi2ly/include/plet.hh deleted file mode 100644 index c05709e3ab..0000000000 --- a/midi2ly/include/plet.hh +++ /dev/null @@ -1,27 +0,0 @@ -/* - plet.hh -- declare Plet - - source file of the GNU LilyPond music typesetter - - (c) 1997--2001 Han-Wen Nienhuys -*/ - - -#ifndef PLET_HH -#define PLET_HH -#include "rational.hh" - -/** - The type and replacement value of a plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3. - - (plet) - */ -struct Plet { - Plet (); - Rational mom () const; - bool unit_b () const; - int iso_i_; // 2/3; 2 is not duration, maar of count! - int type_i_; -}; - -#endif // PLET_HH diff --git a/midi2ly/lilypond-column.cc b/midi2ly/lilypond-column.cc deleted file mode 100644 index 3fde791a66..0000000000 --- a/midi2ly/lilypond-column.cc +++ /dev/null @@ -1,24 +0,0 @@ -// -// lilypond-column.cc -- implement Lilypond_column -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#include "lilypond-column.hh" - -Lilypond_column::Lilypond_column (Lilypond_score* lilypond_score_l, Rational mom) -{ - lilypond_score_l_ = lilypond_score_l; - at_mom_ = mom; -} - -void -Lilypond_column::add_item (Lilypond_item* lilypond_item_l) -{ - lilypond_item_l_list_.append (new Cons (lilypond_item_l, 0)); -} - -Rational -Lilypond_column::at_mom() -{ - return at_mom_; -} diff --git a/midi2ly/lilypond-item.cc b/midi2ly/lilypond-item.cc deleted file mode 100644 index 9d796ad7ac..0000000000 --- a/midi2ly/lilypond-item.cc +++ /dev/null @@ -1,385 +0,0 @@ -// -// lilypond-item.cc -- implement Lilypond_item -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#include -#include -#include "midi2ly-global.hh" -#include "string-convert.hh" -#include "duration-convert.hh" -#include "lilypond-column.hh" -#include "lilypond-item.hh" -#include "lilypond-stream.hh" -#include "lilypond-score.hh" - -Lilypond_item::Lilypond_item (Lilypond_column* lilypond_column_l) -{ - lilypond_column_l_ = lilypond_column_l; -} - -Lilypond_item::~Lilypond_item () -{ -} - -Rational -Lilypond_item::at_mom () -{ - return lilypond_column_l_->at_mom (); -} - -Rational -Lilypond_item::duration_mom () -{ - return Rational (0); -} - -void -Lilypond_item::output (Lilypond_stream& lilypond_stream_r) -{ - lilypond_stream_r << str () << " "; -} - -Lilypond_key::Lilypond_key (int accidentals_i, int minor_i) - : Lilypond_item (0) -{ - accidentals_i_ = accidentals_i; - minor_i_ = minor_i; -} - -char const *accname[] = {"eses", "es", "", "is" , "isis"}; - -String -Lilypond_key::str () -{ - int key_i = accidentals_i_ >= 0 - ? ((accidentals_i_ % 7) ["cgdaebf"] - 'a' - 2 -2 * minor_i_ + 7) % 7 - : ((-accidentals_i_ % 7) ["cfbeadg"] - 'a' - 2 -2 * minor_i_ + 7) % 7; - - String notename_str = !minor_i_ - ? to_str ((char) ((key_i + 2) % 7 + 'a')) - : to_str ((char) ((key_i + 2) % 7 + 'a')); - - // fis cis gis dis ais eis bis - static int sharps_i_a [7] = { 2, 4, 6, 1, 3, 5, 7 }; - // bes es as des ges ces fes - static int flats_i_a [7] = { 6, 4, 2, 7, 5, 3, 1 }; - int accidentals_i = accidentals_i_ >= 0 - ? sharps_i_a [key_i] <= accidentals_i_ ? 1 : 0 - : flats_i_a [key_i] <= -accidentals_i_ ? -1 : 0; - - if (accidentals_i) - notename_str += String (accname [accidentals_i + 2]); - - return "\\key " + notename_str + (minor_i_ ? "\\minor" : "\\major") + "\n"; -} - -String -Lilypond_key::notename_str (int pitch_i) -{ - // this may seem very smart, - // but it-s only an excuse not to read a notename table - - // major scale: do-do - // minor scale: la-la (= + 5) - static int notename_i_a [12] = { 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6 }; - int notename_i = notename_i_a [pitch_i % 12]; - - static int accidentals_i_a [12] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 }; - int accidental_i = accidentals_i_a [(minor_i_ * 5 + pitch_i) % 12]; - if (accidental_i && (accidentals_i_ < 0)) - { - accidental_i *= -1; - notename_i = (notename_i + 1) % 7; - } - - String notename_str = to_str ((char)(((notename_i + 2) % 7) + 'a')); - if (accidental_i) - notename_str += String (accname [accidental_i + 2]); - - /* - By tradition, all scales now consist of a sequence of 7 notes each - with a distinct name, from amongst a b c d e f g. But, minor scales - have a wide second interval at the top - the 'leading note' is - sharped. (Why? it just works that way! Anything else doesn't sound as - good and isn't as flexible at saying things. In medieval times, - scales only had 6 notes to avoid this problem - the hexachords.) - - So, the d minor scale is d e f g a b-flat c-sharp d - using d-flat - for the leading note would skip the name c and duplicate the name d. - Why isn't c-sharp put in the key signature? Tradition. (It's also - supposedly based on the Pythagorean theory of the cycle of fifths, - but that really only applies to major scales...) - - Anyway, g minor is g a b-flat c d e-flat f-sharp g, and all the other - flat minor keys end up with a natural leading note. And there you - have it. - - John Sankey - - Let's also do a-minor: a b c d e f gis a - - --jcn - - */ - - /* ok, bit ugly, but here we go -- jcn */ - - - if (minor_i_) - { - if ((accidentals_i_ == 0) && (notename_str == "as")) - notename_str = "gis"; - else if ((accidentals_i_ == -1) && (notename_str == "des")) - notename_str = "cis"; - else if ((accidentals_i_ == -2) && (notename_str == "ges")) - notename_str = "fis"; - else if ((accidentals_i_ == 5) && (notename_str == "g")) - notename_str = "fisis"; - else if ((accidentals_i_ == 6) && (notename_str == "d")) - notename_str = "cisis"; - else if ((accidentals_i_ == 7) && (notename_str == "a")) - notename_str = "gisis"; - - if ((accidentals_i_ <= -6) && (notename_str == "b")) - notename_str = "ces"; - if ((accidentals_i_ <= -7) && (notename_str == "e")) - notename_str = "fes"; - } - - String de_octavate_str = to_str (',', (Lilypond_note::c0_pitch_i_c_ + 11 - pitch_i) / 12); - String octavate_str = to_str ('\'', (pitch_i - Lilypond_note::c0_pitch_i_c_) / 12); - return notename_str +de_octavate_str + octavate_str; -} - -Lilypond_time_signature::Lilypond_time_signature (int num_i, int den_i, int clocks_4_i, int count_32_i) - : Lilypond_item (0) -{ - sync_dur_.durlog_i_ = 3; - sync_f_ = 1.0; - if (count_32_i != 8) - warning (_f ("#32 in quarter: %d", count_32_i)); - num_i_ = num_i; - den_i_ = den_i; - clocks_1_i_ = clocks_4_i * 4; -} - -Rational -Lilypond_time_signature::bar_mom () -{ - Duration d; - d.durlog_i_ = den_i_; - return Rational (num_i_) * Duration_convert::dur2_mom (d); -} - -int -Lilypond_time_signature::clocks_1_i () -{ - return clocks_1_i_; -} - -int -Lilypond_time_signature::den_i () -{ - return den_i_; -} - -int -Lilypond_time_signature::num_i () -{ - return num_i_; -} - -String -Lilypond_time_signature::str () -{ - String str = "\\time " - + to_str (num_i_) + "/" + to_str (1 << den_i_) - + "\n"; - return str; -} - - -// statics Lilypond_note -/* - this switch can be used to write simple plets like - c4*2/3 - as - \plet 2/3; c4 \plet 1/1; - */ -/* - UGH: .hh says false, .cc says true. - FIXME. - */ -bool const Lilypond_note::simple_plet_b_s; - -Lilypond_note::Lilypond_note (Lilypond_column* lilypond_column_l, - int channel_i, int pitch_i, int dyn_i) - : Lilypond_item (lilypond_column_l) -{ - // junk dynamics - (void)dyn_i; - channel_i_ = channel_i; - pitch_i_ = pitch_i; - end_column_l_ = 0; -} - -Duration -Lilypond_note::duration () -{ - assert (end_column_l_); - Rational mom = end_column_l_->at_mom () - at_mom (); - return Duration_convert::mom2_dur (mom); -} - -Rational -Lilypond_note::duration_mom () -{ - assert (end_column_l_); - return end_column_l_->at_mom () - at_mom (); -} - -String -Lilypond_note::str () -{ - Duration dur = duration (); - if (dur.durlog_i_ < -10) - return ""; - - String name_str - = lilypond_column_l_->lilypond_score_l_->lilypond_key_l_->notename_str (pitch_i_); - - if (simple_plet_b_s) - return name_str + Duration_convert::dur2_str (dur) + " "; - - String str; - - //ugh - if (dur.plet_b () && dur.plet_.type_i_ != 1) - { - { - str += String ("\\times ") - + String_convert::i2dec_str (dur.plet_.iso_i_, 0, 0) - + "/" - + String_convert::i2dec_str (dur.plet_.type_i_, 0, 0) - + " { "; - } - } - - str += name_str; - - Duration tmp = dur; - tmp.set_plet (1,1); - str += Duration_convert::dur2_str (tmp); - - if (dur.plet_b ()) - { - if (dur.plet_.type_i_ != 1) - str += String (" }"); - else - str += String ("*") + to_str (dur.plet_.iso_i_); - } - - /* - note of zero duration is nonsense, - but let's output anyway for convenient debugging - */ - if (!duration_mom ()) - return String ("\n% ") + str + "\n"; - - return str + " "; -} - -Lilypond_skip::Lilypond_skip (Lilypond_column* lilypond_column_l, Rational skip_mom) - : Lilypond_item (lilypond_column_l) -{ - mom_ = skip_mom; -} - -Duration -Lilypond_skip::duration () -{ - return Duration_convert::mom2_dur (mom_); -} - -Rational -Lilypond_skip::duration_mom () -{ - return Duration_convert::dur2_mom (duration ()); -} - -String -Lilypond_skip::str () -{ - String str; - Rational m = mom_; - if (m.to_int () >= 1) - { - int n = m.to_int (); - str += "\\skip 1"; - if (n > 1) - { - str += "*"; - str += to_str (n); - } - str += " "; - m -= n; - } - - if (m > Rational (0)) - { - - Duration dur = Duration_convert::mom2_dur (m); - str += "\\skip "; - str += Duration_convert::dur2_str (dur); - str += " "; - } - return str; -} - -Lilypond_tempo::Lilypond_tempo (int useconds_per_4_i) - : Lilypond_item (0) -{ - useconds_per_4_i_ = useconds_per_4_i; - seconds_per_1_mom_ = Rational(useconds_per_4_i_ *4, 1e6); -} - -String -Lilypond_tempo::str () -{ - String str = "\\tempo 4="; - str += to_str (get_tempo_i (Rational (1, 4))); - str += "\n"; - return str; -} - -int -Lilypond_tempo::useconds_per_4_i () -{ - return useconds_per_4_i_; -} - -int -Lilypond_tempo::get_tempo_i (Rational rational) -{ - Rational m1 = Rational (60) / rational; - Rational m2 = seconds_per_1_mom_; - return m1 / m2; -} - -Lilypond_text::Lilypond_text (Lilypond_text::Type type, String text_str) - : Lilypond_item (0) -{ - type_ = type; - text_str_ = text_str; -} - -String -Lilypond_text::str () -{ - if (!text_str_.length_i () - || (text_str_.length_i () != (int)strlen (text_str_.ch_C ()))) - return ""; - - return "% " + text_str_ + "\n"; -} diff --git a/midi2ly/lilypond-score.cc b/midi2ly/lilypond-score.cc deleted file mode 100644 index 363a0e7bf7..0000000000 --- a/midi2ly/lilypond-score.cc +++ /dev/null @@ -1,256 +0,0 @@ -// -// lilypond-score.cc -- implement Lilypond_score -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#include -#include "rational.hh" -#include "duration.hh" -#include "duration-convert.hh" -#include "midi2ly-global.hh" -#include "lilypond-column.hh" -#include "lilypond-item.hh" -#include "lilypond-score.hh" -#include "lilypond-staff.hh" -#include "lilypond-stream.hh" - -#include "killing-cons.tcc" - -//static Lilypond_key key_c (0, 0); -static Lilypond_time_signature time_sig_4 (4, 2, 24, 8); -// useconds per 4: 250000 === 60 4 per minute -static Lilypond_tempo tempo_60 (1000000); - -Lilypond_score::Lilypond_score (int format_i, int tracks_i, int tempo_i) -{ - last_staff_l_ =0; - format_i_ = format_i; - tracks_i_ = tracks_i; - tempo_i_ = tempo_i; - column_l_array_.push (new Lilypond_column (this, Rational (0))); - // lilypond_key_l_ = &key_c; - lilypond_key_l_ = 0; - lilypond_time_signature_l_ = &time_sig_4; - lilypond_tempo_l_ = &tempo_60; -} - -Lilypond_score::~Lilypond_score () -{ -} - -void -Lilypond_score::add_item (Lilypond_item* lilypond_item_p) -{ - last_staff_l_->add_item (lilypond_item_p); -} - -void -Lilypond_score::add_staff (Lilypond_staff* lilypond_staff_p) -{ - lilypond_staff_p_list_.append (new Killing_cons (lilypond_staff_p, 0)); - last_staff_l_ = lilypond_staff_p; -} - -Lilypond_column* -Lilypond_score::find_column_l (Rational mom) -{ - int upper_i = max (0, column_l_array_.size () - 1); - int lower_i = 0; - int i = 0; //upper_i; - while (1) - { - Rational i_mom = column_l_array_ [i]->at_mom (); - if (i_mom == mom) - return column_l_array_ [i]; - if (mom < i_mom) - upper_i = i; - else - lower_i = i; - if ( (upper_i == lower_i) || (i == column_l_array_.size () - 1)) - { - // we don't do inserts - assert (0); - Lilypond_column* col_p = new Lilypond_column (this, mom); - column_l_array_.push (col_p); - return col_p; - } - i = (upper_i + lower_i + 1 ) / 2; - } - assert (0); - return 0; -} - -Lilypond_column* -Lilypond_score::get_column_l (Rational mom) -{ - int i; - Lilypond_column *c=0; - for (i=column_l_array_.size () - 1; !c && i >=0; i--) - { - if (column_l_array_ [i]->at_mom () == mom ) - c = column_l_array_[i]; - else if (column_l_array_[i]->at_mom () < mom) - break; - } - if (!c) - { - c = new Lilypond_column (this, mom); - column_l_array_.insert (c, i+1); - } - - assert (c->at_mom () == mom); - return c; -} - -void -Lilypond_score::output (String filename_str) -{ - LOGOUT (NORMAL_ver) << _f ("LY output to `%s'...", filename_str) << endl; - - // ugh, ugly midi type 1 fix - if ( (lilypond_staff_p_list_.size_i () == 1) - && !lilypond_staff_p_list_.head_->car_->number_i_) - lilypond_staff_p_list_.head_->car_->number_i_ = 1; - - int track_i = 0; - Lilypond_stream lilypond_stream (filename_str); - for (Cons* i = lilypond_staff_p_list_.head_; i; i = i->next_) - { - LOGOUT (NORMAL_ver) << _f ("track %d:", track_i++) << flush; - i->car_->output (lilypond_stream); - lilypond_stream << '\n'; - LOGOUT (NORMAL_ver) << endl; - } - - lilypond_stream << "\\score{\n"; - if (lilypond_staff_p_list_.size_i () > 1) - lilypond_stream << "< \n"; - for (Cons* i = lilypond_staff_p_list_.head_; i; i = i->next_) - { - if ( (lilypond_staff_p_list_.size_i () != 1) - && (i->car_ == lilypond_staff_p_list_.head_->car_)) - continue; - lilypond_stream << "\\context Staff = \"" << i->car_->id_str () << "\" "; - lilypond_stream << String ("\\" + i->car_->id_str ()) << '\n'; - } - if (lilypond_staff_p_list_.size_i () > 1) - lilypond_stream << ">\n"; - - lilypond_stream << "\\paper{}\n"; - -#if 1 - lilypond_stream << "\\midi{\n"; - - // let's not use silly 0 track - last_cons (lilypond_staff_p_list_.head_)->car_->lilypond_tempo_l_->output (lilypond_stream); - lilypond_stream << "}\n"; -#endif - - lilypond_stream << "}\n"; -} - -void -Lilypond_score::process () -{ - LOGOUT (NORMAL_ver) << '\n' << _ ("Processing...") << endl; - - LOGOUT (DEBUG_ver) << "columns\n"; - - settle_columns (); - filter_tempo (); - quantify_columns (); - quantify_durations (); - - LOGOUT (NORMAL_ver) << '\n' << _ ("Creating voices...") << endl; - int track_i = 0; - for (Cons* i = lilypond_staff_p_list_.head_; i; i = i->next_) - { - LOGOUT (NORMAL_ver) << _ ("track ") << track_i++ << ": " << flush; - i->car_->process (); - LOGOUT (NORMAL_ver) << endl; - } -} - -void -Lilypond_score::filter_tempo () -{ - LOGOUT (NORMAL_ver) << '\n' << _ ("NOT Filtering tempo...") << endl; -} - -void -Lilypond_score::quantify_columns () -{ - // ugh - if (Duration_convert::no_quantify_b_s) - { - LOGOUT (NORMAL_ver) << '\n' << _ ("NOT Quantifying columns...") << endl; - return; - } - - LOGOUT (NORMAL_ver) << '\n' << _ ("Quantifying columns...") << endl; - - int current_bar_i = 0; - Rational bar_mom = lilypond_time_signature_l_->bar_mom (); - - int n = 7 >? Duration_convert::no_smaller_than_i_s; - n = Duration_convert::type2_i (n); - Rational s = Rational (1, n); - for (int i = 0; i < column_l_array_.size (); i++) - { - column_l_array_ [i]->at_mom_ = - s * Rational ( (int) ( (column_l_array_ [i]->at_mom ()) / s)); - - int bar_i = (int) (column_l_array_ [i]->at_mom () / bar_mom) + 1; - if (bar_i > current_bar_i) - - { - LOGOUT (NORMAL_ver) << "[" << bar_i << "]" << flush; - current_bar_i = bar_i; - } - } - LOGOUT (NORMAL_ver) << endl; -} - -void -Lilypond_score::quantify_durations () -{ - -} - -void -Lilypond_score::settle_columns () -{ - LOGOUT (NORMAL_ver) << '\n' << _ ("Settling columns...") << endl; - - int n = column_l_array_.size (); - - int start_i = 0; - int end_i = 0; - Rational start_mom = 0; - - Duration smallest_dur; - smallest_dur.durlog_i_ = 6; - Rational const noise_mom = Duration_convert::dur2_mom (smallest_dur) - / Rational (2); - for (int i = 0; i < n; i++) - { - if (!start_i) - { - start_i = end_i = i; - start_mom = column_l_array_ [i]->at_mom (); - continue; - } - - // find all columns within noise's distance - while ( (i < n) - && (column_l_array_ [i]->at_mom () - start_mom < noise_mom)) - end_i = ++i; - - // bluntly set all to time of first in group - for (int j = start_i; j < end_i; j++) - column_l_array_ [j]->at_mom_ = start_mom; - - start_i = end_i = 0; - } -} - diff --git a/midi2ly/lilypond-staff.cc b/midi2ly/lilypond-staff.cc deleted file mode 100644 index 481bc38417..0000000000 --- a/midi2ly/lilypond-staff.cc +++ /dev/null @@ -1,184 +0,0 @@ -// -// lilypond-staff.cc -- implement Lilypond_staff -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#include -#include -#include "rational.hh" -#include "duration-convert.hh" -#include "string-convert.hh" -#include "midi2ly-proto.hh" -#include "midi2ly-global.hh" -#include "lilypond-column.hh" -#include "lilypond-item.hh" -#include "lilypond-staff.hh" -#include "lilypond-stream.hh" -#include "lilypond-voice.hh" -#include "lilypond-score.hh" - -#include "killing-cons.tcc" - -extern Lilypond_score* lilypond_score_l_g; - -Lilypond_staff::Lilypond_staff (int number_i, String copyright_str, String track_name_str, String instrument_str) -{ - number_i_ = number_i; - copyright_str_ = copyright_str; - instrument_str_ = instrument_str; - name_str_ = track_name_str; - lilypond_key_l_ = 0; - lilypond_time_signature_l_ = 0; - lilypond_tempo_l_ = 0; -} - -void -Lilypond_staff::add_item (Lilypond_item* lilypond_item_p) -{ - lilypond_item_p_list_.append (new Killing_cons (lilypond_item_p, 0)); - if (lilypond_item_p->lilypond_column_l_) - lilypond_item_p->lilypond_column_l_->add_item (lilypond_item_p); -} -/** - Walk ITEMS and find voices. Remove categorised items. - - TODO: - - * collect all channels into separate voices. Use chords for sim - notes on same channel. - * assume voices/assume chords modes. - - */ -void -Lilypond_staff::eat_voice (Cons_list& items) -{ - Lilypond_voice* voice_p = new Lilypond_voice (this); - lilypond_voice_p_list_.append (new Killing_cons (voice_p, 0)); - - Rational mom = 0; - - Link_array now_items; - for (Cons** i = &items.head_; *i;) - { - while (*i && (*i)->car_->at_mom () < mom) - i = &(*i)->next_; - - Lilypond_note* last_note = 0; - Link_array now_items; - if (*i) - mom = (*i)->car_->at_mom (); - while (*i && (*i)->car_->at_mom () == mom) - { - Lilypond_note* note = dynamic_cast ((*i)->car_); - if (note && last_note - /* ugh, should sort out (whether to) channel before */ - && (note->channel_i_ != last_note->channel_i_ - || (note->duration_mom () - != last_note->duration_mom ()))) - break; - Cons* c = items.remove_cons (i); - now_items.push (c->car_); - if (note) - last_note = note; - delete c; - } - - if (now_items.size ()) - mom = now_items.top ()->at_mom (); - if (last_note) - mom += last_note->duration_mom (); - - voice_p->add_items (now_items); - } -} - -String -Lilypond_staff::id_str () -{ - String id (name_str ()); - char *cp = id.ch_l (); - char *end = cp + id.length_i (); - for (;cp < end; cp++) - { - if (!isalpha (*cp)) - { - *cp = 'X'; - } - } - return id; -} - -String -Lilypond_staff::name_str () -{ - if (name_str_.length_i ()) - return name_str_; - return String ("track") + to_str (char ('A' - 1 + number_i_)); -} - - - -void -Lilypond_staff::output (Lilypond_stream& lilypond_stream_r) -{ - int c =0; - - String trackbody = ""; - for (Cons* i = lilypond_voice_p_list_.head_; i; i = i->next_) - { - String voicename = id_str () + "voice" + to_str (char (c + 'A')); - - lilypond_stream_r << voicename << " = \\notes "; - - trackbody += "\\context Voice = " + voicename + " \\" + voicename + "\n"; - lilypond_stream_r << '\n'; - i->car_->output (lilypond_stream_r); - c++; - lilypond_stream_r << '\n'; - } - - lilypond_stream_r << '\n'; - lilypond_stream_r << _ ("% MIDI copyright:") << copyright_str_ << '\n'; - lilypond_stream_r << _ ("% MIDI instrument:") << instrument_str_ << '\n'; - lilypond_stream_r << id_str () << " = "; - lilypond_stream_r << "<\n" << trackbody << ">\n"; - - lilypond_stream_r << " % " << name_str () << '\n'; -} - -void -Lilypond_staff::output_lilypond_begin_bar (Lilypond_stream& lilypond_stream_r, Rational now_mom, int bar_i) -{ - Rational bar_mom = lilypond_time_signature_l_->bar_mom (); - Rational into_bar_mom = now_mom - Rational (bar_i - 1) * bar_mom; - if (bar_i > 1) - { - if (!into_bar_mom) - lilypond_stream_r << "|\n"; - } - lilypond_stream_r << "% " << String_convert::i2dec_str (bar_i, 0, ' '); - if (into_bar_mom) - lilypond_stream_r << ":" << Duration_convert::dur2_str (Duration_convert::mom2_dur (into_bar_mom)); - lilypond_stream_r << '\n'; -} - - -void -Lilypond_staff::process () -{ - /* - group items into voices - */ - - assert (lilypond_score_l_g); - lilypond_key_l_ = lilypond_score_l_g->lilypond_key_l_; - lilypond_time_signature_l_ = lilypond_score_l_g->lilypond_time_signature_l_; - lilypond_tempo_l_ = lilypond_score_l_g->lilypond_tempo_l_; - - Cons_list items; - for (Cons* i = lilypond_item_p_list_.head_; i; i = i->next_) - items.append (new Cons (i->car_, 0)); - - while (items.size_i ()) - eat_voice (items); -} diff --git a/midi2ly/lilypond-stream.cc b/midi2ly/lilypond-stream.cc deleted file mode 100644 index 1f476649a6..0000000000 --- a/midi2ly/lilypond-stream.cc +++ /dev/null @@ -1,192 +0,0 @@ -// -// lilypond-stream.cc -// -// source file of the LilyPond music typesetter -// -// (c) 1997--1998, 1998 Jan Nieuwenhuizen - -#include -#include -#include -#include "midi2ly-global.hh" -#include "lilypond-item.hh" -#include "lilypond-stream.hh" -#include "string-convert.hh" - -extern String filename_str_g; - -static int const INDENT_i = 8; - -Lilypond_stream::Lilypond_stream (String filename_str) -{ - filename_str_ = filename_str; - pending_indent_i_ = 0; - os_p_ = 0; - indent_i_ = 0; - comment_mode_b_ = false; - column_i_ = 0; - wrap_column_i_ = 68; - open(); - header(); -} - -Lilypond_stream::~Lilypond_stream () -{ - delete os_p_; - if (indent_i_) - warning (_f ("lily indent level: %d", indent_i_)); -} - -Lilypond_stream& -Lilypond_stream::operator << (char c) -{ - *this << to_str (c); - return *this; -} - -Lilypond_stream& -Lilypond_stream::operator << (String s) -{ - static String word_sep_str = "{} \t\n"; - while (s.length_i()) - { - int i = s.index_any_i (word_sep_str) + 1; - if (!i) - i = s.length_i(); - String word = s.left_str (i); - s = s.cut_str (i, s.length_i()); - output_wrapped (word); - } - return *this; -} - -Lilypond_stream& -Lilypond_stream::operator << (Lilypond_item& lilypond_item_r) -{ - lilypond_item_r.output (*this); - *os_p_ << flush; - return *this; -} - -void -Lilypond_stream::handle_pending_indent() -{ - *os_p_ << String_convert::char_str ('\t', pending_indent_i_); - column_i_ += pending_indent_i_ * INDENT_i; - pending_indent_i_ = 0; -} - -void -Lilypond_stream::header() -{ - /* Maybe better not to translate these? */ - *os_p_ << _ ("% Creator: "); - if (no_timestamps_b_g) - *os_p_ << "GNU LilyPond\n"; - else - *os_p_ << midi2ly_version_str() << '\n'; - *os_p_ << _ ("% Automatically generated"); - if (no_timestamps_b_g) - *os_p_ << ".\n"; - else - { - *os_p_ << _ (", at "); - time_t t (time (0)); - *os_p_ << ctime (&t) << "%\n"; - } - *os_p_ << _ ("% from input file: "); - // *os_p_ << midi_parser_l_g->filename_str_; - // ugh - *os_p_ << filename_str_g; - *os_p_ << "\n\n"; - // ugh - *os_p_ << "\\version \"1.4.0\"\n"; -} - -void -Lilypond_stream::open() -{ - os_p_ = new ofstream (filename_str_.ch_C ()); - if (!*os_p_) - error (_f ("can't open file: `%s'", filename_str_)); -} - -void -Lilypond_stream::output (String str) -{ - for (int i = 0; i < str.length_i(); i++) - { - char c = str[ i ]; - switch (c) - { - case '{' : - case '<' : - handle_pending_indent(); - if (column_i_ == indent_i_ * INDENT_i) - output ("\t"); - indent_i_++; - *os_p_ << c; - column_i_++; - break; - case '}' : - case '>' : - assert (indent_i_); - indent_i_--; - if (pending_indent_i_) - pending_indent_i_--; - handle_pending_indent(); - *os_p_ << c; - column_i_++; - break; - case '%' : - handle_pending_indent(); - comment_mode_b_ = true; - *os_p_ << c; - column_i_++; - break; - case '\t' : - handle_pending_indent(); - *os_p_ << c; - column_i_ += INDENT_i; - break; - case '\n' : - *os_p_ << endl; - pending_indent_i_ = indent_i_; - column_i_ = 0; - comment_mode_b_ = false; - break; - default : - handle_pending_indent(); - *os_p_ << c; - column_i_++; - break; - } - } -} - -void -Lilypond_stream::output_wrapped (String str) -{ - // enough room left -> doit - if (column_i_ + str.length_i() <= wrap_column_i_) - { - output (str); - return; - } - - // we're at BOL already; this will never fit -> doit - if (column_i_ == indent_i_ * INDENT_i) - { - output (str); - return; - } - - // ok, let's wrap - // preserve comment mode - if (comment_mode_b_) - output (String ("\n%")); - else - output (String ("\n")); - - output (str); -} diff --git a/midi2ly/lilypond-voice.cc b/midi2ly/lilypond-voice.cc deleted file mode 100644 index a19eec0378..0000000000 --- a/midi2ly/lilypond-voice.cc +++ /dev/null @@ -1,151 +0,0 @@ -// -// lilypond-voice.cc -- implement Lilypond_voice -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#include "string-convert.hh" -#include "midi2ly-global.hh" -#include "lilypond-column.hh" -#include "lilypond-item.hh" -#include "lilypond-staff.hh" -#include "lilypond-stream.hh" -#include "lilypond-voice.hh" -#include "lilypond-score.hh" - -extern Lilypond_score* lilypond_score_l_g; - -Lilypond_voice::Lilypond_voice (Lilypond_staff* lilypond_staff_l) -{ - lilypond_staff_l_ = lilypond_staff_l; - threads_.push (new Cons_list); - mom_ = 0; -} - -void -Lilypond_voice::add_items (Link_array& items) -{ - int thread = 0; - for (int i = 0; i < items.size (); i++) - { - Lilypond_item* item = items[i]; - - int to_thread; - if (Lilypond_note* n = dynamic_cast (item)) - to_thread = thread++; - else - to_thread = 0; - - if (to_thread >= threads_.size ()) - threads_.push (new Cons_list); - - if (to_thread == 0 && item->at_mom () > mom_) - { - /* urg: skip should use refer to end-colum, not separate moment */ - Rational r = item->at_mom () - mom_; - Lilypond_column* start = lilypond_score_l_g->find_column_l (mom_); - threads_[to_thread]->append (new Cons (new Lilypond_skip (start, r), 0)); - mom_ = item->at_mom (); - } - - threads_[to_thread]->append (new Cons (item, 0)); - if (to_thread == 0) - mom_ += item->duration_mom (); - } -} - -/** - analyse pitches to determine clef. - */ -String -Lilypond_voice::get_clef () const -{ - Lilypond_note * n =0; - - for (Cons *cp = threads_[0]->head_; !n && cp; cp = cp->next_) - { - n = dynamic_cast (cp->car_); - } - - if (!n) - return ""; - - int p = n->pitch_i_; - - if (p < 56) - return "\\clef \"bass\"\n"; - else if (p > 67) - return "\\clef \"treble\"\n"; - else - return ""; -} - -static int const FAIRLY_LONG_VOICE_i = 6; - -void -Lilypond_voice::output (Lilypond_stream& lilypond_stream_r) -{ - lilypond_stream_r << "{ "; - if (threads_[0]->size_i () > FAIRLY_LONG_VOICE_i) - lilypond_stream_r << '\n'; - - - lilypond_stream_r << get_clef () << '\n'; - - int current_bar_i = 0; - Rational bar_mom = lilypond_staff_l_->lilypond_time_signature_l_->bar_mom (); - - Link_array > heads; - for (int i = 1; i < threads_.size (); i++) - heads.push (threads_[i]->head_); - for (Cons* i = threads_[0]->head_; i; i = i->next_) - { - Rational at_mom = i->car_->lilypond_column_l_->at_mom (); - int bar_i = (int) (at_mom / bar_mom) + 1; - if (bar_i > current_bar_i) - { - if (current_bar_i) - { - if (at_mom == Rational (bar_i - 1) * bar_mom) - lilypond_stream_r << "|"; - lilypond_stream_r << "\n% "; - lilypond_stream_r << String_convert::i2dec_str (bar_i, 0, ' '); - lilypond_stream_r << '\n'; - } - LOGOUT (NORMAL_ver) << "[" << bar_i << "]" << flush; - current_bar_i = bar_i; - } - - if (dynamic_cast (i->car_) - && heads.size () - && heads[0] - && heads[0]->car_->at_mom () == at_mom) - { - lilypond_stream_r << '<'; - - lilypond_stream_r << *i->car_; - - for (int h = 0; - h < heads.size () - && heads[h] - && heads[h]->car_->at_mom () == at_mom; - h++) - { - lilypond_stream_r << *heads[h]->car_; - heads[h] = heads[h]->next_; - } - lilypond_stream_r << '>'; - } - else - lilypond_stream_r << *i->car_; - - if (Lilypond_key* k = dynamic_cast (i->car_)) - lilypond_staff_l_->lilypond_key_l_ = lilypond_score_l_g->lilypond_key_l_ = k; - } - - if (threads_[0]->size_i () > FAIRLY_LONG_VOICE_i) - lilypond_stream_r << '\n'; - - lilypond_stream_r << "} "; -} - - diff --git a/midi2ly/main.cc b/midi2ly/main.cc deleted file mode 100644 index a1a0665539..0000000000 --- a/midi2ly/main.cc +++ /dev/null @@ -1,280 +0,0 @@ -// -// main.cc -- implement main () entry point -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#include -#include -#include -#include -#include "config.h" -#include "string-convert.hh" -#include "getopt-long.hh" -#include "file-path.hh" -#include "duration-convert.hh" -#include "source.hh" - -#include "midi2ly-global.hh" -#include "midi-score-parser.hh" -#include "lilypond-item.hh" -#include "lilypond-score.hh" - -#if HAVE_GETTEXT -#include -#endif - -bool testing_level_global; - -// ugh -String filename_str_g; - -// ugh -Lilypond_score* lilypond_score_l_g = 0; - -bool no_timestamps_b_g = false; -bool no_rests_b_g = false; - -Sources source; - -static File_path path; - -Verbose level_ver = NORMAL_ver; - - -void -identify() -{ -cout << midi2ly_version_str() << endl; - -} - -void -version () -{ - identify (); - cout << '\n'; - cout << _f ("" - "This is free software. It is covered by the GNU General Public License,\n" - "and you are welcome to change it and/or distribute copies of it under\n" - "certain conditions. Invoke as `%s --warranty' for more information.\n", - "midi2ly"); - cout << endl; - - cout << _f ("Copyright (c) %s by", "1996--2001"); - cout << "Han-Wen Nienhuys \n" - << "Jan Nieuwenhuizen \n"; -} - -void -notice() -{ - cout << _ ( - " This program is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU General Public License version 2\n" - "as published by the Free Software Foundation.\n" - "\n" - " This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - "General Public License for more details.\n" - "\n" - " You should have received a copy (refer to the file COPYING) of the\n" - "GNU General Public License along with this program; if not, write to\n" - "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n" - "USA.\n"); -} - -/* - Internationalisation kludge in two steps: - * use _i () to get entry in POT file - * call gettext () explicitely for actual "translation" - */ -Long_option_init long_option_init_a[] = -{ - {0, "no-quantify", 'b', _i ("write exact durations, e.g.: a4*385/384")}, - {0, "debug", 'd', _i ("enable debugging output")}, - {0, "help", 'h', _i ("this help")}, - {_i ("ACC[:MINOR]"), "key", 'k', _i ("set key: ACC +sharps/-flats; :1 minor")}, - {0, "no-silly", 'n', _i ("don't output tuplets, double dots or rests, smallest is 32")}, - {_i ("FILE"), "output", 'o', _i ("set FILE as default output")}, - {0, "no-tuplets", 'p', _i ("don't output tuplets")}, - {0, "quiet", 'q', _i ("be quiet")}, - {0, "no-rests", 'r', _i ("don't output rests or skips")}, - {_i ("DUR"), "smallest", 's', _i ("set smallest duration")}, - {0, "no-timestamps", 'T', _i ("don't timestamp the output")}, - {0, "version", 'V', _i ("print version number")}, - {0, "verbose", 'v', _i ("be verbose")}, - {0, "warranty", 'w', _i ("show warranty and copyright")}, - {0, "no-double-dots", 'x', _i ("assume no double dotted notes")}, - {0,0,0, 0} -}; - -void -usage() -{ - cout << _f ("Usage: %s [OPTION]... [FILE]", "midi2ly"); - cout << '\n'; - cout << _ ("Translate MIDI-file to lilypond"); - cout << '\n'; - cout << '\n'; - cout << _ ("Options:"); - cout << '\n'; - cout << Long_option_init::table_str (long_option_init_a) << endl; - - cout << _f ("Report bugs to %s", "bug-gnu-music@gnu.org") << endl; -} - -void -show_settings () -{ - LOGOUT (VERBOSE_ver) << "\n"; - LOGOUT (VERBOSE_ver) << _f ("no_double_dots: %d\n", - Duration_convert::no_double_dots_b_s); - LOGOUT (VERBOSE_ver) << _f ("no_rests: %d\n", - no_rests_b_g); - LOGOUT (VERBOSE_ver) << _f ("no_quantify_b_s: %d\n", - Duration_convert::no_quantify_b_s); - LOGOUT (VERBOSE_ver) << _f ("no_smaller_than: %d (1/%d)\n", - Duration_convert::no_smaller_than_i_s, - Duration_convert::type2_i (Duration_convert::no_smaller_than_i_s)); - LOGOUT (VERBOSE_ver) << _f ("no_tuplets: %d\n", - Duration_convert::no_tuplets_b_s); -} - -int -main (int argc_i, char* argv_sz_a[]) -{ - -#if HAVE_GETTEXT - setlocale (LC_ALL, ""); /* enable locales */ - setlocale (LC_NUMERIC, "C"); /* musn't have comma's in output */ - String name (PACKAGE); - name.to_lower (); - bindtextdomain (name.ch_C (), DIR_LOCALEDIR); - textdomain (name.ch_C ()) ; -#endif - - bool key_override_b = false; - Lilypond_key key (0, 0); - - - Getopt_long getopt_long (argc_i, argv_sz_a, long_option_init_a); - - String output_str; - while (Long_option_init const* long_option_init_p = getopt_long()) - switch (long_option_init_p->shortname_ch_) - { - case 'b': - Duration_convert::no_quantify_b_s = true; - break; - case 'd': - level_ver = DEBUG_ver; - break; - case 'h': - usage(); - exit (0); - break; - // case 'I': - // path->push (getopt_long.optional_argument_ch_C_); - // break; - case 'k': - { - String str = getopt_long.optional_argument_ch_C_; - int i = str.index_i (':'); - i = (i >=0 ? i : str.length_i ()); - key.accidentals_i_ = String_convert::dec2_i (str.left_str (i)); - key.minor_i_ = (int)(bool)String_convert::dec2_i (str.cut_str (i + 1, str.length_i ())); - key_override_b = true; - break; - } - case 'n': - Duration_convert::no_double_dots_b_s = true; - Duration_convert::no_tuplets_b_s = true; - Duration_convert::no_smaller_than_i_s = 5; - no_rests_b_g = true; - break; - case 'o': - output_str = getopt_long.optional_argument_ch_C_; - break; - case 'p': - Duration_convert::no_tuplets_b_s = true; - break; - case 'q': - level_ver = QUIET_ver; - break; - case 'r': - no_rests_b_g = true; - break; - case 'T': - no_timestamps_b_g = true; - break; - case 's': - { - int i = String_convert::dec2_i (getopt_long.optional_argument_ch_C_); - if (!i) - { - identify(); - usage(); - exit (2); //usage - } - Duration_convert::no_smaller_than_i_s = - Duration_convert::i2_type(i); - } - break; - case 'v': - level_ver = VERBOSE_ver; - break; - - case 'V': - version (); - exit (0); - break; - case 'w': - identify(); - notice(); - exit (0); - break; - case 'x': - Duration_convert::no_double_dots_b_s = true; - break; - default: - assert (0); - break; - } - - // flag -q must be checked first - identify(); - - path.add (""); - source.set_binary (true); - source.set_path (&path); - - char const* arg_sz = 0; - while ( (arg_sz = getopt_long.get_next_arg ())) - { - show_settings (); - filename_str_g = arg_sz; - Midi_score_parser midi_parser; - Lilypond_score* score_p = midi_parser.parse (arg_sz, &source); - - if (!score_p) - return 1; - - // if given on command line: override - if (key_override_b || !score_p->lilypond_key_l_) - score_p->lilypond_key_l_ = &key; - lilypond_score_l_g = score_p; - score_p->process(); - - if (!output_str.length_i ()) - { - Path p = split_path (arg_sz); - - output_str = p.base + p.ext + ".ly"; - } - - score_p->output (output_str); - delete score_p; - } - return 0; -} diff --git a/midi2ly/midi-parser.cc b/midi2ly/midi-parser.cc deleted file mode 100644 index ed9c5a49e3..0000000000 --- a/midi2ly/midi-parser.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* - midi-parser.cc -- implement Midi_parser[_info] - - source file of the GNU LilyPond music typesetter - - (c) 1997--1998 Jan Nieuwenhuizen -*/ - -#include -#include "string-convert.hh" -#include "source-file.hh" -#include "midi2ly-global.hh" -#include "midi-parser.hh" - -Midi_parser_info::Midi_parser_info () -{ - division_1_i_ = 0; - format_i_ = 0; - tracks_i_ = 0; - errorlevel_i_ = 0; - byte_L_ = 0; - end_byte_L_ = 0; - score_l_ = 0; -} - -Midi_parser::Midi_parser () -{ - info_l_ = 0; -} - -int -Midi_parser::exit (String str) -{ - error (str); - ::exit (1); - return 0; -} - -void -Midi_parser::error (String str) -{ - ::message (message (str)); -} - -int -Midi_parser::get_i (int n) -{ - assert (n <= (int)sizeof(int)); - return String_convert::bin2_i (get_str (n)); -} - -unsigned -Midi_parser::get_u (int n) -{ - assert (n <= (int)sizeof(int)); - return String_convert::bin2_u (get_str (n)); -} - -String -Midi_parser::get_str (int n) -{ - assert (n >= 0); - if (!n) - warning (_ ("zero length string encountered")); - - Byte const* p = forward_byte_L (n); - return String (p, n); -} - -int -Midi_parser::get_var_i () -{ - int var_i = 0; - - while (1) - { - Byte byte = next_byte (); - var_i <<= 7; - var_i += byte & 0x7f; - if (!(byte & 0x80)) - return var_i; - } - exit ("get_var_i:"); - return 0; -} - -String -Midi_parser::message (String str) -{ - return String ("midi2ly: ") - + info_l_->source_l_->name_str () + ": " - + String_convert::i2dec_str (info_l_->source_l_->line_i ((char const*)info_l_->byte_L_), 0, 0) + ": " - + str + "\n" - + info_l_->source_l_->error_str ((char const*)info_l_->byte_L_); -} - -void -Midi_parser::warning (String str) -{ - ::message (message (String (_ ("warning: ")) + str)); -} diff --git a/midi2ly/midi-score-parser.cc b/midi2ly/midi-score-parser.cc deleted file mode 100644 index a09f28fce4..0000000000 --- a/midi2ly/midi-score-parser.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - midi-score-parser.cc -- implement - - source file of the GNU LilyPond music typesetter - - (c) 1997--1998 Jan Nieuwenhuizen -*/ - -#include "rational.hh" -#include "source-file.hh" -#include "source.hh" -#include "midi2ly-global.hh" -#include "midi-score-parser.hh" -#include "midi-track-parser.hh" -#include "lilypond-item.hh" -#include "lilypond-score.hh" - - -void -Midi_score_parser::open (String filename_str, Sources* sources_l) -{ - info_l_->source_l_ = sources_l->get_file_l (filename_str); - if (!info_l_->source_l_) - ::error (_f ("can't find file: `%s'", filename_str)); - info_l_->byte_L_ = (Byte const*)info_l_->source_l_->ch_C (); - info_l_->end_byte_L_ = info_l_->byte_L_ + info_l_->source_l_->length_i () + 1; -} - -Lilypond_score* -Midi_score_parser::parse (String filename_str, Sources* sources_l) -{ - Midi_parser_info info; - info_l_ = &info; - open (filename_str, sources_l); - parse_header (); - return parse_score (); -} - -void -Midi_score_parser::parse_header () -{ - String str = get_str (4); - if ( str != "MThd" ) - exit (_ ("MIDI header expected")); - - int length_i = get_i (4); - // is this signed? - if (length_i < 6) - exit (_ ("invalid header length")); - info_l_->format_i_ = get_i (2); - if (info_l_->format_i_ != 0 && info_l_->format_i_ != 1) - exit (_("invalid MIDI format")); - info_l_->tracks_i_ = get_i (2); - if (info_l_->tracks_i_ < 0 || info_l_->tracks_i_ > 32 ) - exit (_("invalid number of tracks")); - info_l_->division_1_i_ = get_i (2) * 4; - if (info_l_->division_1_i_ < 0) - exit (_ ("can't handle non-metrical time")); - // ugh - Duration::division_1_i_s = info_l_->division_1_i_; - forward_byte_L (length_i - 6); -} - -int -Midi_score_parser::find_earliest_i (Link_array& tracks) -{ - int earliest_i = 0; - Rational earliest_mom = infinity_rat; - for (int i = 0; i < tracks.size(); i++) - { - if ( tracks [i]->at_mom () < earliest_mom ) - { - earliest_mom = tracks [i]->at_mom (); - earliest_i = i; - } - } - return earliest_i; -} - -Lilypond_score* -Midi_score_parser::parse_score () -{ - int current_bar_i = 0; - Lilypond_time_signature m4 (4, 2, 24, 8); - Rational bar4_mom = m4.bar_mom (); - - Lilypond_score* score_p = new Lilypond_score( 1, 1, 1 ); - info_l_->score_l_ = score_p; - - Link_array tracks; - for (int i = 0; i < info_l_->tracks_i_; i++) - tracks.push (new Midi_track_parser (info_l_, i)); - - LOGOUT (NORMAL_ver) << _ ("Parsing..."); - LOGOUT (NORMAL_ver) << "\n"; - while (tracks.size ()) - { - int i = find_earliest_i (tracks); - Rational at_mom = tracks [i]->at_mom (); - Lilypond_column* column_l = score_p->get_column_l (at_mom); - Lilypond_staff* staff_p = tracks [i]->parse (column_l); - if ( staff_p ) - { - score_p->add_staff (staff_p); - delete tracks [i]; - tracks.del (i); - } - - // brr, musta have some progress - for (int ii = 0; !info_l_->bar_mom_ && ii < tracks.size (); ii++) - info_l_->bar_mom_ = tracks [ii]->info_l_->bar_mom_; - - int bar_i = (int) (at_mom - / (info_l_->bar_mom_ ? info_l_->bar_mom_ : bar4_mom)) + 1; - if (bar_i > current_bar_i) - { - LOGOUT (NORMAL_ver) << '[' << bar_i << ']' << flush; - current_bar_i = bar_i; - } - } - return score_p; -} diff --git a/midi2ly/midi-track-parser.cc b/midi2ly/midi-track-parser.cc deleted file mode 100644 index 3b62ffc106..0000000000 --- a/midi2ly/midi-track-parser.cc +++ /dev/null @@ -1,360 +0,0 @@ -/* - midi-track-parser.cc -- implement - - source file of the GNU LilyPond music typesetter - - (c) 1997--1998 Jan Nieuwenhuizen -*/ - -#include -#include "string-convert.hh" -#include "midi2ly-global.hh" -#include "midi-track-parser.hh" -#include "lilypond-column.hh" -#include "lilypond-item.hh" -#include "lilypond-score.hh" -#include "lilypond-staff.hh" - -Midi_track_parser::Midi_track_parser (Midi_parser_info* info_l, int i) -{ - info_l_ = info_l; - at_mom_ = 0; - track_info_p_ = 0; - lilypond_staff_p_ = new Lilypond_staff (i, "", "", ""); - parse_header (); - parse_delta_time (); -} - -Midi_track_parser::~Midi_track_parser () -{ - delete lilypond_staff_p_; - delete track_info_p_; -} - -Rational -Midi_track_parser::at_mom () -{ - return at_mom_; -} - -bool -Midi_track_parser::eot () -{ - if ( info_l_->byte_L_ < info_l_->end_byte_L_ ) - return false; - return true; -} - -void -Midi_track_parser::note_end (Lilypond_column* col_l, int channel_i, int pitch_i, int aftertouch_i ) -{ - // junk dynamics - (void)aftertouch_i; - - assert (col_l); - - for (Cons** pp = &open_note_l_list_.head_; *pp;) - { - Cons* i = *pp; - if ((i->car_->pitch_i_ == pitch_i) && (i->car_->channel_i_ == channel_i)) - { - i->car_->end_column_l_ = col_l; - delete open_note_l_list_.remove_cons (pp); - return; - } - else - pp = &i->next_; - } - warning (_f ("Junking note-end event: channel = %d, pitch = %d", - channel_i, pitch_i)); -} - -void -Midi_track_parser::note_end_all (Lilypond_column* col_l) -{ - // find - assert (col_l); - for (Cons* i = open_note_l_list_.head_; i; i = i->next_) - { - i->car_->end_column_l_ = col_l; - } - // UGH UGH. MEMORY LEAK. - open_note_l_list_.init (); -} - -Lilypond_staff* -Midi_track_parser::parse (Lilypond_column* col_l) -{ - Rational mom = at_mom (); - while (!eot () && (mom == at_mom ())) - { - Lilypond_item* p = parse_event (col_l); - if (p) - lilypond_staff_p_->add_item (p); - } - - if (!eot()) - return 0; - - // catch-all - note_end_all (col_l); - - Lilypond_staff* p = lilypond_staff_p_; - lilypond_staff_p_ = 0; - return p; -} - -void -Midi_track_parser::parse_delta_time () -{ - if (eot ()) - return; - int delta_i = get_var_i (); - at_mom_ += Rational (delta_i, info_l_->division_1_i_); -} - -Lilypond_item* -Midi_track_parser::parse_event (Lilypond_column* col_l) -{ - Byte byte = peek_byte (); - // RUNNING_STATUS [\x00-\x5f] - if (byte <= 0x5f) - { - if (running_byte_ <= 0x5f) - exit (_ ("invalid running status")); - /* - 'running status' rather means 'missing status'. - we'll just pretend we read the running status byte. - */ - byte = running_byte_; - } - else - byte = next_byte (); - - Lilypond_item* item_p = 0; - // DATA_ENTRY [\x60-\x79] - if ((byte >= 0x60) && (byte <= 0x79)) - { - next_byte (); - } - // ALL_NOTES_OFF [\x7a-\x7f] - else if ((byte >= 0x7a) && (byte <= 0x7f)) - { - next_byte (); - next_byte (); - note_end_all (col_l); - } - // NOTE_OFF [\x80-\x8f] - else if ((byte >= 0x80) && (byte <= 0x8f)) - { - running_byte_ = byte; - int channel_i = byte & ~0x90; - int pitch_i = (int)next_byte (); - int dyn_i = (int)next_byte (); - note_end (col_l, channel_i, pitch_i, dyn_i); - } - // NOTE_ON [\x90-\x9f] - else if ((byte >= 0x90) && (byte <= 0x9f)) - { - running_byte_ = byte; - int channel_i = byte & ~0x90; - int pitch_i = (int)next_byte (); - int dyn_i = (int)next_byte (); - /* - sss: some broken devices encode NOTE_OFF as - NOTE_ON with zero volume - */ - if (dyn_i) - { - Lilypond_note* p = new Lilypond_note (col_l, channel_i, pitch_i, dyn_i); - item_p = p; - open_note_l_list_.append (new Cons (p, 0)); - } - else - { - note_end (col_l, channel_i, pitch_i, dyn_i); - } - } - - // POLYPHONIC_AFTERTOUCH [\xa0-\xaf] - else if ((byte >= 0xa0) && (byte <= 0xaf)) - { - running_byte_ = byte; - next_byte (); - next_byte (); - } - // CONTROLMODE_CHANGE [\xb0-\xbf] - else if ((byte >= 0xb0) && (byte <= 0xbf)) - { - running_byte_ = byte; - next_byte (); - next_byte (); - } - // PROGRAM_CHANGE [\xc0-\xcf] - else if ((byte >= 0xc0) && (byte <= 0xcf)) - { - running_byte_ = byte; - next_byte (); - } - // CHANNEL_AFTERTOUCH [\xd0-\xdf] - else if ((byte >= 0xd0) && (byte <= 0xdf)) - { - running_byte_ = byte; - next_byte (); - next_byte (); - } - // PITCHWHEEL_RANGE [\xe0-\xef] - else if ((byte >= 0xe0) && (byte <= 0xef)) - { - running_byte_ = byte; - next_byte (); - next_byte (); - } - // SYSEX_EVENT1 [\xf0] - else if (byte == 0xf0) - { - int length_i = get_var_i (); - String str = get_str (length_i); - } - // SYSEX_EVENT2 [\xf7] - else if (byte == 0xf7) - { - int length_i = get_var_i (); - String str = get_str (length_i); - } - // META_EVENT [\xff] - else if (byte == 0xff) - { - // SEQUENCE [\x00][\x02] - byte = next_byte (); - if (byte == 0) - { - next_byte (); - get_i (2); - } - // YYTEXT [\x01] - // YYCOPYRIGHT [\x02] - // YYTRACK_NAME [\x03] - // YYINSTRUMENT_NAME [\x04] - // YYLYRIC [\x05] - // YYMARKER [\x06] - // YYCUE_POINT [\x07] - else if ((byte >= 0x01) && (byte <= 0x07)) - { - // LOGOUT (DEBUG_ver) << "\n% Text(" << (int)byte << "):" << flush; - int length_i = get_var_i (); - String str = get_str (length_i); - // LOGOUT (DEBUG_ver) << str << endl; - Lilypond_text::Type t = (Lilypond_text::Type)byte; - Lilypond_text* p = new Lilypond_text (t, str); - item_p = p; - if (t == Lilypond_text::COPYRIGHT) - lilypond_staff_p_->copyright_str_ = p->text_str_; - else if (t == Lilypond_text::TRACK_NAME) - lilypond_staff_p_->name_str_ = p->text_str_; - else if (t == Lilypond_text::INSTRUMENT_NAME) - lilypond_staff_p_->instrument_str_ = p->text_str_; - } - // END_OF_TRACK [\x2f][\x00] - else - { - Byte next = peek_byte (); - if ((byte == 0x2f) && (next == 0x00)) - { - next_byte (); - info_l_->byte_L_ = info_l_->end_byte_L_; - } - // TEMPO [\x51][\x03] - else if ((byte == 0x51) && (next == 0x03)) - { - next_byte (); - unsigned useconds_per_4_u = get_u (3); - // $$ = new Lilypond_tempo ( ($2 << 16) + ($3 << 8) + $4); - // LOGOUT (DEBUG_ver) << $$->str() << endl; - Lilypond_tempo* p = new Lilypond_tempo ( useconds_per_4_u ); - item_p = p; - info_l_->score_l_->lilypond_tempo_l_ = p; - lilypond_staff_p_->lilypond_tempo_l_ = p; - } - // SMPTE_OFFSET [\x54][\x05] - else if ((byte == 0x54) && (next == 0x05)) - { - next_byte (); - (int)next_byte (); - (int)next_byte (); - (int)next_byte (); - (int)next_byte (); - (int)next_byte (); - } - // TIME [\x58][\x04] - else if ((byte == 0x58) && (next == 0x04)) - { - next_byte (); - int num_i = (int)next_byte (); - int den_i = (int)next_byte (); - int clocks_4_i = (int)next_byte (); - int count_32_i = (int)next_byte (); - Lilypond_time_signature* p = new Lilypond_time_signature ( num_i, den_i, clocks_4_i, count_32_i ); - item_p = p; - info_l_->score_l_->lilypond_time_signature_l_ = p; - info_l_->bar_mom_ = p->bar_mom (); - lilypond_staff_p_->lilypond_time_signature_l_ = p; - } - // KEY [\x59][\x02] - else if ((byte == 0x59) && (next == 0x02)) - { - next_byte (); - int accidentals_i = (int)(signed char)next_byte (); - int minor_i = (int)(bool)next_byte (); - Lilypond_key* p = new Lilypond_key (accidentals_i, minor_i); - item_p = p; -#if 0 - info_l_->score_l_->lilypond_key_l_ = p; - lilypond_staff_p_->lilypond_key_l_ = p; -#endif - } - // SSME [\0x7f][\x03] - else if ((byte == 0x7f) && (next == 0x03)) - { - next_byte (); - int length_i = get_var_i (); - String str = get_str (length_i); - item_p = new Lilypond_text ((Lilypond_text::Type)byte, str); - } - else - { - next_byte (); - next_byte (); - warning (_ ("unimplemented MIDI meta-event")); - } - } - } - else - exit (_ ("invalid MIDI event")); - - if (item_p) - item_p->lilypond_column_l_ = col_l; - - parse_delta_time (); - - return item_p; -} - -void -Midi_track_parser::parse_header () -{ - String str = get_str (4); - if ( str != "MTrk" ) - exit (_ ("MIDI track expected")); - - int length_i = get_i (4); - // is this signed? - if (length_i < 0) - exit (_ ("invalid track length")); - assert (!track_info_p_); - track_info_p_ = new Midi_parser_info (*info_l_); - track_info_p_->end_byte_L_ = track_info_p_->byte_L_ + length_i; - forward_byte_L (length_i); - // forward_byte_L (length_i-1); - info_l_ = track_info_p_; -} diff --git a/midi2ly/midi2ly-version.cc b/midi2ly/midi2ly-version.cc deleted file mode 100644 index 73efc5a42b..0000000000 --- a/midi2ly/midi2ly-version.cc +++ /dev/null @@ -1,20 +0,0 @@ -// -// version.cc -- implement inexpensive versioning -// -// (c) 1997--2001 Jan Nieuwenhuizen - -#include -#include "config.h" -#include "version.hh" - -#define VERSION_SZ MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL "." MY_PATCH_LEVEL - -static char *s = "midi2ly " VERSION_SZ; - - -const char * -midi2ly_version_sz() -{ - return s; -} - diff --git a/midi2ly/plet.cc b/midi2ly/plet.cc deleted file mode 100644 index df6efdd842..0000000000 --- a/midi2ly/plet.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - plet.cc -- implement Plet - - source file of the GNU LilyPond music typesetter - - (c) 1997--2001 Han-Wen Nienhuys -*/ - -#include "plet.hh" - - -Plet::Plet () -{ - type_i_ = 1; - iso_i_ = 1; -} - -Rational -Plet::mom () const -{ - return Rational (iso_i_, type_i_); -} - -bool -Plet::unit_b () const -{ - return type_i_ == 1 && iso_i_ == 1; -} - diff --git a/midi2ly/version.cc b/midi2ly/version.cc deleted file mode 100644 index e1159f289f..0000000000 --- a/midi2ly/version.cc +++ /dev/null @@ -1,11 +0,0 @@ -#include "flower-proto.hh" -#include "string.hh" - -const char * midi2ly_version_sz(); - -String -midi2ly_version_str() -{ - return String (midi2ly_version_sz ()); -} - diff --git a/modules/GNUmakefile b/modules/GNUmakefile index e69de29bb2..61cfea23e5 100644 --- a/modules/GNUmakefile +++ b/modules/GNUmakefile @@ -0,0 +1,16 @@ +depth = .. + +# Hmm, name dir midi too, then? +NAME=midi + + +# compile fucks up on without autoconf -I flag. +STEPMAKE_TEMPLATES=c install python-module + +INSTALLATION_FILES=$(outdir)/midi.so +INSTALLATION_DIR=$(datadir)/python + +# do nothing; module ins't used yet. + +include $(depth)/make/stepmake.make + diff --git a/modules/midi.c b/modules/midi.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 89e2f803b0..c47c7c9d82 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -29,6 +29,7 @@ (direction . -1) (left-padding . 0.2) (right-padding . 0.4) + (paren-cautionaries . #t) (meta . ,(grob-description accidentals-interface font-interface side-position-interface)) )) @@ -316,9 +317,7 @@ (self-alignment-X . 0) (non-rhythmic . #t) (word-space . 0.6) - (ignore-length-mismatch . #f) - (begin-alignment . 4) - (end-alignment . 2) + (end-alignment . 5) (font-family . roman) (font-shape . upright) (meta . ,(grob-description lyric-syllable-interface text-interface font-interface )) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index a3543deb0f..1546486b5e 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -92,7 +92,7 @@ column as start/begin point. Only columns that have grobs or act as bounds are s (grob-property-description 'break-glyph-function procedure? "function taking glyph and break-direction, returning the glyph at a line break.") (grob-property-description 'breakable boolean? "boolean indicating if this is a breakable item (clef, barline, key sig, etc.).") (grob-property-description 'c0-position integer? "integer indicating the position of central C.") - +(grob-property-description 'cautionary-size integer? "size of cautionary accidentals (relative to size of accidentals)") (grob-property-description 'center-element ly-grob? "grob which will be at the center of the group after aligning (when using Align_interface::center_on_element). .") @@ -257,6 +257,7 @@ more than this (in staffspace).") (grob-property-description 'padding number? "add this much extra space between objects that are next to each other.") (grob-property-description 'parallel-beam boolean? "internal: true if there is a beam just as wide as the bracket .") +(grob-property-description 'paren-cautionaries boolean? "Whether to add parenthesis around cautionary accidentals.") (grob-property-description 'pitches list? "list of musical-pitch.") (grob-property-description 'porrectus-width number? "width of the porrectus ligature measured in staff space.") (grob-property-description 'raise number? "height for text to be raised (a negative value lowers the text.") @@ -381,10 +382,7 @@ function of type (beam multiplicity dy staff-line-thickness) -> real. Default v (grob-property-description 'visibility-lambda procedure? "a function that takes the break direction and returns a cons of booleans containing (TRANSPARENT . EMPTY).") (grob-property-description 'when moment? "when does this column happen?.") (grob-property-description 'word-space number? "elongate left by this much (FIXME: cumbersome semantics).") -(grob-property-description 'alignment number? "alignment of lyrics on notehead, -1 is LEFT, 0 is CENTRE, 1 is RIGHT .") -(grob-property-description 'ignore-length-mismatch boolean? "if #t, stanzas with shorter lyrics can be moved away from their respective note-head by the lyric alignment code.") -(grob-property-description 'begin-alignment number? "proportion of lyric length from beginning to align with note-head for left-aligned lyrics.") -(grob-property-description 'end-alignment number? "proportion of lyric length from end to align with note-head for right-aligned lyrics.") +(grob-property-description 'end-alignment number? "proportion of lyric length to align with note-head for non-centered lyrics.") (grob-property-description 'x-gap number? "horizontal gap between notehead and tie.") (grob-property-description 'y-free number? "minimal vertical gap between slur and noteheads or stems.") (grob-property-description 'y-offset number? "extra vertical offset for ties away from the center line.") diff --git a/scm/interface-description.scm b/scm/interface-description.scm index 1f837c0589..8f64d30c3a 100644 --- a/scm/interface-description.scm +++ b/scm/interface-description.scm @@ -187,7 +187,9 @@ "Accidentals" '(accidentals left-padding - right-padding + right-padding + paren-cautionaries + cautionary-size )) @@ -533,9 +535,6 @@ that helps show the length of a melissima (tied/slurred note)." "a single piece of lyrics" '( word-space - alignment - ignore-length-mismatch - begin-alignment end-alignment )) diff --git a/scm/lily.scm b/scm/lily.scm index df53f375c2..c251e8fa2e 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -113,7 +113,7 @@ (map (lambda (x) (eval-string (ly-gulp-file x))) '("output-lib.scm" "tex.scm" - "ps.scm" + "ps.scm" "sketch.scm" "pdf.scm" "pdftex.scm" "ascii-script.scm" diff --git a/scm/music-property-description.scm b/scm/music-property-description.scm index 39957ee441..8914c5c3db 100644 --- a/scm/music-property-description.scm +++ b/scm/music-property-description.scm @@ -27,7 +27,6 @@ (music-property-description 'span-type symbol? "What kind of spanner should be created?") (music-property-description 'articulation-type symbol? "key for scriptDefinitions alist") (music-property-description 'bass boolean? "Set if this note is a bass note in a chord") -(music-property-description 'body music? "The body of a repeat ") (music-property-description 'cautionary boolean? "If set, this alteration needs cautionary accidental") (music-property-description 'change-to-id string? "name of the context to change to ") (music-property-description 'change-to-type string? "type of the context to change to.") diff --git a/scm/sketch.scm b/scm/sketch.scm new file mode 100644 index 0000000000..ab2e8751ca --- /dev/null +++ b/scm/sketch.scm @@ -0,0 +1,268 @@ + + +;;; urg. +(define (sk-numbers->string l) + (string-append + (number->string (car l)) + (if (null? (cdr l)) + "" + (string-append "," (sk-numbers->string (cdr l))) + ) + ) + ) + + +(define (sketch-scm action-name) + (define global-x 0.0) + (define global-y 0.0) + (define output-scale 1.0) + (define (mul-scale x) (* output-scale x)) + + ;; alist containing fontname -> fontcommand assoc (both strings) + (define font-alist '()) + (define font-count 0) + (define current-font "") + + + (define (cached-fontname i) + (string-append + "lilyfont" + (make-string 1 (integer->char (+ 65 i))))) + + + (define (select-font name-mag-pair) + (let* + ( + (c (assoc name-mag-pair font-name-alist)) + ) + + (if (eq? c #f) + (begin + (display "FAILED\n") + (display (object-type (car name-mag-pair))) + (display (object-type (caaar font-name-alist))) + + (ly-warn (string-append + "Programming error: No such font known " + (car name-mag-pair) " " + (ly-number->string (cdr name-mag-pair)) + )) + + "") ; issue no command + "") +; (string-append " " (cddr c) " ")) + )) + + (define (font-load-command name-mag command) + "") + +; "Fn(" command ")" ) + + (define (beam width slope thick) + (string-append + (sk-numbers->string (list slope width thick)) " draw_beam" )) + + (define (comment s) + (string-append "% " s)) + + (define (bracket arch_angle arch_width arch_height height arch_thick thick) + (string-append + (numbers->string (list arch_angle arch_width arch_height height arch_thick thick)) " draw_bracket" )) + + (define (char i) + (invoke-char " show" i)) + + + (define (hairpin thick width starth endh ) + (string-append + (numbers->string (list width starth endh thick)) + " draw_hairpin")) + + ;; what the heck is this interface ? + (define (dashed-slur thick dash l) + (string-append + (apply string-append (map control->string l)) + (ly-number->string thick) + " [ " + (ly-number->string dash) + " " + (ly-number->string (* 10 thick)) ;UGH. 10 ? + " ] 0 draw_dashed_slur")) + + (define (dashed-line thick on off dx dy) + (string-append + (ly-number->string dx) + " " + (ly-number->string dy) + " " + (ly-number->string thick) + " [ " + (ly-number->string on) + " " + (ly-number->string off) + " ] 0 draw_dashed_line")) + + (define (repeat-slash wid slope thick) + (string-append (numbers->string (list wid slope thick)) + " draw_repeat_slash")) + + (define (end-output) + "guidelayer('Guide Lines',1,0,0,1,(0,0,1)) +grid((0,0,20,20),0,(0,0,1),'Grid')\n") + + (define (experimental-on) "") + + ;; obsolete? + (define (font-def i s) + (string-append + "\n/" (font i) " {/" + (substring s 0 (- (string-length s) 4)) + " findfont 12 scalefont setfont} bind def \n")) + + (define (font-switch i) + "") +; (string-append (font i) " ")) + + (define (header-end) + (string-append "") + + ) + + (define (lily-def key val) + (if (equal? key "lilypondpaperoutputscale") + (set! output-scale (string->number val)) +) + "") + + + (define (header creator generate) + (string-append + "##Sketch 1 2 +document() +layout('A4',0) +layer('Layer 1',1,1,0,0,(0,0,0)) +")) + + (define (invoke-char s i) + "") + + (define (invoke-dim1 s d) + (string-append + (ly-number->string (* d (/ 72.27 72))) " " s )) + + (define (placebox x y s) + (set! global-x (+ x 0)) + (set! global-y (+ y 100)) + (eval s) + ) + + (define (bezier-sandwich l thick) + '(string-append + (apply string-append (map control->string l)) + (ly-number->string thick) + " draw_bezier_sandwich")) + +; TODO: use HEIGHT argument + (define (start-line height) + "G()\n" + ) + + (define (filledbox breapth width depth height) + `(string-append + "lw(1)\nr(" + (sk-numbers->string (quote ,(map mul-scale (list (+ breapth width) + 0 0 + (- (+ breapth depth)) + global-x + (+ global-y height))))) + ")\n") + ) + + (define (stem x y z w) (filledbox x y z w)) + + + (define (stop-line) + "G_()\n") + + (define (text s) + "") +; (string-append "(" s ") show ")) + + + (define (volta h w thick vert_start vert_end) + (string-append + (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end))) + " draw_volta")) + + (define (tuplet ht gap dx dy thick dir) + (string-append + (numbers->string (list ht gap dx dy thick (inexact->exact dir))) + " draw_tuplet")) + + + (define (unknown) + "\n unknown\n") + + (define (ez-ball ch letter-col ball-col) + (string-append + " (" ch ") " + (numbers->string (list letter-col ball-col)) + " /Helvetica-Bold " ;; ugh + " draw_ez_ball")) + + (define (define-origin a b c ) "") + (define (no-origin) "") + + ;; PS + (cond ((eq? action-name 'all-definitions) + `(begin + (define beam ,beam) + (define tuplet ,tuplet) + (define bracket ,bracket) + (define char ,char) + (define hairpin ,hairpin) + (define volta ,volta) + (define bezier-sandwich ,bezier-sandwich) + (define dashed-line ,dashed-line) + (define dashed-slur ,dashed-slur) + (define end-output ,end-output) + (define experimental-on ,experimental-on) + (define filledbox ,filledbox) + (define stem ,stem) + (define font-def ,font-def) + (define font-switch ,font-switch) + (define header-end ,header-end) + (define lily-def ,lily-def) + (define font-load-command ,font-load-command) + (define header ,header) + (define invoke-char ,invoke-char) + (define invoke-dim1 ,invoke-dim1) + (define placebox ,placebox) + (define select-font ,select-font) + (define start-line ,start-line) + (define stem ,stem) + (define stop-line ,stop-line) + (define stop-last-line ,stop-line) + (define repeat-slash ,repeat-slash) + (define text ,text) + (define no-origin ,no-origin) + (define define-origin ,define-origin) + (define ez-ball ,ez-ball) + )) + ((eq? action-name 'repeat-slash) repeat-slash) + ((eq? action-name 'tuplet) tuplet) + ((eq? action-name 'beam) beam) + ((eq? action-name 'bezier-sandwich) bezier-sandwich) + ((eq? action-name 'bracket) bracket) + ((eq? action-name 'char) char) + ((eq? action-name 'dashed-line) dashed-line) + ((eq? action-name 'dashed-slur) dashed-slur) + ((eq? action-name 'hairpin) hairpin) + ((eq? action-name 'experimental-on) experimental-on) + ((eq? action-name 'filledbox) filledbox) + ((eq? action-name 'ez-ball) ez-ball) + ((eq? action-name 'select-font) select-font) + ((eq? action-name 'volta) volta) + (else (error "unknown tag -- SKETCH-SCM " action-name)) + ) + ) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index fd5386915b..4163ec4ed2 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -43,7 +43,7 @@ import operator program_version = '@TOPLEVEL_VERSION@' if program_version == '@' + 'TOPLEVEL_VERSION' + '@': - program_version = '1.4pre' + program_version = '1.5.18' # # Try to cater for bad installations of LilyPond, that have diff --git a/scripts/ly2dvi.py b/scripts/ly2dvi.py index d442753fe9..22a9a2245b 100644 --- a/scripts/ly2dvi.py +++ b/scripts/ly2dvi.py @@ -55,6 +55,9 @@ TODO: ''' + + + import os import stat import string @@ -67,20 +70,207 @@ import operator import tempfile import traceback + +################################################################ +# lilylib.py -- options and stuff +# +# source file of the GNU LilyPond music typesetter + +try: + import gettext + gettext.bindtextdomain ('lilypond', localedir) + gettext.textdomain ('lilypond') + _ = gettext.gettext +except: + def _ (s): + return s + +program_version = '@TOPLEVEL_VERSION@' +if program_version == '@' + 'TOPLEVEL_VERSION' + '@': + program_version = '1.5.17' + +def identify (): + sys.stdout.write ('%s (GNU LilyPond) %s\n' % (program_name, program_version)) + +def warranty (): + identify () + sys.stdout.write ('\n') + sys.stdout.write (_ ('Copyright (c) %s by' % ' 2001')) + sys.stdout.write ('\n') + sys.stdout.write (' Han-Wen Nienhuys') + sys.stdout.write (' Jan Nieuwenhuizen') + sys.stdout.write ('\n') + sys.stdout.write (_ (r''' +Distributed under terms of the GNU General Public License. It comes with +NO WARRANTY.''')) + sys.stdout.write ('\n') + +def progress (s): + errorport.write (s + '\n') + +def warning (s): + progress (_ ("warning: ") + s) + +def error (s): + + + '''Report the error S. Exit by raising an exception. Please + do not abuse by trying to catch this error. If you do not want + a stack trace, write to the output directly. + + RETURN VALUE + + None + + ''' + + progress (_ ("error: ") + s) + raise _ ("Exiting ... ") + +def getopt_args (opts): + '''Construct arguments (LONG, SHORT) for getopt from list of options.''' + short = '' + long = [] + for o in opts: + if o[1]: + short = short + o[1] + if o[0]: + short = short + ':' + if o[2]: + l = o[2] + if o[0]: + l = l + '=' + long.append (l) + return (short, long) + +def option_help_str (o): + '''Transform one option description (4-tuple ) into neatly formatted string''' + sh = ' ' + if o[1]: + sh = '-%s' % o[1] + + sep = ' ' + if o[1] and o[2]: + sep = ',' + + long = '' + if o[2]: + long= '--%s' % o[2] + + arg = '' + if o[0]: + if o[2]: + arg = '=' + arg = arg + o[0] + return ' ' + sh + sep + long + arg + + +def options_help_str (opts): + '''Convert a list of options into a neatly formatted string''' + w = 0 + strs =[] + helps = [] + + for o in opts: + s = option_help_str (o) + strs.append ((s, o[3])) + if len (s) > w: + w = len (s) + + str = '' + for s in strs: + str = str + '%s%s%s\n' % (s[0], ' ' * (w - len(s[0]) + 3), s[1]) + return str + +def help (): + ls = [(_ ("Usage: %s [OPTION]... FILE") % program_name), + ('\n\n'), + (help_summary), + ('\n\n'), + (_ ("Options:")), + ('\n'), + (options_help_str (option_definitions)), + ('\n\n'), + (_ ("Report bugs to %s") % 'bug-lilypond@gnu.org'), + ('\n')] + map (sys.stdout.write, ls) + +def setup_temp (): + """ + Create a temporary directory, and return its name. + """ + global temp_dir + if not keep_temp_dir_p: + temp_dir = tempfile.mktemp (program_name) + try: + os.mkdir (temp_dir, 0777) + except OSError: + pass + + return temp_dir + + +def system (cmd, ignore_error = 0): + """Run CMD. If IGNORE_ERROR is set, don't complain when CMD returns non zero. + + RETURN VALUE + + Exit status of CMD + """ + + if verbose_p: + progress (_ ("Invoking `%s\'") % cmd) + st = os.system (cmd) + if st: + name = re.match ('[ \t]*([^ \t]*)', cmd).group (1) + msg = name + ': ' + _ ("command exited with value %d") % st + if ignore_error: + warning (msg + ' ' + _ ("(ignored)") + ' ') + else: + error (msg) + + return st + + +def cleanup_temp (): + if not keep_temp_dir_p: + if verbose_p: + progress (_ ("Cleaning %s...") % temp_dir) + shutil.rmtree (temp_dir) + + +def strip_extension (f, ext): + (p, e) = os.path.splitext (f) + if e == ext: + e = '' + return p + e + +################################################################ +# END Library + + + + + + # if set, LILYPONDPREFIX must take prevalence # if datadir is not set, we're doing a build and LILYPONDPREFIX datadir = '@datadir@' -if os.environ.has_key ('LILYPONDPREFIX') \ - or '@datadir@' == '@' + 'datadir' + '@': + + +if os.environ.has_key ('LILYPONDPREFIX') : +# huh ? this always leads to exception. +# or '@datadir@' == '@' + 'datadir' + '@': datadir = os.environ['LILYPONDPREFIX'] else: datadir = '@datadir@' -sys.path.append (os.path.join (datadir, 'python')) -sys.path.append (os.path.join (datadir, 'python/out')) + +while datadir[-1] == os.sep: + datadir= datadir[:-1] program_name = 'ly2dvi' -program_version = '@TOPLEVEL_VERSION@' + original_dir = os.getcwd () temp_dir = os.path.join (original_dir, '%s.dir' % program_name) errorport = sys.stderr @@ -124,8 +314,6 @@ option_definitions = [ ('', 'w', 'warranty', _ ("show warranty and copyright")), ] -from lilylib import * - layout_fields = ['dedication', 'title', 'subtitle', 'subsubtitle', 'footer', 'head', 'composer', 'arranger', 'instrument', 'opus', 'piece', 'metre', 'meter', 'poet', 'texttranslator'] @@ -596,6 +784,9 @@ if files and files[0] != '-': # Ugh, maybe make a setup () function files = map (lambda x: strip_extension (x, '.ly'), files) + # hmmm. Wish I'd 've written comments when I wrote this. + # now it looks complicated. + (outdir, outbase) = ('','') if not output_name: outbase = os.path.basename (files[0]) @@ -608,8 +799,8 @@ if files and files[0] != '-': for i in ('.dvi', '.latex', '.ly', '.ps', '.tex'): output_name = strip_extension (output_name, i) - - files = map (abspath, files) + outbase = strip_extension (outbase, i) + files = map (abspath, files) if os.path.dirname (output_name) != '.': dep_prefix = os.path.dirname (output_name) diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index 6540628632..f43ae51921 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -24,12 +24,14 @@ TODO: import os import sys +import getopt +import sys +import string -# if set, LILYPONDPREFIX must take prevalence -# if datadir is not set, we're doing a build and LILYPONDPREFIX + +# do fuddling: we must load the midi module from the right directory. datadir = '@datadir@' -if os.environ.has_key ('LILYPONDPREFIX') \ - or '@datadir@' == '@' + 'datadir' + '@': +if os.environ.has_key ('LILYPONDPREFIX'): datadir = os.environ['LILYPONDPREFIX'] else: datadir = '@datadir@' @@ -37,13 +39,34 @@ else: sys.path.append (os.path.join (datadir, 'python')) sys.path.append (os.path.join (datadir, 'python/out')) - -import getopt -import __main__ -import sys -import string import midi +################################################################ +################ CONSTANTS + + +output_name = '' +LINE_BELL = 60 +scale_steps = [0,2,4,5,7,9,11] + +clocks_per_1 = 1536 +clocks_per_4 = 0 +key = 0 +time = 0 +reference_note = 0 +start_quant = 0 +start_quant_clocks = 0 +duration_quant = 0 +duration_quant_clocks = 0 +allowed_tuplets = [] +allowed_tuplet_clocks = [] +absolute_p = 0 +explicit_durations_p = 0 +text_lyrics_p = 0 + + + +################################################################ localedir = '@localedir@' try: @@ -83,9 +106,186 @@ option_definitions = [ ('', 'x', 'text-lyrics', _ ("treat every text as a lyric")), ] -# from lilylib import * -import lilylib +################################################################ +# lilylib.py -- options and stuff +# +# source file of the GNU LilyPond music typesetter + +import os +try: + import gettext + gettext.bindtextdomain ('lilypond', localedir) + gettext.textdomain ('lilypond') + _ = gettext.gettext +except: + def _ (s): + return s + +if program_version == '@' + 'TOPLEVEL_VERSION' + '@': + program_version = '1.5.17' + +def identify (): + sys.stdout.write ('%s (GNU LilyPond) %s\n' % (program_name, program_version)) + +def warranty (): + identify () + sys.stdout.write ('\n') + sys.stdout.write (_ ('Copyright (c) %s by' % ' 2001')) + sys.stdout.write ('\n') + sys.stdout.write (' Han-Wen Nienhuys') + sys.stdout.write (' Jan Nieuwenhuizen') + sys.stdout.write ('\n') + sys.stdout.write (_ (r''' +Distributed under terms of the GNU General Public License. It comes with +NO WARRANTY.''')) + sys.stdout.write ('\n') + +def progress (s): + errorport.write (s + '\n') + +def warning (s): + progress (_ ("warning: ") + s) + +def error (s): + + + '''Report the error S. Exit by raising an exception. Please + do not abuse by trying to catch this error. If you do not want + a stack trace, write to the output directly. + + RETURN VALUE + + None + + ''' + + progress (_ ("error: ") + s) + raise _ ("Exiting ... ") + +def getopt_args (opts): + '''Construct arguments (LONG, SHORT) for getopt from list of options.''' + short = '' + long = [] + for o in opts: + if o[1]: + short = short + o[1] + if o[0]: + short = short + ':' + if o[2]: + l = o[2] + if o[0]: + l = l + '=' + long.append (l) + return (short, long) + +def option_help_str (o): + '''Transform one option description (4-tuple ) into neatly formatted string''' + sh = ' ' + if o[1]: + sh = '-%s' % o[1] + + sep = ' ' + if o[1] and o[2]: + sep = ',' + + long = '' + if o[2]: + long= '--%s' % o[2] + + arg = '' + if o[0]: + if o[2]: + arg = '=' + arg = arg + o[0] + return ' ' + sh + sep + long + arg + + +def options_help_str (opts): + '''Convert a list of options into a neatly formatted string''' + w = 0 + strs =[] + helps = [] + + for o in opts: + s = option_help_str (o) + strs.append ((s, o[3])) + if len (s) > w: + w = len (s) + + str = '' + for s in strs: + str = str + '%s%s%s\n' % (s[0], ' ' * (w - len(s[0]) + 3), s[1]) + return str + +def help (): + ls = [(_ ("Usage: %s [OPTION]... FILE") % program_name), + ('\n\n'), + (help_summary), + ('\n\n'), + (_ ("Options:")), + ('\n'), + (options_help_str (option_definitions)), + ('\n\n'), + (_ ("Report bugs to %s") % 'bug-lilypond@gnu.org'), + ('\n')] + map (sys.stdout.write, ls) + +def setup_temp (): + """ + Create a temporary directory, and return its name. + """ + global temp_dir + if not keep_temp_dir_p: + temp_dir = tempfile.mktemp (program_name) + try: + os.mkdir (temp_dir, 0777) + except OSError: + pass + + return temp_dir + + +def system (cmd, ignore_error = 0): + """Run CMD. If IGNORE_ERROR is set, don't complain when CMD returns non zero. + + RETURN VALUE + + Exit status of CMD + """ + + if verbose_p: + progress (_ ("Invoking `%s\'") % cmd) + st = os.system (cmd) + if st: + name = re.match ('[ \t]*([^ \t]*)', cmd).group (1) + msg = name + ': ' + _ ("command exited with value %d") % st + if ignore_error: + warning (msg + ' ' + _ ("(ignored)") + ' ') + else: + error (msg) + + return st + + +def cleanup_temp (): + if not keep_temp_dir_p: + if verbose_p: + progress (_ ("Cleaning %s...") % temp_dir) + shutil.rmtree (temp_dir) + + +def strip_extension (f, ext): + (p, e) = os.path.splitext (f) + if e == ext: + e = '' + return p + e + +################################################################ +# END Library +################################################################ + + class Duration: @@ -249,6 +449,7 @@ class Note: global reference_note reference_note = self + # TODO: move space return s + ' ' @@ -367,25 +568,6 @@ class Text: return s -output_name = '' -LINE_BELL = 60 -scale_steps = [0,2,4,5,7,9,11] - -clocks_per_1 = 1536 -clocks_per_4 = 0 -key = 0 -time = 0 -reference_note = 0 -start_quant = 0 -start_quant_clocks = 0 -duration_quant = 0 -duration_quant_clocks = 0 -allowed_tuplets = [] -allowed_tuplet_clocks = [] -absolute_p = 0 -explicit_durations_p = 0 -text_lyrics_p = 0 - def split_track (track): chs = {} for i in range(16): @@ -811,7 +993,7 @@ def convert_midi (f, o): s = s + ' \\context Lyrics=%s \\%s\n' % (track, track) s = s + ' >\n}\n' - lilylib.progress (_ ("%s output to `%s'...") % ('LY', o)) + progress (_ ("%s output to `%s'...") % ('LY', o)) if o == '-': h = sys.stdout @@ -822,7 +1004,7 @@ def convert_midi (f, o): h.close () -(sh, long) = lilylib.getopt_args (option_definitions) +(sh, long) = getopt_args (option_definitions) try: (options, files) = getopt.getopt(sys.argv[1:], sh, long) except getopt.error, s: @@ -830,7 +1012,7 @@ except getopt.error, s: errorport.write (_ ("error: ") + _ ("getopt says: `%s\'" % s)) errorport.write ('\n') errorport.write ('\n') - lilylib.help () + help () sys.exit (2) for opt in options: @@ -840,7 +1022,7 @@ for opt in options: if 0: pass elif o == '--help' or o == '-h': - lilylib.help () + help () errorport.write ('\n') errorport.write (_ ("Example:")) errorport.write (r''' @@ -853,7 +1035,7 @@ for opt in options: elif o == '--verbose' or o == '-V': verbose_p = 1 elif o == '--version' or o == '-v': - lilylib.identify () + identify () sys.exit (0) elif o == '--warranty' or o == '-w': status = system ('lilypond -w', ignore_error = 1) @@ -882,10 +1064,8 @@ for opt in options: global key key = Key (sharps, flats, minor) elif o == '--start-quant' or o == '-s': - global start_quant, start_quant_clocks start_quant = string.atoi (a) elif o == '--allow-tuplet' or o == '-t': - global allowed_tuplets a = string.replace (a, '/', '*') tuplet = map (string.atoi, string.split (a, '*')) allowed_tuplets.append (tuplet) @@ -897,7 +1077,7 @@ for opt in options: if not files or files[0] == '-': # FIXME: read from stdin when files[0] = '-' - lilylib.help () + help () errorport.write (program_name + ":" + _ ("error: ") + _ ("no files specified on command line.") + '\n') sys.exit (2) @@ -905,9 +1085,9 @@ if not files or files[0] == '-': for f in files: g = f - g = lilylib.strip_extension (g, '.midi') - g = lilylib.strip_extension (g, '.mid') - g = lilylib.strip_extension (g, '.MID') + g = strip_extension (g, '.midi') + g = strip_extension (g, '.mid') + g = strip_extension (g, '.MID') (outdir, outbase) = ('','') if not output_name: diff --git a/stepmake/bin/package-diff.py b/stepmake/bin/package-diff.py index e07dd3ade3..357ab5046a 100644 --- a/stepmake/bin/package-diff.py +++ b/stepmake/bin/package-diff.py @@ -5,7 +5,7 @@ # -import find + import fnmatch import sys import os @@ -14,6 +14,32 @@ import string import getopt import pipes + +_debug = 0 + +_prune = ['(*)'] + +def find(pattern, dir = os.curdir): + list = [] + names = os.listdir(dir) + names.sort() + for name in names: + if name in (os.curdir, os.pardir): + continue + fullname = os.path.join(dir, name) + if fnmatch.fnmatch(name, pattern): + list.append(fullname) + if os.path.isdir(fullname) and not os.path.islink(fullname): + for p in _prune: + if fnmatch.fnmatch(name, p): + if _debug: print "skip", `fullname` + break + else: + if _debug: print "descend into", `fullname` + list = list + find(pattern, fullname) + return list + + topdir = '' def gulp_file(f): try: @@ -87,20 +113,20 @@ def remove_automatic (dirnames): for d in dirnames: try: for p in pats: - files = files + find.find (p, d) + files = files + find (p, d) except: sys.stderr.write ("Can't find dir: %s\n" % d) cleanup () sys.exit (1) - dirs = map (lambda d: find.find ('out*', d), dirnames) + dirs = map (lambda d: find ('out*', d), dirnames) dirs = reduce (lambda x,y: x + y, dirs) #print dirs for d in dirs: if os.path.isdir (d): - files = files + find.find ('*', d) + files = files + find ('*', d) for f in files: try: