-GNUmakefile
-TAGS
-autom4te.cache
-configure
-config.cache
-config.h
-config.log
-config.make
-config.status
-.dstreamrc
-.gdbinit
-*~
#*
*.aux
*.dvi
*.tex
*.txt
*[0-9]pk
+*~
+.dstreamrc
+.gdbinit
+GNUmakefile
+TAGS
+afm
+autom4te.cache
+config.cache
+config.h
+config.log
+config.make
+config.status
+configure
+fonts
+l
+log
+ls-R
ly2dvi.dir
out
out-www
-afm
+rc
share
+stepmake
tfm
tfm.[0-9]
-stepmake
+2002-07-17 Han-Wen <hanwen@cs.uu.nl>
+
+ * lily/parser.yy (Repeated_music): shift duration log for tremolo
+ repeats, instead of klutzing around.
+
+ * lily/chord-tremolo-engraver.cc (acknowledge_grob): set X parent
+ of stem tremolo grobs.
+
+ * scm/music-functions.scm (shift-duration-log): new function, add
+ to duration log of all notes.
+
+ * lily/duration.cc: add compression factor arguments to
+ make-duration.
+ compression-factor, dot-count, duration-log: add scheme functions.
+
+ * lily/mark-engraver.cc (process_music): allow \mark to take a
+ number as argument as well.
+
+2002-07-16 Han-Wen <hanwen@cs.uu.nl>
+
+ * lily/rest.cc (after_line_breaking): only translate the whole
+ rest if we have more than 1 staff line
+
+ * lily/parser.yy (property_def): only allow #Scheme as \property
+ argument.
+
2002-07-16 Han-Wen Nienhuys <hanwen@cs.uu.nl>
* VERSION: release 1.5.68
will print flats.
@lilypond[singleline, verbatim]
-mus =\notes { \key e \major c d e f }
+mus =\notes { \key d \major cis d fis g }
\score { \notes \context Staff {
\clef "F" \mus
\clef "G"
- \transpose des'' \mus
- \transpose cis'' \mus
+ \transpose g'' \mus
+ \transpose f'' \mus
}}
@end lilypond
\repeat "tremolo" 8 { d16 e }
\repeat "tremolo" 4 { d e }
\repeat "tremolo" 2 { d e }
- \repeat "tremolo" 1 { d e }
- \repeat "tremolo" 1 { d e }
+ c4
\break
\repeat "tremolo" 4 { f'8 e }
- \repeat "tremolo" 2 { f e }
- \repeat "tremolo" 1 { f e }
+ \repeat "tremolo" 2 { f e }
+ c4
c4 c4 c4 c4
c4 c4 c4 c4
c4 c4 c4 c4
\header
{
- texidoc = "In rhythmic staffs, stems should go up, and bar lines have the size for a 5 line staff"
+ texidoc = "In rhythmic staffs, stems should go up, and bar lines have the size for a 5 line staff. The whole note hangs from the rhythmic staff."
}
\score { \notes \context RhythmicStaff
{
- r4 c4. c8 r8 c8 | c2 r2
+ r4 c4. c8 r8 c8 | c2 r2 | r1
}
}
/// moment (global time) where beam started.
Moment start_mom_;
Moment stop_mom_;
-
+ int flags_i_ ;
/// location within measure where beam started.
Moment beam_start_location_;
- int note_head_i_;
- int dots_i_;
-
bool sequential_body_b_;
Spanner * beam_p_;
Spanner * finished_beam_p_;
{
beam_p_ = finished_beam_p_ = 0;
repeat_ =0;
- note_head_i_ = 0;
- dots_i_ = 0;
+ flags_i_ = 0;
stem_tremolo_ = 0;
sequential_body_b_ = false;
}
stop_mom_ = start_mom_ + l;
sequential_body_b_ = dynamic_cast<Sequential_music*> (rp->body ());
- // ugh. should generate triplet beams.
- note_head_i_ = int (ceil (double(l.den ()) / l.num ()));
- dots_i_ = intlog2 (1+l.num ()) -1 ; // 1->0, 3->1, 7->2
- note_head_i_ = note_head_i_ <? 4;
+ Rational total_dur = l.main_part_;
+ Rational note_dur = (total_dur / Rational (repeat_->repeat_count ()));
+ flags_i_ = intlog2 ((total_dur / note_dur).num ());
+
return true;
}
beam_p_ = new Spanner (get_property ("Beam"));
beam_p_->set_grob_property ("chord-tremolo", SCM_BOOL_T);
-
SCM smp = get_property ("measurePosition");
Moment mp
= (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
}
else if (!sequential_body_b_ && !stem_tremolo_)
{
- int flags = intlog2 (note_head_i_ * repeat_->repeat_count ()) -2;
- if (flags)
+
+ if (flags_i_)
{
stem_tremolo_ = new Item (get_property ("StemTremolo"));
announce_grob(stem_tremolo_, repeat_->self_scm());
stem_tremolo_->set_grob_property ("flag-count",
- gh_int2scm (flags));
+ gh_int2scm (flags_i_));
}
}
void
Chord_tremolo_engraver::acknowledge_grob (Grob_info info)
{
- if (beam_p_)
+ if (beam_p_ && Stem::has_interface (info.grob_l_))
{
- if (Stem::has_interface (info.grob_l_))
- {
- Grob * s = info.grob_l_;
- int f = Stem::duration_log (s);
- f = (f > 2) ? f - 2 : 1;
- Stem::set_beaming (s, f, LEFT);
- Stem::set_beaming (s, f, RIGHT);
+ Grob * s = info.grob_l_;
+ Stem::set_beaming (s, flags_i_, LEFT);
+ Stem::set_beaming (s, flags_i_, RIGHT);
- SCM d = s->get_grob_property ("direction");
- if (Stem::duration_log (s) != 1)
- {
- int gap_i =Stem::duration_log (s) - ((Stem::duration_log (s) >? 2) - 2);
- beam_p_->set_grob_property ("gap", gh_int2scm (gap_i));
- }
- s->set_grob_property ("direction", d);
+ SCM d = s->get_grob_property ("direction");
+ if (Stem::duration_log (s) != 1)
+ {
+ beam_p_->set_grob_property ("gap", gh_double2scm (0.8));
+ }
+ s->set_grob_property ("direction", d);
- if (dynamic_cast <Rhythmic_req *> (info.music_cause ()))
- {
- Beam::add_stem (beam_p_, s);
- }
+ if (dynamic_cast <Rhythmic_req *> (info.music_cause ()))
+ {
+ Beam::add_stem (beam_p_, s);
+ }
+ else
+ {
+ String s = _ ("stem must have Rhythmic structure");
+ if (info.music_cause ())
+ info.music_cause ()->origin ()->warning (s);
else
- {
- String s = _ ("stem must have Rhythmic structure");
- if (info.music_cause ())
- info.music_cause ()->origin ()->warning (s);
- else
- ::warning (s);
- }
+ ::warning (s);
}
}
else if (stem_tremolo_ && Stem::has_interface (info.grob_l_))
{
Stem_tremolo::set_stem (stem_tremolo_, info.grob_l_);
-
- info.grob_l_->set_grob_property ("duration-log", gh_int2scm (intlog2 (note_head_i_)));
- }
-
-
- if (repeat_ && Note_head::has_interface (info.grob_l_))
- {
- info.grob_l_->set_grob_property ("duration-log", gh_int2scm (intlog2 (note_head_i_)));
- if (dots_i_ > 0)
- {
- Item * d = new Item (get_property ("Dots"));
- Rhythmic_head::set_dots (info.grob_l_, d);
-
- d->set_grob_property ("dot-count", gh_int2scm (dots_i_));
-
- d->set_parent (info.grob_l_, Y_AXIS);
- announce_grob (d, SCM_EOL);
- }
+ stem_tremolo_->set_parent (info.grob_l_,X_AXIS);
}
}
Chord_tremolo_iterator::construct_children ()
{
Repeated_music * rep = dynamic_cast<Repeated_music*> (music_l ());
- factor_ = Moment (Rational(1, rep->repeat_count ()));
+ factor_ = Moment (Rational(1, 1));
child_iter_p_ = get_iterator_p (rep->body ());
}
child_iter_p_->process (factor_ * m);
}
-
Moment
Chord_tremolo_iterator::pending_moment () const
{
/*
- duration.cc -- implement Duration, Plet,
-
+ duration.cc -- implement Duration
+
source file of the LilyPond music typesetter
(c) 1997--2002 Jan Nieuwenhuizen <janneke@gnu.org>
#include <assert.h>
+#include "misc.hh"
#include "lily-proto.hh"
#include "string.hh"
#include "moment.hh"
return SCM_BOOL_F;
}
-
LY_DEFINE(make_duration,
- "make-duration", 2, 0, 0, (SCM length, SCM dotcount),
+ "make-duration", 2, 2, 0, (SCM length, SCM dotcount,
+ SCM num, SCM den),
"
@var{length} is the negative logarithm (base 2) of the duration:
1 is a half note, 2 is a quarter note, 3 is an eighth
note, etc. The number of dots after the note is given by
@var{dotcount}.
+The duration factor is optionally given by @var{num} and @var{den}.
A duration is a musical duration, i.e. a length of time described by a
power of two (whole, half, quarter, etc.) and a number of augmentation
{
SCM_ASSERT_TYPE(gh_number_p(length), length, SCM_ARG1, __FUNCTION__, "integer");
SCM_ASSERT_TYPE(gh_number_p(dotcount), dotcount, SCM_ARG2, __FUNCTION__, "integer");
+
+ bool compress = false;
+ if (num != SCM_UNDEFINED)
+ {
+ SCM_ASSERT_TYPE(gh_number_p(num), length, SCM_ARG3, __FUNCTION__, "integer");
+ compress = true;
+ }
+ else
+ num = gh_int2scm (1);
+
+ if (den != SCM_UNDEFINED)
+ SCM_ASSERT_TYPE(gh_number_p(den), length, SCM_ARG4, __FUNCTION__, "integer");
+ else
+ den = gh_int2scm (1);
Duration p (gh_scm2int (length), gh_scm2int (dotcount));
+ if (compress)
+ p = p.compressed (Rational (gh_scm2int (num), gh_scm2int (den)));
+
return p.smobbed_copy ();
}
+
+
+LY_DEFINE(duration_log,
+ "duration-log", 1, 0, 0, (SCM dur),
+ "
+Extract the duration log from @var{dur}"
+)
+{
+ SCM_ASSERT_TYPE(unsmob_duration(dur), dur, SCM_ARG1, __FUNCTION__, "duration");
+
+ return gh_int2scm (unsmob_duration (dur)->duration_log ());
+}
+
+
+LY_DEFINE(dot_count_log,
+ "duration-dot-count", 1, 0, 0, (SCM dur),
+ "
+Extract the dot count from @var{dur}"
+)
+{
+ SCM_ASSERT_TYPE(unsmob_duration(dur), dur, SCM_ARG1, __FUNCTION__, "duration");
+
+ return gh_int2scm (unsmob_duration (dur)->dot_count ());
+}
+
+
+LY_DEFINE(ly_intlog2,
+ "intlog2", 1, 0, 0, (SCM d),
+ "
+Extract the dot count from @var{dur}"
+)
+{
+ SCM_ASSERT_TYPE(gh_number_p (d), d, SCM_ARG1, __FUNCTION__, "integer");
+
+ int l = intlog2 (gh_scm2int (d));
+
+ return gh_int2scm (l);
+}
+
+LY_DEFINE(compression_factor,
+ "duration-factor", 1, 0, 0, (SCM dur),
+ "
+Extract the compression factor from @var{dur}. Return as a pair."
+)
+{
+ SCM_ASSERT_TYPE(unsmob_duration(dur), dur, SCM_ARG1, __FUNCTION__, "duration");
+ Rational r =unsmob_duration (dur)->factor ();
+
+ return gh_cons(gh_int2scm (r.num()),gh_int2scm (r.den ()));
+}
+
SCM
Duration::smobbed_copy ()const
{
Duration compressed (Rational) const;
Rational length_mom () const ;
-
-
+ Rational factor () const { return factor_; }
int duration_log ()const;
int dot_count () const;
SCM smobbed_copy () const;
DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
DECLARE_SIMPLE_SMOBS (Duration,);
-
+
private:
/// Logarithm of the base duration.
int durlog_i_;
struct Tremolo_req : public Request {
VIRTUAL_COPY_CONS (Music);
Tremolo_req ();
+};
+
+struct Chord_tremolo_notify_req : public Request
+{
- void set_type (int);
- int get_type () const;
+ Rational factor_;
+ VIRTUAL_COPY_CONS(Chord_tremolo_notify_req);
+ Chord_tremolo_notify_req();
};
text_p_->set_grob_property ("text",m);
else
{
- if (!gh_string_p (m))
+ if (!gh_string_p (m) && !gh_number_p (m))
m = get_property ("rehearsalMark");
- ;
if (gh_number_p (m))
{
"Get the property @var{sym} of music expression @var{mus}.")
{
Music * sc = unsmob_music (mus);
- SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "grob");
+ SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "music");
SCM_ASSERT_TYPE(gh_symbol_p(sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
return sc->internal_get_mus_property (sym);
void
Note_heads_engraver::start_translation_timestep ()
{
-
-
}
%type <scm> chord_note chord_inversion chord_bass
%type <scm> duration_length fraction
-%type <scm> embedded_scm scalar
+%type <scm> embedded_scm
%type <music> Music Sequential_music Simultaneous_music
%type <music> relative_music re_rhythmed_music part_combined_music
%type <music> property_def translator_change
SCM func = scm_primitive_eval (ly_symbol2scm ("repeat-name-to-ctor"));
SCM result = gh_call1 (func, $2);
+ if (gh_equal_p ($2, ly_str02scm ("tremolo")))
+ {
+ /*
+ we can not get durations and other stuff correct down the line, so we have to
+ add to the duration log here.
+
+ TODO: do dots.
+ */
+ SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
+ gh_call2 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)));
+ }
+
set_music_properties (r, result);
r->set_spot (*$4->origin ());
+
$$ = r;
}
;
;
property_def:
- PROPERTY STRING '.' STRING '=' scalar {
+ PROPERTY STRING '.' STRING '=' embedded_scm {
Music *t = set_property_music (scm_string_to_symbol ($4), $6);
Context_specced_music *csm = new Context_specced_music (SCM_EOL);
}
;
-scalar:
- string { $$ = $1; }
- | bare_int { $$ = gh_int2scm ($1); }
- | embedded_scm { $$ = $1; }
- ;
-
-
request_chord:
pre_requests {
THIS->push_spot ();
Mark_req * m = new Mark_req;
$$ = m;
}
- | MARK scalar {
+ | MARK STRING {
Mark_req *m = new Mark_req;
m->set_mus_property ("label", $2);
$$ = m;
+ }
+ | MARK bare_unsigned {
+ String s(to_str ($2));
+ Mark_req *m = new Mark_req;
+ m->set_mus_property ("label", gh_int2scm ($2));
+ $$ = m;
}
| PENALTY SCM_T {
Break_req * b = new Break_req;
{
Grob *me = unsmob_grob (smob);
int bt = gh_scm2int (me->get_grob_property ("duration-log"));
- if (bt == 0)
+ if (bt == 0 && Staff_symbol_referencer::line_count (me) > 1)
{
me->translate_axis (Staff_symbol_referencer::staff_space (me) , Y_AXIS);
}
{
starter = starter <? m;
playing_durations_.insert (now_durations_[i]);
+
}
}
now_durations_.clear ();
tiny =
- \property Voice.fontSize= -2
+ \property Voice.fontSize= #-2
small =
- \property Voice.fontSize= -1
+ \property Voice.fontSize= #-1
normalsize = {
- \property Voice.fontSize= 0
+ \property Voice.fontSize= #0
}
normalkey = {
(start-moment-function . ,Repeated_music::first_start)
(length . ,Repeated_music::unfolded_music_length)))
("tremolo" . ((iterator-ctor . ,Chord_tremolo_iterator::constructor)
- (start-moment-function . ,Repeated_music::first_start)
- (length . ,Repeated_music::unfolded_music_length)))))
+ (start-moment-function . ,Repeated_music::first_start)
+
+ ;; the length of the repeat is handled by shifting the note logs
+ (length . ,Repeated_music::folded_music_length)))))
(handle (assoc name supported-reps)))
(Y-extent-callback . ,Stem_tremolo::height)
(X-extent-callback . #f)
- (beam-width . 2.0) ; staff-space
+ (beam-width . 1.6) ; staff-space
(beam-thickness . 0.48) ; staff-space
(meta . ((interfaces . (stem-tremolo-interface item-interface ))))
))
-;(debug-enable 'backtrace)
+(debug-enable 'backtrace)
(define point-and-click #f)
":"
(number->string (ly-get-mus-property mus 'denominator))
))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(define (shift-duration-log music shift )
+ "Recurse through music, adding SHIFT to duration-log to any note
+encountered. This scales the music up by a factor 2^k."
+ (let* ((es (ly-get-mus-property music 'elements))
+ (e (ly-get-mus-property music 'element))
+ (n (ly-music-name music))
+ (f (lambda (x) (shift-duration-log x shift)))
+ )
+ (if (or (equal? n "Note_req")
+ (equal? n "Rest_req"))
+ (let* (
+ (d (ly-get-mus-property music 'duration))
+ (cp (duration-factor d))
+ (nd (make-duration (+ shift (duration-log d))
+ (duration-dot-count d)
+ (car cp)
+ (cdr cp)))
+
+ )
+ (ly-set-mus-property music 'duration nd)
+ ))
+
+ (if (pair? es)
+ (ly-set-mus-property
+ music 'elements
+ (map f es)))
+
+ (if (music? e)
+ (ly-set-mus-property
+ music 'element
+ (f e)))
+ music))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (unfold-repeats music)
"
This function replaces all repeats with unfold repeats. It was
(if (equal? n "Repeated_music")
(begin
+ (if (equal? (ly-get-mus-property 'type music) 'tremolo)
+ (shift-duration-log music (- (intlog2 (ly-get-mus-property 'repeat-count music))))
+ )
(ly-set-mus-property
music 'length Repeated_music::unfolded_music_length)
(ly-set-mus-property