vertical positioning for polyphony, without RestCollision object.
* lily/note-column.cc (add_head): prevent rests & note heads on
one stem.
* lily/rest-collision.cc (do_shift): ignore rests with beams.
(do_shift): rewrite only-rests case: use common refpoints: the
routine will have sensible results when other rest-translations
have taken place.
* lily/simple-spacer.cc (solve): cleanup: remove code for linelen
< 0 case.
* input/GNUmakefile (SUBDIRS): remove ascii-art
2004-02-13 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/rest.cc (polyphonic_offset_callback): new function. Do
+ vertical positioning for polyphony, without RestCollision object.
+
+ * lily/note-column.cc (add_head): prevent rests & note heads on
+ one stem.
+
+ * lily/rest-collision.cc (do_shift): ignore rests with beams.
+ (do_shift): rewrite only-rests case: use common refpoints: the
+ routine will have sensible results when other rest-translations
+ have taken place.
+
+ * lily/simple-spacer.cc (solve): cleanup: remove code for linelen
+ < 0 case.
+
* input/GNUmakefile (SUBDIRS): remove ascii-art
2004-02-13 Jan Nieuwenhuizen <janneke@gnu.org>
the following table lists the differences:
@example
+ (old) (new)
+
\property A.B = #C \set A.B = #C
\property A.B \unset \unset A.B
\property A.B \set #C = #D \override A.B #C = #D
}
-<<<<<<< morgenlied.ly
-ignoreMelisma = \set ignoreMelismata = ##t
-ignoreMelismaOff = \unset ignoreMelismata
-=======
ignoreMelisma = \set ignoreMelismata = ##t
ignoreMelismaOff = \unset ignoreMelismata
->>>>>>> 1.20
firstVerse = \lyrics {
-<<<<<<< morgenlied.ly
- \set stanza = "1."
-=======
\set stanza = "1."
->>>>>>> 1.20
Sü -- ßes Licht! Aus
\ignoreMelisma
}
secondVerse = \lyrics {
-<<<<<<< morgenlied.ly
- \set stanza = "2."
-=======
\set stanza = "2."
->>>>>>> 1.20
Ach, der Lie -- be sanf
-- tes We -- hen schwellt mir |
das be -- weg -- te __ Herz, sanft, wie ein ge -- lieb -- ter Schmerz. __ Dürft ich |
g16(_\p fis a g fis g f e d c b a ) |
<g e>8( <es fis a> <d f b> <c e c'>) r8 r |
r8 c'( e,) f r a |
-<<<<<<< morgenlied.ly
- \once \override DynamicLineSpanner #'padding =#3
-=======
\once \override DynamicLineSpanner #'padding =#3
->>>>>>> 1.20
r8_\> << { s8 s8-\! } << { fis( g)
} \\ { c,4 } >> >> r8 <e c g> <e c g> |
<d c a>4. r8 \clef bass <d b f> <d b f> |
fis r4 <g b>8( |
<f c'>4.)
-<<<<<<< morgenlied.ly
\once \override Slur #'height-limit = #1.0
-=======
- \once \override Slur #'height-limit = #1.0
->>>>>>> 1.20
<g c>4.( | <a c>4.) <g b,> |
c,4 r8 g4 r8 |
\lyricsto "singer" \new Lyrics \firstVerse
\lyricsto "singer" \new Lyrics \secondVerse
\new PianoStaff <<
-<<<<<<< morgenlied.ly
- \set PianoStaff.instrument = \markup {
-=======
\set PianoStaff.instrument = \markup {
->>>>>>> 1.20
\bold
\bigger\bigger\bigger\bigger \huge "2. " }
\new Staff \pianoRH
g8. b16 es4. d8 |
c8. g16 es4. c8 |
\grace {
-<<<<<<< standchen.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.31
as'32[( bes ]
\revert Stem #'stroke-style }
\times 2/3 { as8[)( g)] as } c4. as8 |
g2. |
\grace {
-<<<<<<< standchen.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.31
f32[( g ]
\revert Stem #'stroke-style }
\times 2/3 { f8[)( e)] f } as4. f8 |
g8. b16 es4. d8 |
c8. g16 e4. c8 |
\grace {
-<<<<<<< standchen.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.31
a'32[( b ]
\revert Stem #'stroke-style }
\times 2/3 { a!8[)( gis)] a } c4. a8 |
R2. |
R2. |
\grace {
-<<<<<<< standchen.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.31
a32[( b ]
\revert Stem #'stroke-style }
\times 2/3 { a!8[)( gis)] a } c4. a8 |
r8\pp <es as c> <as c es> <es as c> <as c es> <es as c> |
%20
r8 <es g bes> <g bes es> <es g bes> <g bes es> <es g bes> |
-<<<<<<< standchen.ly
- \override Slur #'attachment = #'(stem . stem)
-=======
\override Slur #'attachment = #'(stem . stem)
->>>>>>> 1.31
\grace {
-<<<<<<< standchen.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.31
as'32[( bes ]
\revert Stem #'stroke-style }
<a a'>4.-> <f f'>8)
<e e'>2. |
<es! es'! >2. |
-<<<<<<< standchen.ly
- \override TextScript #'font-shape = #'italic
-=======
\override TextScript #'font-shape = #'italic
->>>>>>> 1.31
<d d'>2._"decresc."
\revert TextScript #'font-shape
<f g>4. <b, g'>8(-. <d g>-. <f g>)-. |
%80
-<<<<<<< standchen.ly
- \override TextScript #'font-shape = #'italic
-=======
\override TextScript #'font-shape = #'italic
->>>>>>> 1.31
<e g>2._"dim."
\revert TextScript #'font-shape
R1 * 3/4 * 6
}
-<<<<<<< standchen.ly
-trebleStaff = \context Staff = treble<<
- \set Staff.midiInstrument = "acoustic grand"
-=======
trebleStaff = \context Staff = treble<<
\set Staff.midiInstrument = "acoustic grand"
->>>>>>> 1.31
\global
{\clef treble
-<<<<<<< standchen.ly
\override autoBeamSettings #'(begin * * * *) = #(ly:make-moment 0 1)
-=======
- \override autoBeamSettings #'(begin * * * *) = #(ly:make-moment 0 1)
->>>>>>> 1.31
\trebleIntro
\trebleVerseOne
\trebleEentje
\trebleThrough }
>>
-<<<<<<< standchen.ly
-bassStaff = \context Staff = bass<<
- \set Staff.midiInstrument = "acoustic grand"
-=======
bassStaff = \context Staff = bass<<
\set Staff.midiInstrument = "acoustic grand"
->>>>>>> 1.31
\global
\clef bass
{\bassIntro
\score{
<<
\new Staff <<
-<<<<<<< standchen.ly
- \set Staff.midiInstrument = "synth voice"
-=======
\set Staff.midiInstrument = "synth voice"
->>>>>>> 1.31
%% insert \transpose if necessary, depending on voice range.
\global
\vocals
d'[ cis] |
%% d4 d,,2 |
d4
-<<<<<<< baerenreiter-sarabande.ly
- \override NoteHead #'after-line-breaking-callback
- = #(lambda (smob) (assert-system-count smob 6))
-=======
\override NoteHead
#'after-line-breaking-callback
= #(lambda (smob) (assert-system-count smob 6))
->>>>>>> 1.30
d,,2 |
}
a gis ~ gis16 gis fis e
\skip 4*1
\change Staff=lower \stemDown
-<<<<<<< bwv940.ly
- \override NoteColumn #'horizontal-shift = #0
-=======
\override NoteColumn #'horizontal-shift = #0
->>>>>>> 1.7
\stemUp\tieUp
b2 a |
g a4. gis16 a |
\score {
\notes \context PianoStaff <<
-<<<<<<< wtk1-fugue2.ly
\override Score.TimeSignature #'style = #'C
-=======
- \override Score.TimeSignature #'style = #'C
->>>>>>> 1.15
\context Staff = treble <<
\key c \minor
\dux
righta = \notes \transpose c cis' {
% \stemUp \slurUp \tieUp
\stemUp
-<<<<<<< romanze-op28-2.ly
- \override Slur #'attachment = #'(stem . stem)
-=======
\override Slur #'attachment = #'(stem . stem)
->>>>>>> 1.32
\repeat volta 2 {
-<<<<<<< romanze-op28-2.ly
- \override TextScript #'extra-offset = #'(-8.0 . 2.5)
-=======
\override TextScript #'extra-offset = #'(-8.0 . 2.5)
->>>>>>> 1.32
\m a,16[^\p( \u c^\markup {
\large "Einfach ("
\note #"8" #1
c_3 g,_2 es, g, h,_4 g, d, g, c g,8 f,16 |
c g, es, g, es c_3 as, c^2 d^3 c h, c |
e des b,\< des g e_3 ces_4 d_2 f^3 d cis d |
-<<<<<<< romanze-op28-2.ly
- \override PhrasingSlur #'extra-offset = #'(0 . 3)
- \override PhrasingSlur #'beautiful = #42
-=======
\override PhrasingSlur #'extra-offset = #'(0 . 3)
\override PhrasingSlur #'beautiful = #42
->>>>>>> 1.32
g\( fes des fes b g_3 es_1\! ges_2 a^3 ges f_1 ges_2 |
r ges_2 b des_1 ges b,_2 des ges,^1 b, \d des,^1 \stemDown \transpose c' c { b,[_1 as,] |
g,8 b,16[ g, e, cis,] d,\)_4 \< f, h, d_3 f_2 r16\! }
f,8.. f32^1 g8^2 a4.) |
a4^1( c8^1_\accent~[c b)] g16^1([ b^2] |
c4)^1 es8^1~es d^1 f^1~ |
-<<<<<<< romanze-op28-2.ly
\override PianoStaff.Arpeggio #'direction = #1
-=======
- \override PianoStaff.Arpeggio #'direction = #1
->>>>>>> 1.32
f f8.. f32^1( as4.)^\fermata\arpeggio ~ |
\revert PianoStaff.Arpeggio #'direction
\stemUp \tieUp as r4 r8 |
}
s2. s
\u s4. \grace {
-<<<<<<< romanze-op28-2.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.32
f8(
\revert Stem #'stroke-style }
f4) e8 |
c4) r8 f4-4( as8-5~ | as g-4 b)-5 as4-5( ces'8-4~ |
ces' b des'-4 c'4)-5( <es'-4 es''>8 |
\stemDown \tieDown des'4.)_5~des'~ |
-<<<<<<< romanze-op28-2.ly
- \override NoteColumn #'horizontal-shift = #-1 des' s
-=======
\override NoteColumn #'horizontal-shift = #-1 des' s
->>>>>>> 1.32
}
>>
\change Staff=down \stemUp \slurUp \tieUp \phrasingSlurUp
s2.*2
s8 r16 h\( c' d' es' as g8\arpeggio fis(
ges)\) f16-2( a-1 c'-3 f')-1 \grace {
-<<<<<<< romanze-op28-2.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.32
\stemDown \slurUp b,[( f] \stemUp
\revert Stem #'stroke-style }
e')-1( d' c' b-1 a-2\prall g
\score { \notes
\context PianoStaff <<
\pianoCautionaries
-<<<<<<< romanze-op28-2.ly
- \override PianoStaff.NoteCollision #'merge-differently-dotted = ##t
- \set PianoStaff.connectArpeggios = ##t
- \override PianoStaff.Arpeggio #'print-function = \arpeggioBracket
-
- \override PianoStaff.InstrumentName #'font-size = #6
- \override PianoStaff.InstrumentName #'font-shape = #'italic
- \override PianoStaff.InstrumentName #'font-magnification = #3
-=======
\override PianoStaff.NoteCollision #'merge-differently-dotted = ##t
\set PianoStaff.connectArpeggios = ##t
\override PianoStaff.Arpeggio #'print-function = \arpeggioBracket
\override PianoStaff.InstrumentName #'font-size = #6
\override PianoStaff.InstrumentName #'font-shape = #'italic
\override PianoStaff.InstrumentName #'font-magnification = #3
->>>>>>> 1.32
\set PianoStaff.instrument = "2. "
\context Staff = up {
-<<<<<<< romanze-op28-2.ly
- \override Staff.DynamicLineSpanner #'direction = #-1
-=======
\override Staff.DynamicLineSpanner #'direction = #-1
->>>>>>> 1.32
\clef G <<\global \context Voice=upv \righta >>
}
\context Staff = mid {
-<<<<<<< romanze-op28-2.ly
- \override Staff.InstrumentName #'font-size = #0
- \override Staff.InstrumentName #'font-shape = #'upright
- \override Staff.InstrumentName #'font-magnification = #1
- \override Staff.InstrumentName #'extra-offset = #'(0 . 6)
- % \set Staff.instrument = "\\begin{turn}{-90}{Rechte Hand}\\end{turn}"
- \set Staff.instrument = \markup { \column < Rechte Hand > }
-=======
\override Staff.InstrumentName #'font-size = #0
\override Staff.InstrumentName #'font-shape = #'upright
\override Staff.InstrumentName #'font-magnification = #1
\override Staff.InstrumentName #'extra-offset = #'(0 . 6)
% \set Staff.instrument = "\\begin{turn}{-90}{Rechte Hand}\\end{turn}"
\set Staff.instrument = \markup { \column < Rechte Hand > }
->>>>>>> 1.32
\clef F <<\global \context Voice=midv \rightb>>
}
\context Staff = down {
-<<<<<<< romanze-op28-2.ly
- \override Staff.DynamicLineSpanner #'direction = #1
-=======
\override Staff.DynamicLineSpanner #'direction = #1
->>>>>>> 1.32
\clef F
<< \global \context Voice=lva \lefta \context Voice=lvb \leftb >>
}
<< a1(\trill
{ s2 \grace {
-<<<<<<< mozart-hrn3-allegro.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.16
g16[ a]
\revert Stem #'stroke-style }
} >>
a, ( d g, c)
d d
\grace {
-<<<<<<< mozart-hrn3-allegro.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.16
e8(
\revert Stem #'stroke-style }
c[( b)] b4 r2
c2 (bes a) a8[(b c cis)]
d2( ~ d8[ e16 d] \grace {
-<<<<<<< mozart-hrn3-allegro.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.16
\longgrace d16( \endlonggrace
\revert Stem #'stroke-style }
c8[) b16 c)]
\grace {
-<<<<<<< mozart-hrn3-allegro.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.16
\longgrace c16 \endlonggrace
\revert Stem #'stroke-style }
b8[( a16 g)] g4 r2 |
f4. ( d8) f8[ ( d) f d]
c[ (e] g2) \grace {
-<<<<<<< mozart-hrn3-allegro.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.16
\longgrace f16( \endlonggrace
\revert Stem #'stroke-style }
e8[)( d16 c)]
<< d1\trill (
{ s2 \grace {
-<<<<<<< mozart-hrn3-allegro.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.16
c16[ d]
\revert Stem #'stroke-style }
} >>
<< d1(\trill
{ s2 \grace {
-<<<<<<< mozart-hrn3-allegro.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.16
c16[ d]
\revert Stem #'stroke-style }
} >>
c[ ( e) g g] g[( f e d)]
c4(
\grace {
-<<<<<<< mozart-hrn3-romanze.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.15
\longgrace e16 \endlonggrace
\revert Stem #'stroke-style }
\mark "C"
%% this is a trick to get the sfp-s to align.
-<<<<<<< mozart-hrn3-romanze.ly
- \override Hairpin #'transparent = ##t
-=======
\override Hairpin #'transparent = ##t
->>>>>>> 1.15
des1\sfp \>
g,1\sfp\! \>
c\sfp \! \>
R2.*7
\mark "A"
c4.\p \grace {
-<<<<<<< mozart-hrn3-rondo.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.15
e16(
\revert Stem #'stroke-style }
d8[) c d]
c4 r8 r4 r8
e4. \grace {
-<<<<<<< mozart-hrn3-rondo.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.15
g16(
\revert Stem #'stroke-style }
f8[) e f]
<< d2.(\trill
{ s2 \grace {
-<<<<<<< mozart-hrn3-rondo.ly
- \override Stem #'stroke-style = #"grace"
-=======
\override Stem #'stroke-style = #"grace"
->>>>>>> 1.15
c16[ d]
\revert Stem #'stroke-style }
} >>
-
\header {
-
texidoc = "Rests under beams are only moved if necessary."
-
}
\version "2.1.22"
+fig = \notes \relative c' {
+ <a c e>8[ r <c e a> r <e a c> r <a c e>] r |
+}
+
+
\score {
- \new Staff
- \notes {
- \stemUp
- \transpose c c' {
- c''8[ r8 c''8 c''8]
- c8[ r8 c8 c8]
- c8[ r8 r8 c'''8]
- \stemDown
- c8[ r8 c8 c8]
- c''8[ r8 c''8 c''8]
- c'8[ r8 r8 c'''8]
- }
- }
- \paper { raggedright = ##t }
+ \notes \relative c' \new Staff {
+ \fig
+ \transpose c c, \fig
+ \new Voice { \stemUp \transpose c f \fig }
+ <<
+ \\
+ \transpose f c \fig
+ >>
+
+ <<
+ { \transpose c c' \fig }
+ \\
+ {}
+ >>
+
+ << \transpose c c' \fig \\
+ \transpose f c \fig
+ >>
+ }
+
+ \paper {
+ raggedright = ##t
+ }
}
+
+++ /dev/null
-\version "2.1.22"
-
-\header
-{
-texidoc = "Rests in collisions sit opposite of the note if no direction is
- specified for the voice containing the rest."
-}
-
-
- \paper { raggedright= ##t }
-
-\score{\notes\relative c''
- \context Staff <<
-\time 2/4
-\new Voice {
- r4 }
-\new Voice {\voiceTwo
-b8 }>>}
-
<< { r8 g''4 g8 r g4 g8 } \\
{ d,4 r d r } >>
}
-
+ \paper { raggedright = ##t }
}
Column_x_positions::Column_x_positions ()
{
- satisfies_constraints_b_ = false;
+ satisfies_constraints_ = true;
force_ = 0;
}
we couldn't satisfy the constraints, this won't get better
if we add more columns, so we get on with the next one
*/
- if (!cp.satisfies_constraints_b_)
+ if (!cp.satisfies_constraints_)
break ;
}
Column_x_positions cp (optimal_paths[final_breaks[i]].line_config_);
lines.push (cp);
- if(!cp.satisfies_constraints_b_)
+ if(!cp.satisfies_constraints_)
warning ("Could not find line breaking that satisfies constraints.");
}
return lines;
Real demerit = abs (this_one.force_) + abs (prev.force_ - this_one.force_)
+ break_penalties;
- if (!this_one.satisfies_constraints_b_)
+ if (!this_one.satisfies_constraints_)
{
/*
If it doesn't satisfy constraints, we make this one
Array<Real> config_;
Real force_;
- bool satisfies_constraints_b_;
+ bool satisfies_constraints_;
Column_x_positions ();
};
{
public:
static int shift_compare (Grob *const &, Grob*const&);
-
- /** The relative position of the "voice" containing this
- chord. Normally this would be the same as the stem direction,
-
- JUNKME.
- */
-
- static Grob * accidentals (Grob*me);
static Direction dir (Grob*me);
+ static Grob * accidentals (Grob*me);
static Slice head_positions_interval (Grob* me);
static Direction static_dir (Grob*);
static void translate_rests (Grob*me,int dy);
- static Grob * first_head (Grob*me);
+ static Grob *first_head (Grob*me);
+ static Grob *get_rest (Grob*me);
static void set_stem (Grob*me,Grob*);
static void set_dotcol (Grob*me,Grob*);
static void add_head (Grob*me,Grob*);
static String glyph_name (Grob*, int, String);
static SCM brew_internal_stencil (SCM);
DECLARE_SCHEME_CALLBACK (extent_callback, (SCM,SCM));
+ DECLARE_SCHEME_CALLBACK (polyphonic_offset_callback, (SCM,SCM));
DECLARE_SCHEME_CALLBACK (print, (SCM ));
};
#endif // REST_HH
{
Real ideal_;
Real hooke_;
- bool active_b_;
+ bool is_active_;
Real block_force_;
Real range_stiffness (int, int) const;
void add_rod (int l, int r, Real dist);
Real range_ideal_len (int l, int r)const;
- Real active_blocking_force ()const;
+ Real is_activelocking_force ()const;
Real configuration_length ()const;
void set_active_states ();
- bool active_b () const;
+ bool is_active () const;
};
#endif /* SIMPLE_SPACER_HH */
#include "note-head.hh"
#include "accidental-placement.hh"
+/*
+ TODO: figure out if we can prune this class. This is just an
+ annoying layer between (rest)collision & (note-head + stem)
+ */
+
bool
Note_column::has_rests (Grob*me)
{
Axis_group_interface::add_element (me, stem);
}
+
+Grob*
+Note_column::get_rest (Grob*me)
+{
+ return unsmob_grob (me->get_grob_property ("rest"));
+}
+
void
Note_column::add_head (Grob*me,Grob *h)
{
+ bool both = false;
if (Rest::has_interface (h))
{
- me->set_grob_property ("rest", h->self_scm ());
+ if (gh_pair_p (me->get_grob_property ("note-heads")))
+ both = true;
+ else
+ me->set_grob_property ("rest", h->self_scm ());
}
else if (Note_head::has_interface (h))
{
+ if (unsmob_grob (me->get_grob_property ("rest")))
+ both = true;
Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-heads"),h);
}
- Axis_group_interface::add_element (me, h);
+
+ if (both)
+ me->warning ("Can't have rests and note heads together on a stem.");
+ else
+ Axis_group_interface::add_element (me, h);
}
/**
- translate the rest symbols vertically by amount DY_I, but only if
+ translate the rest symbols vertically by amount DY, but only if
they have no staff-position set.
*/
void
-Note_column::translate_rests (Grob*me,int dy_i)
+Note_column::translate_rests (Grob*me, int dy)
{
Grob * r = unsmob_grob (me->get_grob_property ("rest"));
if (r && !gh_number_p (r->get_grob_property ("staff-position")))
{
- r->translate_axis (dy_i * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS);
+ r->translate_axis (dy * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS);
}
}
*/
#include "warn.hh"
-#include "rest-collision.hh"
#include "engraver.hh"
-#include "note-collision.hh"
+#include "rest-collision.hh"
#include "note-column.hh"
class Rest_collision_engraver : public Engraver
TRANSLATOR_DECLARATIONS(Rest_collision_engraver);
};
-
-
Rest_collision_engraver::Rest_collision_engraver ()
{
rest_collision_ =0;
{
if (rest_collision_
|| note_columns_.is_empty ()
- || !rest_count_)
+ || !rest_count_
+ || (note_columns_.size () == rest_count_
+ && rest_count_ < 2))
return;
rest_collision_ = make_item ("RestCollision");
#include "group-interface.hh"
#include "staff-symbol-referencer.hh"
#include "duration.hh"
+#include "directional-element-interface.hh"
MAKE_SCHEME_CALLBACK (Rest_collision,force_shift_callback,2);
SCM
return gh_double2scm (0.0);
}
+
+
void
Rest_collision::add_column (Grob*me,Grob *p)
{
only add callback for the rests, since we don't move anything
else.
- (not?)
+ (not?)
*/
p->add_offset_callback (Rest_collision::force_shift_callback_proc, Y_AXIS);
p->set_grob_property ("rest-collision", me->self_scm ());
TODO: look at horizontal-shift to determine ordering between rests
for more than two voices.
- TODO: look at previous note to determine vertical position?
*/
SCM
{
Grob * e = unsmob_grob (ly_car (s));
if (unsmob_grob (e->get_grob_property ("rest")))
- rests.push (e);
+ {
+ /*
+ Ignore rests under beam.
+ */
+ Grob* st = unsmob_grob (e->get_grob_property ("stem"));
+ if (st && unsmob_grob (st->get_grob_property ("beam")))
+ continue;
+
+ rests.push (e);
+ }
else
notes.push (e);
}
[todo]
* decide not to print rest if too crowded?
-
- * ignore rests under beams.
*/
- // no rests to collide
- if (!rests.size ())
+ /*
+ no partners to collide with
+ */
+ if (rests.size () + notes.size () < 2)
return SCM_UNSPECIFIED;
- // no partners to collide with
- if (rests.size () + notes.size () < 2)
- {
- if (rests.size () == 1
- && Note_column::dir (rests[0]))
- {
- Note_column::translate_rests (rests[0],
- 4 * Note_column::dir (rests[0]));
- }
- }
- // meisjes met meisjes
+
+ Real staff_space = Staff_symbol_referencer::staff_space (me);
+ /*
+ only rests
+ */
if (!notes.size ())
{
- SCM characteristic = head_characteristic (rests[0]);
- int i = 1;
- for (; i < rests.size (); i++)
- {
- if (!gh_equal_p (head_characteristic (rests[i]), characteristic))
- break;
- }
/*
- If all durations are the same, we'll check if there are more
- rests than maximum-rest-count.
- Otherwise (different durations), we'll try to display them all
- (urg: all 3 of them, currently).
+ This is incomplete: in case of an uneven number of rests, the
+ center one should be centered on the staff.
*/
- int display_count;
- SCM s = me->get_grob_property ("maximum-rest-count");
- if (i == rests.size ()
- && gh_number_p (s) && gh_scm2int (s) < rests.size ())
+ Drul_array< Link_array <Grob > > ordered_rests;
+ for (int i= 0; i < rests.size (); i++)
{
- display_count = gh_scm2int (s);
- for (; i > display_count; i--)
+ Grob * r = Note_column::get_rest (rests[i]);
+
+ Direction d = get_grob_direction (r);
+ if (d)
{
- Grob* r = unsmob_grob (rests[i-1]->get_grob_property ("rest"));
- if (r)
- {
- Grob * d = unsmob_grob (r->get_grob_property ("dot"));
- if (d)
- d->suicide();
- r->suicide ();
- }
- rests[i-1]->suicide ();
+ ordered_rests[d].push (rests[i]);
}
+ else
+ rests[d]->warning (_("rest direction not set. Cannot resolve collision."));
}
- else
- display_count = rests.size ();
+
+ Direction d = LEFT;
+ do {
+ ordered_rests[d].sort (Note_column::shift_compare);
+ } while (flip (&d) != LEFT);
- /*
- Ugh. Should have minimum dist.
+ if (ordered_rests[UP].size () + ordered_rests[DOWN].size () < 2)
+ return SCM_UNSPECIFIED;
- Ugh. What do we do if we have three different rests?
-
- */
- int dy = display_count > 2 ? 6 : 4; // FIXME Should get dims from table.
- if (display_count > 1)
- {
- Direction d0 = Note_column::dir (rests[0]);
- Direction d1 = Note_column::dir (rests[1]);
+ Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS);
+ common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS);
- if (!d0 && !d1)
- {
- d0= UP;
- d1 = DOWN;
- }
- else if (!d0)
- d0 = - d1;
- else if (!d1)
- d1 = -d0;
-
- Note_column::translate_rests (rests[0],d0 *dy);
- Note_column::translate_rests (rests[1], d1 *dy);
+ Real diff =
+ (ordered_rests[DOWN].top ()->extent (common, Y_AXIS)[UP]
+ - ordered_rests[UP].top ()->extent (common, Y_AXIS)[DOWN]) /staff_space;
+
+ if (diff > 0)
+ {
+ int amount_down = (int) ceil (diff / 2);
+ diff -= amount_down;
+ Note_column::translate_rests (ordered_rests[DOWN].top (),
+ -2 * amount_down);
+ if (diff > 0)
+ Note_column::translate_rests (ordered_rests[UP].top (),
+ 2 * int (ceil (diff)));
}
+
+ do {
+ for (int i = ordered_rests[d].size () -1; i-- > 0;)
+ {
+ Real last_y = ordered_rests[d][i+1]->extent (common, Y_AXIS)[d];
+ Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d];
+
+ Real diff = d * ((last_y - y) /staff_space);
+ if (diff > 0)
+ Note_column::translate_rests (ordered_rests[d][i],d * (int) ceil (diff) * 2);
+ }
+ } while (flip (&d) != LEFT);
}
- // meisjes met jongetjes
else
{
+ /*
+ Rests and notes.
+ */
if (rests.size () > 1)
{
warning (_ ("too many colliding rests"));
}
Grob * rcol = rests[0];
+ Grob *common = common_refpoint_of_array (notes, rcol, Y_AXIS);
+
Direction dir = Note_column::dir (rests[0]);
-
- if (!dir)
- {
- dir = - Note_column::dir (notes[0]);
- }
- Grob * r = unsmob_grob (rcol->get_grob_property ("rest"));
- Interval restdim = r->extent (r, Y_AXIS); // ??
-
+
+ Interval restdim = rcol->extent (common, Y_AXIS);
if (restdim.is_empty ())
return SCM_UNSPECIFIED;
-
Real staff_space = Staff_symbol_referencer::staff_space (rcol);
-
Real minimum_dist = robust_scm2double (me->get_grob_property ("minimum-distance"), 1.0) * staff_space;
-
- Grob *common = common_refpoint_of_array (notes, rcol, Y_AXIS);
-
Interval notedim;
for (int i = 0; i < notes.size (); i++)
{
notedim.unite (notes[i]->extent (common, Y_AXIS));
}
- Interval inter (notedim);
- inter.intersect (restdim);
-
Real dist =
minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0;
// move by whole spaces inside the staff.
if (discrete_dist < stafflines+1)
discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
-
+
Note_column::translate_rests (rcol,dir * discrete_dist);
}
return SCM_UNSPECIFIED;
#include "dots.hh"
#include "paper-score.hh"
#include "staff-symbol-referencer.hh"
+#include "directional-element-interface.hh"
// -> offset callback
MAKE_SCHEME_CALLBACK (Rest,after_line_breaking,1);
return ly_interval2scm (unsmob_stencil (m)->extent (a));
}
-
+MAKE_SCHEME_CALLBACK (Rest,polyphonic_offset_callback,2);
+SCM
+Rest::polyphonic_offset_callback (SCM smob, SCM)
+{
+ Grob* me = unsmob_grob (smob);
+ Direction d = get_grob_direction (me);
+ Real off = 2* d ;
+ if(off)
+ off *= Staff_symbol_referencer::staff_space (me);
+ return gh_double2scm (off);
+}
ADD_INTERFACE (Rest,"rest-interface",
"a rest",
Real den =0.0;
for (int i=l; i < r; i++)
{
- if (springs_[i].active_b_)
+ if (springs_[i].is_active_)
den += 1 / springs_[i].hooke_;
}
}
Real
-Simple_spacer::active_blocking_force () const
+Simple_spacer::is_activelocking_force () const
{
Real bf = - infinity_f;
for (int i=0; i < springs_.size (); i++)
- if (springs_[i].active_b_)
+ if (springs_[i].is_active_)
{
bf = bf >? springs_[i].block_force_;
}
{
/* float comparison is safe, since force is only copied. */
for (int i=0 ; i <springs_.size (); i++)
- if (springs_[i].active_b_
+ if (springs_[i].is_active_
&& springs_[i].block_force_ >= force_)
{
- springs_[i].active_b_ = false;
+ springs_[i].is_active_ = false;
active_count_ --;
}
}
}
bool
-Simple_spacer::active_b () const
+Simple_spacer::is_active () const
{
return active_count_;
}
void
Simple_spacer::my_solve_linelen ()
{
- while (active_b ())
+ while (is_active ())
{
- force_ = active_blocking_force ();
+ force_ = is_activelocking_force ();
Real conf = configuration_length ();
if (conf < line_len_)
void
Simple_spacer::my_solve_natural_len ()
{
- while (active_b ())
+ while (is_active ())
{
- force_ = active_blocking_force () >? 0.0;
+ force_ = is_activelocking_force () >? 0.0;
if (force_ < 1e-8) // ugh.,
break;
if (isinf (desc.hooke_))
{
- desc.active_b_ = false;
+ desc.is_active_ = false;
springs_.push (desc);
}
else
}
}
}
-
-
}
/*
void
Simple_spacer::solve (Column_x_positions *positions, bool ragged)
{
- /*
- TODO: should support natural length on only the last line.
- */
- ragged = ragged || (line_len_ < 0) ;
if (ragged)
my_solve_natural_len ();
else
my_solve_linelen ();
positions->force_ = force_;
+
/*
We used to have a penalty for compression, no matter what, but that
fucked up wtk1-fugue2 (taking 3 full pages.)
*/
-
positions->config_.push (indent_);
for (int i=0; i <springs_.size (); i++)
{
For raggedright, we must have a measure of music density: this is
to prevent lots of short lines (which all have force = 0).
*/
- if (ragged && line_len_ > 0)
+ if (ragged)
{
Real len = positions->config_.top ();
- positions->force_ = (line_len_ - len) * active_springs_stiffness ();
+ if (line_len_ - len >= 0)
+ positions->force_ = ((line_len_ - len) * active_springs_stiffness ());
+ else
+ {
+ positions->force_ = 0.0;
+ /*
+ Don't go past end-of-line in ragged right.
+ */
+ positions->satisfies_constraints_ = false;
+ }
}
positions->cols_ = spaced_cols_;
positions->loose_cols_ = loose_cols_;
- positions->satisfies_constraints_b_ = (line_len_ < 0) || active_b ();
+ positions->satisfies_constraints_ =
+ positions->satisfies_constraints_ && is_active ();
/*
Check if breaking constraints are met.
}
- positions->satisfies_constraints_b_ =
- positions->satisfies_constraints_b_ && break_satisfy;
-
- if (ragged && force_ < 0)
- positions->satisfies_constraints_b_ = false;
+ positions->satisfies_constraints_ =
+ positions->satisfies_constraints_ && break_satisfy;
}
/****************************************************************/
{
ideal_ =0.0;
hooke_ =0.0;
- active_b_ = true;
+ is_active_ = true;
block_force_ = 0.0;
}
Real
Spring_description::length (Real f) const
{
- if (!active_b_)
+ if (!is_active_)
f = block_force_;
return ideal_ + f / hooke_ ;
}
(X-extent-callback . ,Rest::extent_callback)
(Y-extent-callback . ,Rest::extent_callback)
(print-function . ,Rest::print)
- (Y-offset-callbacks . (,Staff_symbol_referencer::callback))
+ (Y-offset-callbacks . (,Staff_symbol_referencer::callback
+ ,Rest::polyphonic_offset_callback
+ ))
(minimum-distance . 0.25)
(meta . (
(interfaces . (font-interface
))
(define direction-polyphonic-grobs
- '(Tie Slur Script TextScript Stem Dots DotColumn))
+ '(Tie Rest Slur Script TextScript Stem Dots DotColumn))
(define-public (make-voice-props-set n)
(make-sequential-music
check_clef(value)
elif keyword == "name":
value = re.sub ('\\\\','\\\\\\\\', value)
- voices_append ("\\property Staff.instrument = %s\n" % value )
+ voices_append ("\\set Staff.instrument = %s\n" % value )
__main__.part_names = 1
elif keyword == "sname" or keyword == "snm":
- voices_append ("\\property Staff.instr = %s\n" % value )
+ voices_append ("\\set Staff.instr = %s\n" % value )
else:
break
"""
Nowadays abc2ly outputs explicits barlines (?)
"""
- outf.write ("\n\\property Score.defaultBarType=\"empty\"\n")
+ outf.write ("\n\\set Score.defaultBarType=\"empty\"\n")
def dump_slyrics (outf):
if a == 'C':
if not state.common_time:
state.common_time = 1
- voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
+ voices_append ("\\override Staff.TimeSignature #\'style = #'C\n")
a = '4/4'
if a == 'C|':
if not state.common_time:
state.common_time = 1
- voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n")
+ voices_append ("\\override Staff.TimeSignature #\'style = #'C\n")
a = '2/2'
if not length_specified:
set_default_len_from_time_sig (a)
str = string.join (map (lambda x: '(volta %s)' % x, strs))
- e = e + ' \\property Score.repeatCommands = #\'(%s) ' % str
+ e = e + ' \\set Score.repeatCommands = #\'(%s) ' % str
if g.force_break:
e = e + ' \\break '