From b8ef428503e626c3a5a7adc65282baf5e7dda205 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 13 Apr 2000 15:44:31 +0200 Subject: [PATCH] patch::: 1.3.44.jcn2 1.3.44.jcn2 =========== * Implemented una-chorda and sostenuto piano pedals in performer and engraver. * Added Properties textScriptWordSpace and chordNameWordSpace. * Junked old lyrics in star-spangled-banner. --- CHANGES | 9 ++ VERSION | 2 +- buildscripts/make-cygwin-cross.sh | 1 + input/bugs/bar-break.ly | 28 ++++ input/bugs/shorthand-trickery.ly | 36 +++++ input/bugs/text-dynamics.ly | 144 +++++++++++++++++++ input/star-spangled-banner.ly | 220 ++++++++++++++++-------------- input/test/bar-break.ly | 2 +- input/test/font-body.ly | 1 + input/test/ped.ly | 14 -- input/test/pedal.ly | 2 +- lily/chord-name.cc | 7 + lily/include/audio-item.hh | 3 +- lily/midi-item.cc | 10 +- lily/piano-pedal-engraver.cc | 218 +++++++++++++++++------------ lily/piano-pedal-performer.cc | 91 +++++++----- lily/text-item.cc | 12 +- ly/engraver.ly | 8 ++ ly/spanners.ly | 10 +- scm/generic-property.scm | 11 ++ scm/lily.scm | 1 + tex/p.tex | 4 +- 22 files changed, 585 insertions(+), 249 deletions(-) create mode 100644 input/bugs/bar-break.ly create mode 100644 input/bugs/shorthand-trickery.ly create mode 100644 input/bugs/text-dynamics.ly diff --git a/CHANGES b/CHANGES index 1cd9dce1a2..3222ba52f1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ +1.3.44.jcn2 +=========== + +* Implemented una-chorda and sostenuto piano pedals in performer and engraver. + +* Added Properties textScriptWordSpace and chordNameWordSpace. + +* Junked old lyrics in star-spangled-banner. + 1.3.44.jcn1 =========== diff --git a/VERSION b/VERSION index f2d1a87acc..be8e47761a 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=44 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/buildscripts/make-cygwin-cross.sh b/buildscripts/make-cygwin-cross.sh index 6d9bd3b1ff..fa6a47f450 100644 --- a/buildscripts/make-cygwin-cross.sh +++ b/buildscripts/make-cygwin-cross.sh @@ -606,6 +606,7 @@ copy < olddll copy < newdll bash setup.sh if not errorlevel 0 goto nobash +attrib +s \\Cygnus\\usr\\share\\lilypond\\cmtfm goto :exit :nobash @echo "setup.bat: can't find bash" diff --git a/input/bugs/bar-break.ly b/input/bugs/bar-break.ly new file mode 100644 index 0000000000..94fd0dbbcf --- /dev/null +++ b/input/bugs/bar-break.ly @@ -0,0 +1,28 @@ +\score +{ + \context StaffGroup = a < + \context PianoStaff = b < + \context Staff = "c" \notes\relative c'' { b4 b \bar "empty"; \break b b } + \context Staff = "d" \notes\relative c'' { b4 b b b } + > + > + + \paper { + indent=100.0\mm; + linewidth=150.0\mm; + \translator { + \StaffContext + \consists "Instrument_name_engraver"; + numberOfStaffLines = #1 + marginScriptPadding = #30 % urg: this is in PT + instrument = #"Foo" + instr = #"Bar" + } + \translator { + \StaffGroupContext + \consists "Instrument_name_engraver"; + marginScriptPadding = #10 % urg: this is in PT + instrument = #"Piano\n(For rehearsal only)" + } + } +} diff --git a/input/bugs/shorthand-trickery.ly b/input/bugs/shorthand-trickery.ly new file mode 100644 index 0000000000..6ad3025c85 --- /dev/null +++ b/input/bugs/shorthand-trickery.ly @@ -0,0 +1,36 @@ +% +% Example of shorthand trickery +% \property Context.foo = bar +% +foo = \property Staff.foo = #"bar" +% +% +% + +one = \context Voice\notes\relative c { + a1 b c +} + + +two = \context Voice\notes { + a1\foo + b + < c\foo e > +} + +\score{ + \context OtherStaff=one < + \one + \two + > + \paper{ + \translator { + \StaffContext + \name "OtherStaff"; + } + \translator { + \ScoreContext + \accepts "OtherStaff"; + } + } +} diff --git a/input/bugs/text-dynamics.ly b/input/bugs/text-dynamics.ly new file mode 100644 index 0000000000..03dfeee77c --- /dev/null +++ b/input/bugs/text-dynamics.ly @@ -0,0 +1,144 @@ +\header{ +Composer="Sergej Rachmaninov (1873-1943)"; +Title="Elegie"; +Subtitle="À Monsieur A. Arensky"; +Opus="Opus 3 Nr 1"; +Note="Small fragment to show Pedal and Dynamics problems"; +Enteredby="JCN"; +} + +% +% Arg. +% How to remove dynamics from Voice/Staff, but still show fingering? +% When Dynamic_engraver is removed, the Text_engraver happily engraves +% the dynamic markings. +% When the Text_engraver is removed, it can't engrave the fingerings. +% + +global = \notes{ + \key es \minor; + \time 4/4; +} + +upperMusic = \context Voice\notes\relative c'' { + %1 + R1 + R1 + r2 ges'2--~ +} + +upperDynamics = \context Voice\notes { + %1 + s1\pp + s1 + s2 s2\mf +} + +upperFingering = \context Voice\notes { + %1 + s1 + s1 + s2 s2-4 +} + +lowerMusic = \context Voice\notes\relative c { + %1 + bes' ges' es' bes' es, ges,)bes, + bes' ges' es' bes' es, ges,)bes, + bes' ges' es' bes' es, ges,)bes, +} + +lowerPedal = \context Voice\notes { + %1 + %1 + s8\unachorda\sustaindown s8 s4 s2 + s8\sustaindown\sustainup s8 s4 s2 + s8\sustaindown\sustainup s8 s4 s2\trechorde +} + +lowerDynamics = \context Voice\notes { + %1 +} + +lowerFingering = \context Voice\notes { + %1 + s8 s8-5 s-2 s-1 s-2 s-1 s-2 s + s1 + s1 +} + +\score{ + \context PianoStaff < + \context UpperStaff=upper < + \global + \upperMusic + \upperDynamics + \upperFingering + \lowerPedal + > + \context LowerStaff=lower < + \global + \clef bass; + \lowerMusic + \lowerPedal + \lowerDynamics + \lowerFingering + \upperDynamics + > + > + \paper{ + % Hmm + \translator { + \VoiceContext + \remove "Piano_pedal_engraver"; + \remove "Dynamic_engraver"; + % AAAARGH! + \remove "Text_engraver"; + } + \translator { + \StaffContext + \name "UpperStaff"; + \consists "Dynamic_engraver"; + dynamicPadding = #3 % urg, in \pt + dynamicMinimumSpace = #6 % urg, in \pt + } + \translator { + \StaffContext + \name "LowerStaff"; + \consists "Piano_pedal_engraver"; + startSustain = #"Ped." + stopSustain = #"*" + stopStartSustain = #"-P" + startUnaChorda = #"una chorda" + stopUnaChorda = #"tre chorde" + textScriptPadding = #3.0 + } + \translator { + \PianoStaffContext + \accepts "UpperStaff"; + \accepts "LowerStaff"; + } + \translator { + \ScoreContext + timeSignatureStyle = #"C" + } + } + \midi{ + % Zucht + \translator { + \StaffContext + \name "UpperStaff"; + } + \translator { + \StaffContext + \name "LowerStaff"; + } + \translator { + \ScoreContext + \accepts "UpperStaff"; + \accepts "LowerStaff"; + } + \tempo 4 = 88; + } +} + diff --git a/input/star-spangled-banner.ly b/input/star-spangled-banner.ly index e485996a03..4c14e483e5 100644 --- a/input/star-spangled-banner.ly +++ b/input/star-spangled-banner.ly @@ -4,7 +4,23 @@ http://www.Arkkra.com/doc/star.html http://www.Arkkra.com/doc/star.ps %} +\version "1.3.42"; +% TODO: +% +% * centre non-melismata lyrics under notehead: +% +% l c c c l +% ___ +% | | | | | | | +% x|()x| x| x| x| x|( )x| +% Oh_____say can you see +% +% +% * repeat colons in Lyrics / running into barline of 'Whose broad' +% +% * slur/lyric clash +% \header{ title="The Star Spangled Banner"; @@ -16,11 +32,22 @@ http://www.Arkkra.com/doc/star.ps copyright="public domain"; } +global = \notes { + \time 3/4; + \key d; + \partial 4; +} + $staff1_voice_1 = \notes { a8.()fis16 - \repeat volta 2 { d4 fis4 a4 d'2 fis'8. e'16 d'4 fis4 gis4 a2 a8 a8 - fis'4. e'8 d'4 cis'2 b8. cis'16 d'4 d'4 a4 } - \alternative { { fis4 d4 a8. fis16 } { fis4 d4 fis'8. fis'16 } } + \repeat volta 2 { + d4 fis4 a4 d'2 fis'8. e'16 d'4 fis4 gis4 a2 a8 a8 + fis'4. e'8 d'4 cis'2 b8. cis'16 d'4 d'4 a4 + } + \alternative { + { fis4 d4 a8. fis16 } + { fis4 d4 fis'8. fis'16 } + } fis'4 g'4 a'4 a'2 g'8 fis'8 e'4 fis'4 g'4 g'2 g'4 fis'4. e'8 d'4 cis'2 b8. cis'16 d'4 fis4 gis4 a2 a4 d'4 d'4 d'8()cis'8 b4 b4 b4 e'4 g'8 ()fis'8 e'8()d'8 @@ -30,9 +57,14 @@ $staff1_voice_1 = \notes { $staff1_voice_2 = \notes { a8.()fis16 - \repeat volta 2 { a,4 d4 e4 d4 () fis4 fis8. fis16 fis4 d4 d4 cis2 - e8 e8 a4. a8 a4 a2 a8. a16 a4 a4 a4 } - \alternative { { fis4 d4 a8. fis16 } { fis4 d4 r4 } } + \repeat volta 2 { + a,4 d4 e4 d4 () fis4 fis8. fis16 fis4 d4 d4 cis2 + e8 e8 a4. a8 a4 a2 a8. a16 a4 a4 a4 + } + \alternative { + { fis4 d4 a8. fis16 } + { fis4 d4 r4 } + } a4 a4 d'4 d'2 a8 a8 cis'4 cis'4 cis'4 cis'2 a4 a4. a8 a4 a2 a8. a16 d4 d4 d4 cis2 e4 fis4 e4 d4 d4 d4 dis4 g4 g8()dis8 e4 e2 e8. e16 d4.()a8 a8 a8 a2 g8 g8 a4. a8 g4 fis2 s4 @@ -40,9 +72,14 @@ $staff1_voice_2 = \notes { $staff2_voice_1 = \notes { r4 - \repeat volta 2 { fis4 a4 a4 b2 cis'8. cis'16 b4 b4 b4 a2 cis'8 cis'8 - d'4. cis'8 d'4 e'2 e'8. e'16 d'4 d'4 a4 } - \alternative { { fis4 d4 r4 } { fis4 d4 r4 } } + \repeat volta 2 { + fis4 a4 a4 b2 cis'8. cis'16 b4 b4 b4 a2 cis'8 cis'8 + d'4. cis'8 d'4 e'2 e'8. e'16 d'4 d'4 a4 + } + \alternative { + { fis4 d4 r4 } + { fis4 d4 r4 } + } d4 e4 fis4 fis'2 e'8 d'8 e'4 e'4 e'4 e'2 cis'4 d'4. cis'8 d'4 e'2 e'8. e'16 a4 a4 e4 e2 cis'4 a4 a4 a4 g4 g4 b4 b4 b4 b4 a2 cis'8. cis'16 a4.()cis'8 d'8 d'8 d'2 d'8 d'8 d'4. d'8 cis'4 @@ -51,113 +88,83 @@ $staff2_voice_1 = \notes { $staff2_voice_2 = \notes { r4 - \repeat volta 2 { d4 d4 cis4 b,2 ais,8. ais,16 b,4 b,4 e4 a,2 a8 a8 - d4. e8 fis8 g8 a2 g8. g16 fis4 fis4 a4 } - \alternative { { fis4 d4 r4 } { fis4 d4 r4 } } + \repeat volta 2 { + d4 d4 cis4 b,2 ais,8. ais,16 b,4 b,4 e4 a,2 a8 a8 + d4. e8 fis8 g8 a2 g8. g16 fis4 fis4 a4 + } + \alternative { + { fis4 d4 r4 } + { fis4 d4 r4 } + } d4 d4 d4 d2 d8 d8 a4 a4 a4 a2 a,4 d4. e8 fis8 g8 a2 g8. g16 fis4 d4 e4 a,2 a4 d4 e4 fis4 g4 g4 fis4 e4 e8()fis8 g8()gis8 a2 g8. g16 fis4.()a,8 d8 e8 fis2 b8 b8 a4. a8 a,4 d2 s4 } - -altOne =\lyrics { say,4 can you | see,2 __ by8. the16 dawn's4 ear- ly light2 What8 - so8 proud-4. ly8 we4 hailed,2 At8. the16 twi-4 light's last gleam- - ing. Whose8. broad16 } - -altTwo = \lyrics { stripes4 and bright stars,2 through8. the16 per-4 il- ous fight,2 - O'er8 the8 ram-4. parts8 we4 watched,2 were8. so16 gal-4 lant- ly - _ _ % UGH UGH - stream-4 ing - And8. the16 rock-4 ets' red glare,2 the8 bombs8 - burst-4 ing in air,2 gave4 proof4. through8 the4 night2 that8. - our16 flag4 was still there,2 Oh4 say, does that star- span- - gled ban- ner yet wave,2 __ O'er8. the16 land2 __ of8 the8 free2 - and8 the8 home4. of8 the4 brave.2 -} -% old code -nonRepeatText = \lyrics \context LyricVoice = LVA { - Oh4 __ - \context Lyrics < - \altOne - \altTwo - > -} - -%{ -Be careful to have all duration within the lyrics of the same kind. - -Alternatives & need to be matched more intelligently. See -"whose broad" alt1, volta1, "streaming" alt2, *volta2*! - -%} - -textxx = \lyrics { +text = \lyrics { Oh __ \repeat "fold" 2 { } \alternative { - { - say, can you | see, by the dawn's ear- ly light What - so proud- ly we hailed, At the twi- light's last gleam- - ing. Whose broad - } - + { + say, can you | see, by the dawn's ear- ly light + What so proud- ly we hailed, + At the twi- light's last gleam- ing. + %Whose broad + %Whose broad_justoseewhatsgoingonhere \bar ":|"; + % Ah, it seems that this context stops to exist just before + % the :| barline is set, and doesn't see its width? + % Adding one here fixes running into the span-bar, + % but adds yet another repeatcolon -- maybe we can fix that + % elsewhere. + Whose broad \bar ":|"; + } { stripes and bright stars, through the per- il- ous fight, O'er the ram- parts we watched, were so gal- lant- ly - " " " " " " " "% _ _ _ _ % UGH UGH UGH - stream- ing - And the rock- ets' red glare, the bombs - burst- ing in air, gave proof through the night that - our flag was still there, Oh say, does that star- span- - gled ban- ner yet wave, __ O'er the land __ of the free - and the home of the brave. + " " " " " " " "% UGH UGH UGH + stream- ing + + And the rock- ets' red glare, the bombs burst- ing in air, + gave proof through the night that our flag was still there, + Oh say, does that star- span- gled ban- ner yet wave, __ + O'er the land __ of the free and the home of the brave. + } } -}} - +} -beginmatter = \notes {\time 3/4; \key d; s4 | } - +\include "paper16.ly"; -automaticLyrics = \notes \context GrandStaff < +\score{ + \context GrandStaff \notes < \addlyrics - \context Staff=staffA < - \beginmatter + \context Staff=upper < + \global \clef treble; \property Staff.automaticMelismata = ##t - \context Voice = one \transpose c'' {\stemup \$staff1_voice_1 \bar "|.";} - \context Voice = two \transpose c'' {\stemdown \$staff1_voice_2 } - > - \context LyricVoice \textxx - \context Staff=staffB < - \beginmatter - \clef bass; - \property Staff.noVoltaBraces = ##t - \context Voice = three {\stemup \$staff2_voice_1 \bar "|."; } - \context Voice = four {\stemdown \$staff2_voice_2 } - > - > - -handLyrics = \notes \context GrandStaff < - \context Staff=staffA < - \beginmatter - \transpose c'' {\voiceone \$staff1_voice_1 \bar "|.";} - \transpose c'' {\voicetwo \$staff1_voice_2 } + \context Voice = one \transpose c'' { + \stemup + \$staff1_voice_1 + \bar "|."; + } + \context Voice = two \transpose c'' { + \stemdown + \$staff1_voice_2 + } > - \nonRepeatText - \context Staff=staffB < - \beginmatter + \context LyricVoice \text + \context Staff=lower < + \global \clef bass; - - \property Staff.noVoltaBraces = "1" - {\voiceone \$staff2_voice_1 \bar "|."; } - {\voicetwo \$staff2_voice_2 } + \property Staff.noVoltaBraces = ##t + \context Voice = three { + \stemup + \$staff2_voice_1 + } + \context Voice = four { + \stemdown + \$staff2_voice_2 + } > > - - -\include "paper16.ly"; - -\score{ - \automaticLyrics \paper{ \paper_sixteen textheight = 230.\mm; @@ -168,15 +175,28 @@ handLyrics = \notes \context GrandStaff < } \translator { \LyricsContext + \consists "Span_bar_engraver"; + % Urg + % 'Whose broad' still runs into the :| span-bar + %\consists "Span_bar_engraver"; + + % Urg + % Moet iemand kunnen begrijpen hoe die visibilities + % werken? + %% #'Span_bar_engraver-visibility = #all-invisible + "Span_bar_engraver-visibility" = #all-invisible + "Bar_engraver-visibility" = #all-invisible + "Span_bar::visibility-lambda" = #all-invisible } \translator { \LyricsVoiceContext \consists "Bar_engraver"; - + "Bar_engraver-visibility" = #all-invisible + "Bar::visibility-lambda" = #all-invisible } } - \midi {} + \midi { + \tempo 4 = 60; + } } - -\version "1.3.42"; diff --git a/input/test/bar-break.ly b/input/test/bar-break.ly index e9606a07ac..37a6ee138d 100644 --- a/input/test/bar-break.ly +++ b/input/test/bar-break.ly @@ -22,7 +22,7 @@ \StaffGroupContext \consists "Instrument_name_engraver"; marginScriptPadding = #10 % urg: this is in PT - instrument = #" \n \n \n \n \n \n \n \n \n \nPiano\n(For rehearsal only)" + instrument = #"Piano in het midden" } } } diff --git a/input/test/font-body.ly b/input/test/font-body.ly index 5ff097f6f9..970031c1ba 100644 --- a/input/test/font-body.ly +++ b/input/test/font-body.ly @@ -62,5 +62,6 @@ c\longa*1/4 c\breve*1/2 c1 c2 c4 c8 \time 12/8; a1. | \time 12/4; r1. r2. r4. r8. r16. r32. r64. r64. | + c2\sustaindown c\sustainup | } } diff --git a/input/test/ped.ly b/input/test/ped.ly index 40410a32f6..e69de29bb2 100644 --- a/input/test/ped.ly +++ b/input/test/ped.ly @@ -1,14 +0,0 @@ -\score{ -\context Staff \notes\relative c'{ -c\sustaindown d e f\sustainup g\sustaindown b c -c,\sustainup\sustaindown d e f \sustainup g\sustaindown b c -\property Staff.stopStartSustain = #"-P" -\property Staff.startSustain = #"P" -c,\sustainup\sustaindown d e f \sustainup g\sustaindown b c -} -\paper{ -} -\midi{ -\tempo 4 = 60; -} -} diff --git a/input/test/pedal.ly b/input/test/pedal.ly index cd7398265c..40410a32f6 100644 --- a/input/test/pedal.ly +++ b/input/test/pedal.ly @@ -1,5 +1,5 @@ \score{ -\context Staff \notes\relative c{ +\context Staff \notes\relative c'{ c\sustaindown d e f\sustainup g\sustaindown b c c,\sustainup\sustaindown d e f \sustainup g\sustaindown b c \property Staff.stopStartSustain = #"-P" diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 7b94bb1771..27e3342e51 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -13,6 +13,7 @@ #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" +#include "staff-symbol-referencer.hh" /* @@ -296,5 +297,11 @@ Chord_name::do_brew_molecule () const mol.add_at_edge (X_AXIS, RIGHT, name.inversion_mol, 0); if (!name.bass_mol.empty_b ()) mol.add_at_edge (X_AXIS, RIGHT, name.bass_mol, 0); + + s = get_elt_property ("word-space"); + if (gh_number_p (s)) + mol.dim_.interval_a_[X_AXIS][RIGHT] += gh_scm2double (s) + * staff_symbol_referencer (this).staff_space (); + return mol; } diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index 9c01181055..ef13d9f021 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -79,7 +79,8 @@ public: class Audio_piano_pedal : public Audio_item { public: - bool type_b_; + String type_str_; + Direction dir_; }; class Audio_text : public Audio_item diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 6832692129..7afd3d69e2 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -502,8 +502,14 @@ Midi_piano_pedal::str () const Byte status_byte = (char) (0xB0 + channel_i_); String str = to_str ((char)status_byte); - str += to_str ((char)0x40); - int pedal = audio_l_->type_b_ ? 0x7f : 0; + if (audio_l_->type_str_ == "Sostenuto") + str += to_str ((char)0x42); + else if (audio_l_->type_str_ == "Sustain") + str += to_str ((char)0x40); + else if (audio_l_->type_str_ == "UnaChorda") + str += to_str ((char)0x43); + + int pedal = ((1 - audio_l_->dir_) / 2 ) * 0x7f; str += to_str ((char)pedal); return str; } diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 6d0327ddc3..0a7bf172c2 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -4,7 +4,6 @@ source file of the GNU LilyPond music typesetter (c) 2000 Jan Nieuwenhuizen - */ #include "engraver.hh" @@ -17,14 +16,9 @@ #include "stem.hh" #include "side-position-interface.hh" #include "staff-symbol-referencer.hh" - - -/* - TODO: - sostenuto - una-chorda / tre-corde - */ - +#include "dictionary.hh" +#include "dictionary-iter.hh" +#include "text-item.hh" /* Urg. @@ -93,11 +87,30 @@ Sustain_pedal::do_brew_molecule () const return mol; } + + +/* + TODO: + * it would be real cool if an engraver could be initialised with a + string, ie: + + Piano_pedal_engraver::"sostenuto" + Piano_pedal_engraver::"sustain" + Piano_pedal_engraver::"una-chorda" + */ + /** engrave Piano pedals */ class Piano_pedal_engraver : public Engraver { + struct Pedal_info + { + Span_req* start_req_l_; + Drul_array req_l_drul_; + Item* item_p_; + }; + public: VIRTUAL_COPY_CONS (Translator); Piano_pedal_engraver (); @@ -110,19 +123,24 @@ protected: virtual void acknowledge_element (Score_element_info); private: - Span_req* sustain_start_req_l_; - Drul_array sustain_req_l_drul_; - Sustain_pedal* sustain_p_; + Dictionary info_dict_; }; -ADD_THIS_TRANSLATOR(Piano_pedal_engraver); +ADD_THIS_TRANSLATOR (Piano_pedal_engraver); Piano_pedal_engraver::Piano_pedal_engraver () { - sustain_p_ = 0; - sustain_req_l_drul_[START] = 0; - sustain_req_l_drul_[STOP] = 0; - sustain_start_req_l_ = 0; + (void)info_dict_["Sostenuto"]; + (void)info_dict_["Sustain"]; + (void)info_dict_["UnaChorda"]; + for (Dictionary_iter i (info_dict_); i.ok (); i++) + { + Pedal_info& p = i.val_ref (); + p.item_p_ = 0; + p.req_l_drul_[START] = 0; + p.req_l_drul_[STOP] = 0; + p.start_req_l_ = 0; + } } /* @@ -130,22 +148,26 @@ Piano_pedal_engraver::Piano_pedal_engraver () I'm a script */ void -Piano_pedal_engraver::acknowledge_element (Score_element_info i) +Piano_pedal_engraver::acknowledge_element (Score_element_info info) { - if (sustain_p_) + for (Dictionary_iter i (info_dict_); i.ok (); i++) { - if (Note_head* n = dynamic_cast (i.elem_l_)) + Pedal_info& p = i.val_ref (); + if (p.item_p_) { - Side_position_interface st (sustain_p_); - st.add_support (n); - if (st.get_axis( ) == X_AXIS - && !sustain_p_->parent_l (Y_AXIS)) - sustain_p_->set_parent (n, Y_AXIS); - } - if (Stem* s = dynamic_cast (i.elem_l_)) - { - Side_position_interface st (sustain_p_); - st.add_support (s); + if (Note_head* n = dynamic_cast (info.elem_l_)) + { + Side_position_interface st (p.item_p_); + st.add_support (n); + if (st.get_axis( ) == X_AXIS + && !p.item_p_->parent_l (Y_AXIS)) + p.item_p_->set_parent (n, Y_AXIS); + } + if (Stem* s = dynamic_cast (info.elem_l_)) + { + Side_position_interface st (p.item_p_); + st.add_support (s); + } } } } @@ -153,12 +175,16 @@ Piano_pedal_engraver::acknowledge_element (Score_element_info i) bool Piano_pedal_engraver::do_try_music (Music *m) { - if (Span_req * s = dynamic_cast(m)) + for (Dictionary_iter i (info_dict_); i.ok (); i++) { - if (s->span_type_str_ == "sustain") + Pedal_info& p = i.val_ref (); + if (Span_req * s = dynamic_cast(m)) { - sustain_req_l_drul_[s->span_dir_] = s; - return true; + if (s->span_type_str_ == i.key ()) + { + p.req_l_drul_[s->span_dir_] = s; + return true; + } } } return false; @@ -167,80 +193,96 @@ Piano_pedal_engraver::do_try_music (Music *m) void Piano_pedal_engraver::do_process_music () { - SCM s = SCM_UNDEFINED; - if (sustain_req_l_drul_[STOP] && sustain_req_l_drul_[START]) + for (Dictionary_iter i (info_dict_); i.ok (); i++) { - if (!sustain_start_req_l_) + Pedal_info& p = i.val_ref (); + SCM s = SCM_UNDEFINED; + if (p.req_l_drul_[STOP] && p.req_l_drul_[START]) { - sustain_req_l_drul_[STOP]->warning (_ ("can't find start of piano_pedal")); + if (!p.start_req_l_) + { + p.req_l_drul_[STOP]->warning (_f ("can't find start of piano pedal: %s", i.key ())); + } + else + { + s = get_property ("stopStart" + i.key ()); + } + p.start_req_l_ = p.req_l_drul_[START]; } - else + else if (p.req_l_drul_[STOP]) { - s = get_property ("stopStartSustain"); - if (!gh_string_p (s)) - s = ly_str02scm ("*Ped."); + if (!p.start_req_l_) + { + p.req_l_drul_[STOP]->warning (_f ("can't find start of piano pedal: %s", i.key ())); + } + else + { + s = get_property ("stop" + i.key ()); + } + p.start_req_l_ = 0; } - sustain_start_req_l_ = sustain_req_l_drul_[START]; - } - else if (sustain_req_l_drul_[STOP]) - { - if (!sustain_start_req_l_) + else if (p.req_l_drul_[START]) { - sustain_req_l_drul_[STOP]->warning (_ ("can't find start of piano_pedal")); + p.start_req_l_ = p.req_l_drul_[START]; + s = get_property ("start" + i.key ()); } - else + + if (s != SCM_UNDEFINED) { - s = get_property ("stopSustain"); - if (!gh_string_p (s)) - s = ly_str02scm ("*"); + if (i.key () == "Sustain") + { + p.item_p_ = new Sustain_pedal; + p.item_p_->set_elt_property ("glyph", s); + } + else + { + p.item_p_ = new Text_item; + p.item_p_->set_elt_property ("text", s); + // guh + p.item_p_->set_elt_property ("style", ly_str02scm ("italic")); + } + + Side_position_interface si (p.item_p_); + si.set_axis (Y_AXIS); + + /* Hmm, + If set to empty, it can't be centred + Howto centre non-fat text? + p.item_p_->set_empty (X_AXIS); + */ + p.item_p_->set_elt_property ("self-alignment-X", gh_int2scm (0)); + p.item_p_->add_offset_callback (Side_position_interface::aligned_on_self, X_AXIS); + p.item_p_->add_offset_callback (Side_position_interface::centered_on_parent, X_AXIS); + announce_element (Score_element_info (p.item_p_, + p.req_l_drul_[START] + ? p.req_l_drul_[START] + : p.req_l_drul_[STOP])); } - sustain_start_req_l_ = 0; - } - else if (sustain_req_l_drul_[START]) - { - sustain_start_req_l_ = sustain_req_l_drul_[START]; - s = get_property ("startSustain"); - if (!gh_string_p (s)) - s = ly_str02scm ("Ped."); - } - if (s != SCM_UNDEFINED) - { - sustain_p_ = new Sustain_pedal; - sustain_p_->set_elt_property ("glyph", s); - - - Side_position_interface si (sustain_p_); - si.set_axis (Y_AXIS); - - /* Hmm, - If set to empty, it can't be centred - Howto centre non-fat text? - sustain_p_->set_empty (X_AXIS); - */ - sustain_p_->set_elt_property ("self-alignment-X", gh_int2scm (0)); - sustain_p_->add_offset_callback (Side_position_interface::aligned_on_self, X_AXIS); - sustain_p_->add_offset_callback (Side_position_interface::centered_on_parent, X_AXIS); - announce_element (Score_element_info (sustain_p_, - sustain_req_l_drul_[START] - ? sustain_req_l_drul_[START] - : sustain_req_l_drul_[STOP])); } } void Piano_pedal_engraver::do_pre_move_processing () { - if (sustain_p_) + for (Dictionary_iter i (info_dict_); i.ok (); i++) { - side_position (sustain_p_).add_staff_support (); - typeset_element (sustain_p_); + Pedal_info& p = i.val_ref (); + if (p.item_p_) + { + side_position (p.item_p_).add_staff_support (); + typeset_element (p.item_p_); + } + p.item_p_ = 0; } - sustain_p_ = 0; } void Piano_pedal_engraver::do_post_move_processing () { - sustain_req_l_drul_[STOP] = 0; - sustain_req_l_drul_[START] = 0; + for (Dictionary_iter i (info_dict_); i.ok (); i++) + { + Pedal_info& p = i.val_ref (); + p.req_l_drul_[STOP] = 0; + p.req_l_drul_[START] = 0; + } } diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index 444028b8de..01dfab892f 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -1,5 +1,5 @@ /* - piano-pedal-performer.cc -- implement Piano_pedal_performer + piano-pedal-performer.cc -- implement Piano_pedal_performer source file of the GNU LilyPond music typesetter @@ -10,19 +10,20 @@ #include "command-request.hh" #include "musical-request.hh" #include "audio-item.hh" - - -/* - TODO: - sostenuto - una-chorda / tre-corde - */ +#include "dictionary.hh" +#include "dictionary-iter.hh" /** perform Piano pedals */ class Piano_pedal_performer : public Performer { + struct Pedal_info + { + Span_req* start_req_l_; + Drul_array req_l_drul_; + }; + public: VIRTUAL_COPY_CONS (Translator); @@ -36,43 +37,55 @@ protected: private: Link_array audio_p_arr_; - Span_req* sustain_start_req_l_; - Drul_array sustain_req_l_drul_; + Dictionary info_dict_; }; ADD_THIS_TRANSLATOR (Piano_pedal_performer); Piano_pedal_performer::Piano_pedal_performer () { - sustain_req_l_drul_[START] = 0; - sustain_req_l_drul_[STOP] = 0; - sustain_start_req_l_ = 0; + (void)info_dict_["Sostenuto"]; + (void)info_dict_["Sustain"]; + (void)info_dict_["UnaChorda"]; + for (Dictionary_iter i (info_dict_); i.ok (); i++) + { + Pedal_info& p = i.val_ref (); + p.req_l_drul_[START] = 0; + p.req_l_drul_[STOP] = 0; + p.start_req_l_ = 0; + } } void Piano_pedal_performer::do_process_music () { - if (sustain_req_l_drul_[STOP]) + for (Dictionary_iter i (info_dict_); i.ok (); i++) { - if (!sustain_start_req_l_) + Pedal_info& p = i.val_ref (); + if (p.req_l_drul_[STOP]) { - sustain_req_l_drul_[STOP]->warning (_ ("can't find start of piano_pedal")); + if (!p.start_req_l_) + { + p.req_l_drul_[STOP]->warning (_f ("can't find start of piano pedal: %s", i.key ())); + } + else + { + Audio_piano_pedal* a = new Audio_piano_pedal; + a->type_str_ = i.key (); + a->dir_ = STOP; + audio_p_arr_.push (a); + } + p.start_req_l_ = 0; } - else + + if (p.req_l_drul_[START]) { - Audio_piano_pedal* p = new Audio_piano_pedal; - p->type_b_ = false; - audio_p_arr_.push (p); + p.start_req_l_ = p.req_l_drul_[START]; + Audio_piano_pedal* a = new Audio_piano_pedal; + a->type_str_ = i.key (); + a->dir_ = START; + audio_p_arr_.push (a); } - sustain_start_req_l_ = 0; - } - - if (sustain_req_l_drul_[START]) - { - sustain_start_req_l_ = sustain_req_l_drul_[START]; - Audio_piano_pedal* p = new Audio_piano_pedal; - p->type_b_ = true; - audio_p_arr_.push (p); } } @@ -87,19 +100,27 @@ Piano_pedal_performer::do_pre_move_processing () void Piano_pedal_performer::do_post_move_processing () { - sustain_req_l_drul_[STOP] = 0; - sustain_req_l_drul_[START] = 0; + for (Dictionary_iter i (info_dict_); i.ok (); i++) + { + Pedal_info& p = i.val_ref (); + p.req_l_drul_[STOP] = 0; + p.req_l_drul_[START] = 0; + } } bool Piano_pedal_performer::do_try_music (Music* r) { - if (Span_req * s = dynamic_cast(r)) + for (Dictionary_iter i (info_dict_); i.ok (); i++) { - if (s->span_type_str_ == "sustain") + Pedal_info& p = i.val_ref (); + if (Span_req * s = dynamic_cast(r)) { - sustain_req_l_drul_[s->span_dir_] = s; - return true; + if (s->span_type_str_ == i.key ()) + { + p.req_l_drul_[s->span_dir_] = s; + return true; + } } } return false; diff --git a/lily/text-item.cc b/lily/text-item.cc index ea0c6f2475..0b0845e143 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -12,6 +12,7 @@ #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" +#include "staff-symbol-referencer.hh" Molecule Text_item::do_brew_molecule () const @@ -20,8 +21,15 @@ Text_item::do_brew_molecule () const String st = gh_string_p (style) ? ly_scm2string (style) : ""; SCM txt = get_elt_property ("text"); String t = gh_string_p (txt) ? ly_scm2string (txt) : ""; - - return paper_l ()->lookup_l(0)->text (st, t, paper_l ()); + + Molecule mol = paper_l ()->lookup_l(0)->text (st, t, paper_l ()); + + SCM s = get_elt_property ("word-space"); + if (gh_number_p (s)) + mol.dim_.interval_a_[X_AXIS][RIGHT] += gh_scm2double (s) + * staff_symbol_referencer (this).staff_space (); + + return mol; } diff --git a/ly/engraver.ly b/ly/engraver.ly index 2859461903..e32f472d02 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -144,6 +144,12 @@ VoiceContext = \translator { \consists "Melisma_engraver"; textScriptPadding = #3.0 \consists "Text_engraver"; + + startSustain = #"Ped." + stopSustain = #"*" + stopStartSustain = #"*Ped." + startUnaChorda = #"una chorda" + stopUnaChorda = #"tre chorde" \consists "Piano_pedal_engraver"; \consists "Script_engraver"; \consists "Script_column_engraver"; @@ -291,6 +297,8 @@ ChordNameContext = \translator { \type "Engraver_group_engraver"; \name ChordNames; + Generic_property_list = #generic-chord-staff-properties + \consists "Property_engraver"; \consists "Output_property_engraver"; \accepts "ChordNameVoice"; \consistsend "Axis_group_engraver"; diff --git a/ly/spanners.ly b/ly/spanners.ly index ba90491821..8af8a2e57d 100644 --- a/ly/spanners.ly +++ b/ly/spanners.ly @@ -24,8 +24,14 @@ cresc = \spanrequest \start "crescendo" endcresc = \spanrequest \stop "crescendo" % better name sustainstart/stop? -sustaindown = \spanrequest \start "sustain" -sustainup = \spanrequest \stop "sustain" +sustaindown = \spanrequest \start "Sustain" +sustainup = \spanrequest \stop "Sustain" + +unachorda = \spanrequest \start "UnaChorda" +trechorde = \spanrequest \stop "UnaChorda" + +sostenutodown = \spanrequest \start "Sostenuto" +sostenutoup = \spanrequest \stop "Sostenuto" %crescpoco = \property Voice.crescendoText = "cresc. poco a poco" %decresc = \property Voice.crescendoText = "decr." diff --git a/scm/generic-property.scm b/scm/generic-property.scm index adbf00a735..10df9e75ca 100644 --- a/scm/generic-property.scm +++ b/scm/generic-property.scm @@ -64,6 +64,7 @@ (list 'textScriptPadding number? 'padding) (list 'textVerticalAlignment dir? 'self-alignment-Y) (list 'textHorizontalAlignment dir? 'self-alignment-X) + (list 'textScriptWordSpace number? 'word-space) ) )) @@ -72,6 +73,11 @@ (list 'textScriptPadding number? 'padding) (list 'sustainPedalPadding number? 'padding)))) +(define generic-chord-name-properties + (cons "Chord_name" (list + (list 'textScriptWordSpace number? 'word-space) + (list 'chordNameWordSpace number? 'word-space)))) + (define generic-crescendo-properties (cons "Crescendo" (list (list 'verticalDirection dir? 'direction) @@ -240,3 +246,8 @@ (list generic-text-properties ) ) + +(define generic-chord-staff-properties + (list generic-chord-name-properties + ) +) diff --git a/scm/lily.scm b/scm/lily.scm index df8e73a607..7e67be562c 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -85,6 +85,7 @@ (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t))) (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f))) (define (all-visible d) '(#f . #f)) +(define (all-invisible d) '(#t . #t)) (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f))) (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f))) diff --git a/tex/p.tex b/tex/p.tex index 2f6169490e..d66fca3996 100644 --- a/tex/p.tex +++ b/tex/p.tex @@ -24,12 +24,12 @@ \baselineskip 12mm \vbox{ -\kern 50mm +\kern 20mm \hbox{ \fetatwentysixfontt \hbox { \pedalP\kern-0.06ex\pedale\kern -0.55ex\pedald\pedaldot} -\kern 100mm +\kern 50mm \pedalasterisk } } -- 2.39.2