From 0757febe2084fd8507334987b6f6b524888247c7 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 13 May 2012 01:23:31 +0200 Subject: [PATCH] Issue 2530: Use fractions rather than Scheme pairs for \scaleDuration, timeSignatureFraction et al --- Documentation/ly-examples/aucun-snippet.ly | 16 ++--- Documentation/notation/rhythms.itely | 67 ++++++++++--------- ...olymetric-section-using--scaledurations.ly | 39 +++++++++++ .../chord-tremolo-scaled-durations.ly | 4 +- .../time-signature-settings-by-staff.ly | 10 +-- lily/lexer.ll | 6 ++ lily/parser.yy | 5 ++ ly/engraver-init.ly | 4 +- ly/performer-init.ly | 4 +- 9 files changed, 103 insertions(+), 52 deletions(-) create mode 100644 Documentation/snippets/new/changing-time-signatures-inside-a-polymetric-section-using--scaledurations.ly diff --git a/Documentation/ly-examples/aucun-snippet.ly b/Documentation/ly-examples/aucun-snippet.ly index 9fb71c8c08..bcfc2f1dce 100644 --- a/Documentation/ly-examples/aucun-snippet.ly +++ b/Documentation/ly-examples/aucun-snippet.ly @@ -1,4 +1,4 @@ -\version "2.15.18" +\version "2.15.39" \include "example-header.ily" \paper { @@ -187,9 +187,9 @@ triplumNotes = \relative c' { f8 f4 e8 d c f f f | % 1 % the \scaleDurations command below makes 5 notes last the % duration of a dotted quarter - e8 c4 \scaleDurations #'(3 . 2) { \times 4/5{e16[ d e d e]} } e8 f4 | % 2 + e8 c4 \scaleDurations 3/2 { \times 4/5{e16[ d e d e]} } e8 f4 | % 2 g2. ~ g4. | % 3 - f8 d4 f4. \scaleDurations #'(3 . 2) { \times 4/6{ g16[ f e f e f]}} % 4 + f8 d4 f4. \scaleDurations 3/2 { \times 4/6{ g16[ f e f e f]}} % 4 g8 g4 g4. e4. | % 5 fis8 d4 e8\startGroup g4\stopGroup f8[ e d] | % 6 c2. r4. | % 7 @@ -222,10 +222,10 @@ tenorNotes = \relative c { %\set Staff.instrumentName = "Triplum" \set Staff.instrumentName = \incipitTriplum \set Staff.shortInstrumentName = "Tr." - \set Staff.timeSignatureFraction = #'(9 . 8) - \scaleDurations #'(2 . 3) + \set Staff.timeSignatureFraction = 9/8 + \scaleDurations 2/3 \context Voice = "triplum" { \global \triplumNotes } -% \scaleDurations #'(2 . 3) +% \scaleDurations 2/3 % \context Voice = "slashes" { \triplumSkips } \new Lyrics { \lyricsto "triplum" { \triplumWords }} >> @@ -233,8 +233,8 @@ tenorNotes = \relative c { %\set Staff.instrumentName = "Motetus" \set Staff.instrumentName = \incipitMotetus \set Staff.shortInstrumentName = "M." - \set Staff.timeSignatureFraction = #'(9 . 8) - \scaleDurations #'(2 . 3) + \set Staff.timeSignatureFraction = 9/8 + \scaleDurations 2/3 \context Voice = "motetus" { \global \motetusNotes } \new Lyrics { \lyricsto "motetus" { \motetusWords }} >> diff --git a/Documentation/notation/rhythms.itely b/Documentation/notation/rhythms.itely index e223bab412..872464c4ea 100644 --- a/Documentation/notation/rhythms.itely +++ b/Documentation/notation/rhythms.itely @@ -7,7 +7,7 @@ Guide, node Updating translation committishes.. @end ignore -@c \version "2.15.18" +@c \version "2.15.39" @node Rhythms @section Rhythms @@ -317,8 +317,10 @@ fraction @code{N/M} by appending @code{*N/M} (or @code{*N} if @code{M} is 1) to the duration. This will not affect the appearance of the notes or rests produced, but the altered duration will be used in calculating the position within the measure and setting the duration -in the MIDI output. Multiplying factors may be combined such as -@code{*L*M/N}. +in the MIDI output. Multiplying factors may be combined like +@code{*L*M/N}. Factors are part of the duration: if +you don't specify a duration for subsequent notes, the default +duration taken from the preceding note includes any scaling factor. In the following example, the first three notes take up exactly two beats, but no triplet bracket is printed. @@ -326,16 +328,16 @@ two beats, but no triplet bracket is printed. @lilypond[quote,relative=2,verbatim] \time 2/4 % Alter durations to triplets -a4*2/3 gis4*2/3 a4*2/3 +a4*2/3 gis a % Normal durations -a4 a4 +a4 a % Double the duration of chord 4*2 % Duration of quarter, appears like sixteenth b16*4 c4 @end lilypond -The duration of spacing notes may also be modified by +The duration of spacer rests may also be modified by a multiplier. This is useful for skipping many measures, e.g., @code{s1*23}. @@ -349,20 +351,19 @@ Longer stretches of music may be compressed by a fraction in the same way, as if every note, chord or rest had the fraction as a multiplier. This leaves the appearance of the music unchanged but the internal duration of the notes will be multiplied by the -fraction @emph{num}/@emph{den}. The spaces around the dot are -required. Here is an example showing how music can be compressed -and expanded: +fraction @emph{num}/@emph{den}. Here is an example showing how music +can be compressed and expanded: @lilypond[quote,relative=2,verbatim] \time 2/4 % Normal durations 4 c8 a % Scale music by *2/3 -\scaleDurations #'(2 . 3) { +\scaleDurations 2/3 { 4. c8 a f } % Scale music by *2 -\scaleDurations #'(2 . 1) { +\scaleDurations 2/1 { 4 c8 b } @end lilypond @@ -1061,8 +1062,8 @@ be changed, or new default values can be added: \new Staff { \relative c' { \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(3 1) % beatStructure #'() % beamExceptions \time 4/4 @@ -1077,11 +1078,11 @@ be changed, or new default values can be added: @enumerate @item -@code{@var{timeSignatureFraction}}, a Scheme pair describing the +@code{@var{timeSignatureFraction}}, a fraction describing the time signature. @item -@code{@var{baseMomentFraction}}, a Scheme pair containing the numerator +@code{@var{baseMomentFraction}}, a fraction containing the numerator and denominator of the basic timing unit for the time signature. @item @@ -1105,8 +1106,8 @@ instantiated or there must be music in the context before the \relative c' { % This call will fail because the context isn't yet instantiated \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(3 1) % beatStructure #'() % beamExceptions \time 4/4 @@ -1114,8 +1115,8 @@ instantiated or there must be music in the context before the \repeat unfold 7 { c8 } | % This call will succeed \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(3 1) % beatStructure #'() % beamExceptions \time 4/4 @@ -1138,13 +1139,13 @@ to the original values: \relative c' { \repeat unfold 8 { c8 } | \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(3 1) % beatStructure #'() % beamExceptions \time 4/4 \repeat unfold 8 { c8 } | - \revertTimeSignatureSettings #'(4 . 4) + \revertTimeSignatureSettings 4/4 \time 4/4 \repeat unfold 8 { c8 } | } @@ -1161,8 +1162,8 @@ for different staves by moving the @code{Timing_translator} and the \new StaffGroup << \new Staff { \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(3 1) % beatStructure #'() % beamExceptions \time 4/4 @@ -1170,8 +1171,8 @@ for different staves by moving the @code{Timing_translator} and the } \new Staff { \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(1 3) % beatStructure #'() % beamExceptions \time 4/4 @@ -1585,14 +1586,14 @@ affect the autobeaming rules. } \new Staff { \time 3/4 - \set Staff.timeSignatureFraction = #'(9 . 8) - \scaleDurations #'(2 . 3) + \set Staff.timeSignatureFraction = 9/8 + \scaleDurations 2/3 \repeat unfold 6 { c8[ c c] } } \new Staff { \time 3/4 - \set Staff.timeSignatureFraction = #'(10 . 8) - \scaleDurations #'(3 . 5) { + \set Staff.timeSignatureFraction = 10/8 + \scaleDurations 3/5 { \repeat unfold 2 { c8[ c c] } \repeat unfold 2 { c8[ c] } | c4. c \times 2/3 { c8[ c c] } c4 @@ -2291,8 +2292,8 @@ beaming settings for a time signature are described in << \new Staff { \overrideTimeSignatureSettings - #'(3 . 4) % timeSignatureFraction - #'(1 . 8) % baseMomentFraction + 3/4 % timeSignatureFraction + 1/8 % baseMomentFraction #'(1 5) % beatStructure #'() % beamExceptions \time 3/4 @@ -3321,7 +3322,7 @@ becomes: Or explicitly change the musical duration: @example -\acciaccatura @{ \scaleDurations #' (1 . 2) @{ c'8[ d' e' f' g'] @} @} +\acciaccatura @{ \scaleDurations 1/2 @{ c'8[ d' e' f' g'] @} @} @end example See @ref{Scaling durations}. diff --git a/Documentation/snippets/new/changing-time-signatures-inside-a-polymetric-section-using--scaledurations.ly b/Documentation/snippets/new/changing-time-signatures-inside-a-polymetric-section-using--scaledurations.ly new file mode 100644 index 0000000000..66013ce130 --- /dev/null +++ b/Documentation/snippets/new/changing-time-signatures-inside-a-polymetric-section-using--scaledurations.ly @@ -0,0 +1,39 @@ +\version "2.15.17" + +\header { + lsrtags = "workaround, contexts-and-engravers, contemporary-notation, rhythms" + + doctitle = "Changing time signatures inside a polymetric section using \\scaleDurations" +} + + +\layout { + \context { + \Score + \remove "Timing_translator" + \remove "Default_bar_line_engraver" + } + \context { + \Staff + \consists "Timing_translator" + \consists "Default_bar_line_engraver" + } +} + +<< + \new Staff { + \scaleDurations 8/5 { + \time 6/8 + \set Timing.measureLength = #(ly:make-moment 6 5) + b8 b b b b b + \time 2/4 + \set Timing.measureLength = #(ly:make-moment 4 5) + b4 b + } + } + \new Staff { + \clef bass + \time 2/4 + c2 d e f + } +>> diff --git a/input/regression/chord-tremolo-scaled-durations.ly b/input/regression/chord-tremolo-scaled-durations.ly index 0b8c6c8ad1..6cf26b9589 100644 --- a/input/regression/chord-tremolo-scaled-durations.ly +++ b/input/regression/chord-tremolo-scaled-durations.ly @@ -1,4 +1,4 @@ -\version "2.14.0" +\version "2.15.17" \header { texidoc = "Don't allow scaled durations to confuse the tremolo beaming. @@ -8,7 +8,7 @@ The tremolos should each have 3 beams." { \time 3/4 \repeat tremolo 12 {e'32 f'} - \scaleDurations #'(3 . 4) { + \scaleDurations 3/4 { \repeat tremolo 12 {e'32 f'} r4 } } diff --git a/input/regression/time-signature-settings-by-staff.ly b/input/regression/time-signature-settings-by-staff.ly index b5ddc6f818..c772b7b1a4 100644 --- a/input/regression/time-signature-settings-by-staff.ly +++ b/input/regression/time-signature-settings-by-staff.ly @@ -1,4 +1,4 @@ -\version "2.14.0" +\version "2.15.17" \header { texidoc = " @@ -13,8 +13,8 @@ should be beamed 3/4, 1/4. The lower staff should be beamed 1/4, 3/4. \new StaffGroup << \new Staff { \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(3 1) % beatStructure #'() % beamExceptions \time 4/4 @@ -22,8 +22,8 @@ should be beamed 3/4, 1/4. The lower staff should be beamed 1/4, 3/4. } \new Staff { \overrideTimeSignatureSettings - #'(4 . 4) % timeSignatureFraction - #'(1 . 4) % baseMomentFraction + 4/4 % timeSignatureFraction + 1/4 % baseMomentFraction #'(1 3) % beatStructure #'() % beamExceptions \time 4/4 diff --git a/lily/lexer.ll b/lily/lexer.ll index 78b6475303..bdbf128314 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -711,6 +711,11 @@ BOM_UTF8 \357\273\277 } } +{FRACTION} { + yylval.scm = scan_fraction (YYText ()); + return FRACTION; +} + -{UNSIGNED} | // backup rule {REAL} { yylval.scm = scm_c_read_string (YYText ()); @@ -721,6 +726,7 @@ BOM_UTF8 \357\273\277 return REAL; } +{UNSIGNED}/\/ | // backup rule {UNSIGNED} { yylval.scm = scm_c_read_string (YYText ()); return UNSIGNED; diff --git a/lily/parser.yy b/lily/parser.yy index 601d63fc31..49acd012d5 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -786,6 +786,9 @@ identifier_init: | number_expression { $$ = $1; } + | FRACTION { + $$ = $1; + } | string { $$ = $1; } @@ -2060,12 +2063,14 @@ simple_string: STRING { scalar: embedded_scm_arg | bare_number + | FRACTION | lyric_element ; scalar_closed: embedded_scm_arg_closed | bare_number + | FRACTION | lyric_element ; diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 6e8210b9c1..7f9a2b9699 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -16,7 +16,7 @@ %%%% You should have received a copy of the GNU General Public License %%%% along with LilyPond. If not, see . -\version "2.15.20" +\version "2.15.39" \context { \name "Global" @@ -614,7 +614,7 @@ automatically when an output definition (a @code{\score} or repeatCountVisibility = #all-repeat-counts-visible timeSignatureSettings = #default-time-signature-settings - timeSignatureFraction = #'(4 . 4) + timeSignatureFraction = 4/4 %% These defaults should be the same as the rules established in %% scm/time-signature-settings.scm for 4/4 time diff --git a/ly/performer-init.ly b/ly/performer-init.ly index 1a36b7fd19..fdfa7add3c 100644 --- a/ly/performer-init.ly +++ b/ly/performer-init.ly @@ -16,7 +16,7 @@ %%%% You should have received a copy of the GNU General Public License %%%% along with LilyPond. If not, see . -\version "2.14.0" +\version "2.15.39" %% %% setup for Request->Element conversion. @@ -225,7 +225,7 @@ %% Timing variables in layout definitions before any %% Timing_translator has been run. - timeSignatureFraction = #'(4 . 4) + timeSignatureFraction = 4/4 %% These defaults should be the same as the rules established in %% scm/time-signature-settings.scm for 4/4 time -- 2.39.2