Calculate tremolo beaming only from the repeat-count and the duration-log
of the original notes. In particular, don't use any information about
scaled durations when calculating the tremolo beaming.
(cherry picked from commit
1ace1688c305ecf144b29673fde94fccce4cc595)
protected:
Stream_event *repeat_;
protected:
Stream_event *repeat_;
- int flags_;
- // number of beams for short tremolos
- int expected_beam_count_;
// current direction of beam (first RIGHT, then LEFT)
Direction beam_dir_;
Spanner *beam_;
// current direction of beam (first RIGHT, then LEFT)
Direction beam_dir_;
Spanner *beam_;
protected:
virtual void finalize ();
void process_music ();
protected:
virtual void finalize ();
void process_music ();
{
beam_ = 0;
repeat_ = 0;
{
beam_ = 0;
repeat_ = 0;
- flags_ = 0;
- expected_beam_count_ = 0;
{
if (ASSIGN_EVENT_ONCE (repeat_, ev))
{
{
if (ASSIGN_EVENT_ONCE (repeat_, ev))
{
- int type = scm_to_int (ev->get_property ("tremolo-type"));
- /* e.g. 1 for type 8, 2 for type 16 */
- flags_ = intlog2 (type) - 2;
- expected_beam_count_ = scm_to_int (ev->get_property ("expected-beam-count"));
ev->origin ()->warning (_ ("No tremolo to end"));
repeat_ = 0;
beam_ = 0;
ev->origin ()->warning (_ ("No tremolo to end"));
repeat_ = 0;
beam_ = 0;
- expected_beam_count_ = 0;
- Grob *s = info.grob ();
+ int tremolo_type = robust_scm2int (repeat_->get_property ("tremolo-type"), 1);
+ int flags = max (0, intlog2 (tremolo_type) - 2);
+ int repeat_count = robust_scm2int (repeat_->get_property ("repeat-count"), 1);
+ int gap_count = min (flags, intlog2 (repeat_count) + 1);
- Stem::set_beaming (s, flags_, beam_dir_);
+ Grob *s = info.grob ();
+ Stem::set_beaming (s, flags, beam_dir_);
if (Stem::duration_log (s) != 1)
if (Stem::duration_log (s) != 1)
- beam_->set_property ("gap-count", scm_from_int (flags_ - expected_beam_count_));
+ beam_->set_property ("gap-count", scm_from_int (gap_count));
if (beam_dir_ == RIGHT)
{
if (beam_dir_ == RIGHT)
{
if (elt_count <= 0)
elt_count = 1;
if (elt_count <= 0)
elt_count = 1;
-
- Rational total_dur = l.main_part_;
- Rational note_dur = total_dur / Rational (elt_count * Repeated_music::repeat_count (mus));
-
- SCM tremolo_type = scm_int2num (note_dur.den ());
- int expected_beaming_ = max (0, (intlog2 (total_dur.den ()) - intlog2 (total_dur.num () + 1) - 1));
if (elt_count == 1)
{
Music *ev = make_music_by_name (ly_symbol2scm ("TremoloEvent"));
ev->set_spot (*origin);
if (elt_count == 1)
{
Music *ev = make_music_by_name (ly_symbol2scm ("TremoloEvent"));
ev->set_spot (*origin);
- ev->set_property ("tremolo-type", tremolo_type);
+ ev->set_property ("repeat-count", mus->get_property ("repeat-count"));
+ ev->set_property ("tremolo-type", mus->get_property ("tremolo-type"));
return scm_list_2 (ev->unprotect (), body->self_scm ());
}
else
return scm_list_2 (ev->unprotect (), body->self_scm ());
}
else
Music *stop_event = unsmob_music (stop_event_scm);
start_event->set_spot (*origin);
stop_event->set_spot (*origin);
Music *stop_event = unsmob_music (stop_event_scm);
start_event->set_spot (*origin);
stop_event->set_spot (*origin);
- start_event->set_property ("tremolo-type", tremolo_type);
- start_event->set_property ("expected-beam-count", scm_int2num (expected_beaming_));
+ start_event->set_property ("repeat-count", mus->get_property ("repeat-count"));
+ start_event->set_property ("tremolo-type", mus->get_property ("tremolo-type"));
return scm_list_3 (start_event_scm, body->self_scm (), stop_event_scm);
}
return scm_list_3 (start_event_scm, body->self_scm (), stop_event_scm);
}
simultaneous music, or the alternatives of repeated music.")
(elements-callback ,procedure? "Return a list of children, for use by
a sequential iterator. Takes a single music parameter.")
simultaneous music, or the alternatives of repeated music.")
(elements-callback ,procedure? "Return a list of children, for use by
a sequential iterator. Takes a single music parameter.")
- (expected-beam-count ,integer? "Expected number of non-tremolo beams
-in a tremolo repeat.")
(figure ,integer? "A bass figure.")
(force-accidental ,boolean? "If set, a cautionary accidental should
(figure ,integer? "A bass figure.")
(force-accidental ,boolean? "If set, a cautionary accidental should
(define-public (make-repeat name times main alts)
"create a repeat music expression, with all properties initialized properly"
(define-public (make-repeat name times main alts)
"create a repeat music expression, with all properties initialized properly"
+ (define (first-note-duration music)
+ "Finds the duration of the first NoteEvent by searching depth-first
+through MUSIC."
+ (if (memq 'note-event (ly:music-property music 'types))
+ (ly:music-property music 'duration)
+ (let loop ((elts (if (ly:music? (ly:music-property music 'element))
+ (list (ly:music-property music 'element))
+ (ly:music-property music 'elements))))
+ (and (pair? elts)
+ (let ((dur (first-note-duration (car elts))))
+ (if (ly:duration? dur)
+ dur
+ (loop (cdr elts))))))))
+
(let ((talts (if (< times (length alts))
(begin
(ly:warning (_ "More alternatives than repeats. Junking excess alternatives"))
(let ((talts (if (< times (length alts))
(begin
(ly:warning (_ "More alternatives than repeats. Junking excess alternatives"))
(if (equal? name "tremolo")
(let* ((dots (1- (logcount times)))
(mult (/ (* times (ash 1 dots)) (1- (ash 2 dots))))
(if (equal? name "tremolo")
(let* ((dots (1- (logcount times)))
(mult (/ (* times (ash 1 dots)) (1- (ash 2 dots))))
- (shift (- (ly:intlog2 (floor mult)))))
+ (shift (- (ly:intlog2 (floor mult))))
+ (note-duration (first-note-duration r))
+ (duration-log (if (ly:duration? note-duration)
+ (ly:duration-log note-duration)
+ 1))
+ (tremolo-type (ash 1 duration-log)))
+ (set! (ly:music-property r 'tremolo-type) tremolo-type)
(if (not (integer? mult))
(ly:warning (_ "invalid tremolo repeat count: ~a") times))
(if (memq 'sequential-music (ly:music-property main 'types))
(if (not (integer? mult))
(ly:warning (_ "invalid tremolo repeat count: ~a") times))
(if (memq 'sequential-music (ly:music-property main 'types))