--- /dev/null
+\version "2.11.51"
+
+\header {
+ texidoc = "Pitched trills on consecutive notes with the same
+name and octave should not lose accidentals; in the following
+example, accidentals should be visible for all trill-pitches.
+"
+}
+
+\relative c' {
+ \pitchedTrill
+ f4\startTrillSpan ges f\stopTrillSpan
+
+ \pitchedTrill
+ f4\startTrillSpan g gis\stopTrillSpan ~
+
+ \pitchedTrill
+ gis4\startTrillSpan ges f\stopTrillSpan
+
+ \pitchedTrill
+ g4\startTrillSpan gis f\stopTrillSpan
+
+ \pitchedTrill
+ f4\startTrillSpan gisis f\stopTrillSpan
+
+ \pitchedTrill
+ f4\startTrillSpan geses f\stopTrillSpan
+}
--- /dev/null
+\version "2.11.51"
+
+\header {
+ texidoc = "Pitched trill accidentals can be forced."
+}
+
+\relative c' {
+ \pitchedTrill
+ c4\startTrillSpan es f\stopTrillSpan
+ \pitchedTrill
+ c4\startTrillSpan es f\stopTrillSpan
+ \pitchedTrill
+ c4\startTrillSpan es f\stopTrillSpan
+ \pitchedTrill
+ c4\startTrillSpan-"forced" es! f\stopTrillSpan
+}
class Accidental_engraver : public Engraver
{
- int get_bar_number ();
void update_local_key_signature (SCM new_signature);
void create_accidental (Accidental_entry *entry, bool, bool);
Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans, bool);
return result;
}
-int
-Accidental_engraver::get_bar_number ()
-{
- SCM barnum = get_property ("internalBarNumber");
- SCM smp = get_property ("measurePosition");
-
- int bn = robust_scm2int (barnum, 0);
-
- Moment mp = robust_scm2moment (smp, Moment (0));
- if (mp.main_part_ < Rational (0))
- bn--;
-
- return bn;
-}
-
void
Accidental_engraver::process_acknowledged ()
{
{
SCM accidental_rules = get_property ("autoAccidentals");
SCM cautionary_rules = get_property ("autoCautionaries");
- int barnum = get_bar_number ();
+ int barnum = measure_number (context());
for (vsize i = 0; i < accidentals_.size (); i++)
{
/* Cannot look for ties: it's not guaranteed that they reach
us before the notes. */
- if (acc.need_acc
- && !note->in_event_class ("trill-span-event"))
- create_accidental (&accidentals_[i], acc.need_restore, cautionary);
+ if (!note->in_event_class ("trill-span-event"))
+ {
+ if (acc.need_acc)
+ create_accidental (&accidentals_[i], acc.need_restore, cautionary);
- if (forced || cautionary)
- accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T);
+ if (forced || cautionary)
+ accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T);
+ }
}
}
}
}
for (vsize i = accidentals_.size (); i--;)
- {
- int barnum = get_bar_number ();
-
+ {
Stream_event *note = accidentals_[i].melodic_;
Context *origin = accidentals_[i].origin_;
+ int barnum = measure_number (origin);
+
Pitch *pitch = unsmob_pitch (note->get_property ("pitch"));
if (!pitch)
continue;
return m;
}
+int
+measure_number (Context const *context)
+{
+ SCM barnum = context->get_property ("internalBarNumber");
+ SCM smp = context->get_property ("measurePosition");
+
+ int bn = robust_scm2int (barnum, 0);
+ Moment mp = robust_scm2moment (smp, Moment (0));
+ if (mp.main_part_ < Rational (0))
+ bn--;
+
+ return bn;
+}
+
void
set_context_property_on_children (Context *trans, SCM sym, SCM val)
Moment measure_position (Context const *context);
Rational measure_length (Context const *context);
+int measure_number (Context const *context);
void set_context_property_on_children (Context *trans, SCM sym, SCM val);
/* Shorthand for creating and broadcasting stream events. */
SCM key = scm_cons (scm_from_int (p->get_octave ()),
scm_from_int (p->get_notename ()));
+ int bn = measure_number (context());
+
SCM handle = scm_assoc (key, keysig);
+ if (handle != SCM_BOOL_F)
+ {
+ bool same_bar = (bn == robust_scm2int (scm_cddr (handle), 0));
+ bool same_alt
+ = (p->get_alteration () == robust_scm2rational (scm_cadr (handle), 0));
+
+ if (!same_bar || (same_bar && !same_alt))
+ handle = SCM_BOOL_F;
+ }
+
bool print_acc
- = (handle == SCM_BOOL_F) || p->get_alteration () == Rational (0);
+ = (handle == SCM_BOOL_F) || p->get_alteration () == Rational (0)
+ || (ev->get_property ("force-accidental") == SCM_BOOL_T);
if (trill_head_)
{
(ly:music-property ev-chord 'elements))))
(sec-note-events (get-notes secondary-note))
(trill-events (filter (lambda (m) (music-has-type m 'trill-span-event))
- (ly:music-property main-note 'elements)))
-
- (trill-pitch
- (if (pair? sec-note-events)
- (ly:music-property (car sec-note-events) 'pitch)
- )))
-
- (if (ly:pitch? trill-pitch)
- (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
- trill-events)
- (begin
- (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
- (display sec-note-events)))
+ (ly:music-property main-note 'elements))))
+ (if (pair? sec-note-events)
+ (begin
+ (let*
+ ((trill-pitch (ly:music-property (car sec-note-events) 'pitch))
+ (forced (ly:music-property (car sec-note-events ) 'force-accidental)))
+
+ (if (ly:pitch? trill-pitch)
+ (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
+ trill-events)
+ (begin
+ (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
+ (display sec-note-events)))
+
+ (if (eq? forced #t)
+ (for-each (lambda (m) (ly:music-set-property! m 'force-accidental forced))
+ trill-events)))))
main-note))