From 051d7e7cbdbbe5f5337ab2b477b0bd1e72eedd04 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 28 Sep 2002 21:40:44 +0000 Subject: [PATCH] * lily/parser.yy (command_element): move clef stuff into Scheme. * lily/part-combine-music.cc: removed file and class. * lily/context-specced-music-iterator.cc (class Context_specced_music_iterator): new file. Obsoletes the Context_specced_music type. * scm/music-types.scm (make-repeated-music): put different kinds of repeated music into music-type table. * lily/include/command-request.hh: removed lily/include/musical-request.hh: removed. Removed all _req classes except Key_change_req. Changes throughout. --- ChangeLog | 4 + lily/auto-beam-engraver.cc | 4 +- lily/chord-tremolo-engraver.cc | 2 +- lily/completion-note-heads-engraver.cc | 16 +- lily/duration.cc | 4 +- lily/folded-repeat-iterator.cc | 2 +- lily/grace-music.cc | 4 +- lily/grob-pq-engraver.cc | 2 +- lily/include/duration.hh | 2 +- lily/include/grace-music.hh | 2 +- lily/include/lyric-combine-music.hh | 2 +- lily/include/midi-item.hh | 2 +- lily/include/music-iterator.hh | 2 +- lily/include/music-list.hh | 4 +- lily/include/music-wrapper.hh | 2 +- lily/include/music.hh | 2 +- lily/include/repeated-music.hh | 6 +- lily/include/request.hh | 2 +- lily/lyric-combine-music.cc | 4 +- lily/midi-item.cc | 2 +- lily/midi-walker.cc | 4 +- lily/music-iterator.cc | 4 +- lily/music-sequence.cc | 6 +- lily/music-wrapper.cc | 4 +- lily/music.cc | 2 +- lily/note-performer.cc | 2 +- lily/parser.yy | 28 +-- lily/part-combine-music-iterator.cc | 4 +- lily/percent-repeat-engraver.cc | 2 +- lily/percent-repeat-iterator.cc | 2 +- lily/porrectus-engraver.cc | 2 +- lily/repeated-music.cc | 18 +- lily/request.cc | 6 +- lily/score.cc | 2 +- lily/sequential-iterator.cc | 12 +- lily/sequential-music.cc | 2 +- lily/simple-music-iterator.cc | 4 +- lily/simultaneous-music.cc | 2 +- lily/spacing-engraver.cc | 6 +- lily/tempo-performer.cc | 2 +- lily/tie-performer.cc | 2 +- lily/tuplet-engraver.cc | 2 +- lily/untransposable-music.cc | 7 + scm/clef.scm | 65 ++++--- scm/music-types.scm | 247 ++++++++++++------------- 45 files changed, 263 insertions(+), 244 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ee5170aeb..1fd875d5cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2002-09-28 Han-Wen Nienhuys + * lily/parser.yy (command_element): move clef stuff into Scheme. + + * lily/: rename length_mom () to get_length() + * lily/part-combine-music.cc: removed file and class. * lily/context-specced-music-iterator.cc (class diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 2d16ffcf0b..55e47bb13c 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -417,7 +417,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) return ; - Moment dur = unsmob_duration (m->get_mus_property ("duration"))->length_mom (); + Moment dur = unsmob_duration (m->get_mus_property ("duration"))->get_length (); /* FIXME: This comment has been here since long: @@ -453,7 +453,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) durlog - 2); stems_->push (stem); last_add_mom_ = now; - extend_mom_ = (extend_mom_ >? now) + m->length_mom (); + extend_mom_ = (extend_mom_ >? now) + m->get_length (); } } diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index d94d752553..bf3859264f 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -82,7 +82,7 @@ Chord_tremolo_engraver::try_music (Music * m) && rp->get_mus_property ("iterator-ctor") == Chord_tremolo_iterator::constructor_proc && !repeat_) { - Moment l = rp->length_mom (); + Moment l = rp->get_length (); repeat_ = rp; start_mom_ = now_mom (); stop_mom_ = start_mom_ + l; diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index a9caf8a7ac..5b89b08a97 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -73,7 +73,7 @@ Completion_heads_engraver::try_music (Music *m) note_reqs_.push (m); first_b_ = true; - Moment musiclen = m->length_mom (); + Moment musiclen = m->get_length (); Moment now = now_mom(); if (now_mom ().grace_part_) @@ -122,7 +122,7 @@ Completion_heads_engraver::find_nearest_duration (Rational length) /* this could surely be done more efficient. Left to the reader as an excercise. */ - while (d.length_mom () > length && d.duration_log () < log_limit) + while (d.get_length () > length && d.duration_log () < log_limit) { if (d.dot_count ()) { @@ -141,7 +141,7 @@ Completion_heads_engraver::find_nearest_duration (Rational length) d = Duration (d.duration_log (), 0); // scale up. - d = d.compressed (length / d.length_mom ()); + d = d.compressed (length / d.get_length ()); } return d; @@ -171,22 +171,22 @@ Completion_heads_engraver::process_music () note_dur = *orig; } Moment nb = next_barline_moment (); - if (nb < note_dur.length_mom ()) + if (nb < note_dur.get_length ()) { note_dur = find_nearest_duration (nb.main_part_); Moment next = now; - next.main_part_ += note_dur.length_mom (); + next.main_part_ += note_dur.get_length (); top_engraver ()->add_moment_to_process (next); do_nothing_until_ = next.main_part_; } if (orig) { - left_to_do_ = orig->length_mom (); + left_to_do_ = orig->get_length (); } - if (orig && note_dur.length_mom() != orig->length_mom()) + if (orig && note_dur.get_length () != orig->get_length ()) { if (!scratch_note_reqs_.size ()) for (int i = 0; i < note_reqs_.size (); i++) @@ -243,7 +243,7 @@ Completion_heads_engraver::process_music () notes_.push (note); } - left_to_do_ -= note_dur.length_mom (); + left_to_do_ -= note_dur.get_length (); /* diff --git a/lily/duration.cc b/lily/duration.cc index a036c55f52..2ad688ec5f 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -22,7 +22,7 @@ int Duration::compare (Duration const &left, Duration const &right) { - return Rational::compare (left.length_mom (), right.length_mom ()); + return Rational::compare (left.get_length (), right.get_length ()); } Duration::Duration () @@ -48,7 +48,7 @@ Duration::compressed (Rational m) const } Rational -Duration::length_mom () const +Duration::get_length () const { Rational mom (1 << abs (durlog_)); diff --git a/lily/folded-repeat-iterator.cc b/lily/folded-repeat-iterator.cc index 4c72fcf1b1..06fefb1f4a 100644 --- a/lily/folded-repeat-iterator.cc +++ b/lily/folded-repeat-iterator.cc @@ -118,7 +118,7 @@ Folded_repeat_iterator::leave_body () main_iter_->quit (); main_iter_ = 0; - main_length_mom_ += mus->body ()->length_mom (); + main_length_mom_ += mus->body ()->get_length (); } void diff --git a/lily/grace-music.cc b/lily/grace-music.cc index 08fc36616f..3cf9414727 100644 --- a/lily/grace-music.cc +++ b/lily/grace-music.cc @@ -17,7 +17,7 @@ Grace_music::compress (Moment m) } Moment -Grace_music::length_mom () const +Grace_music::get_length () const { Moment m ; return m; @@ -27,7 +27,7 @@ Grace_music::length_mom () const Moment Grace_music::start_mom () const { - Moment l = Music_wrapper::length_mom (); + Moment l = Music_wrapper::get_length (); Moment gl; gl.grace_part_ = -(l.main_part_ + l.grace_part_ ); return gl; diff --git a/lily/grob-pq-engraver.cc b/lily/grob-pq-engraver.cc index 856650300b..4aa8a63cd6 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -62,7 +62,7 @@ Grob_pq_engraver::acknowledge_grob (Grob_info gi) if (m) { Moment n = now_mom (); - Moment l = m->length_mom (); + Moment l = m->get_length (); if (!l.to_bool ()) return ; diff --git a/lily/include/duration.hh b/lily/include/duration.hh index fff532d980..c6c194d226 100644 --- a/lily/include/duration.hh +++ b/lily/include/duration.hh @@ -25,7 +25,7 @@ public: String string () const; Duration compressed (Rational) const; - Rational length_mom () const ; + Rational get_length () const ; Rational factor () const { return factor_; } int duration_log ()const; int dot_count () const; diff --git a/lily/include/grace-music.hh b/lily/include/grace-music.hh index 37d1888d87..3c324eb7cb 100644 --- a/lily/include/grace-music.hh +++ b/lily/include/grace-music.hh @@ -19,7 +19,7 @@ public: Grace_music (); protected: virtual void compress (Moment); - virtual Moment length_mom () const; + virtual Moment get_length () const; virtual Moment start_mom () const; }; diff --git a/lily/include/lyric-combine-music.hh b/lily/include/lyric-combine-music.hh index 2885450af6..100f03e723 100644 --- a/lily/include/lyric-combine-music.hh +++ b/lily/include/lyric-combine-music.hh @@ -22,7 +22,7 @@ public: virtual void transpose (Pitch); VIRTUAL_COPY_CONS (Music); - virtual Moment length_mom () const; + virtual Moment get_length () const; virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); }; diff --git a/lily/include/midi-item.hh b/lily/include/midi-item.hh index 8739912a6d..0e52ccf004 100644 --- a/lily/include/midi-item.hh +++ b/lily/include/midi-item.hh @@ -121,7 +121,7 @@ class Midi_note : public Midi_item public: Midi_note (Audio_note*); - Moment length_mom () const; + Moment get_length () const; int get_pitch () const; virtual String string () const; diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index e005bd60d3..e90054a4cf 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -67,7 +67,7 @@ protected: public: VIRTUAL_COPY_CONS (Music_iterator); - Moment music_length_mom () const; + Moment music_get_length () const; Moment music_start_mom () const; Music_iterator (); Music_iterator (Music_iterator const&); diff --git a/lily/include/music-list.hh b/lily/include/music-list.hh index 3f957eef8b..c2895a1fdd 100644 --- a/lily/include/music-list.hh +++ b/lily/include/music-list.hh @@ -21,7 +21,7 @@ class Simultaneous_music : public Music_sequence public: VIRTUAL_COPY_CONS (Music); virtual Pitch to_relative_octave (Pitch); - virtual Moment length_mom () const; + virtual Moment get_length () const; virtual Moment start_mom () const; Simultaneous_music (); }; @@ -46,7 +46,7 @@ class Sequential_music : public Music_sequence { public: VIRTUAL_COPY_CONS (Music); - virtual Moment length_mom () const; + virtual Moment get_length () const; virtual Moment start_mom () const; Sequential_music (); diff --git a/lily/include/music-wrapper.hh b/lily/include/music-wrapper.hh index bd2ebb5056..d9360d959a 100644 --- a/lily/include/music-wrapper.hh +++ b/lily/include/music-wrapper.hh @@ -28,7 +28,7 @@ public: VIRTUAL_COPY_CONS (Music); - virtual Moment length_mom () const; + virtual Moment get_length () const; virtual Moment start_mom () const; virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); diff --git a/lily/include/music.hh b/lily/include/music.hh index a8457dee8b..7f6c4e8950 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -49,7 +49,7 @@ public: virtual Pitch to_relative_octave (Pitch); /// The duration of this piece of music - virtual Moment length_mom () const; + virtual Moment get_length () const; virtual Moment start_mom () const; void print () const; /// Transpose, with the interval central C to #p# diff --git a/lily/include/repeated-music.hh b/lily/include/repeated-music.hh index 833609261c..703d35cf1a 100644 --- a/lily/include/repeated-music.hh +++ b/lily/include/repeated-music.hh @@ -56,9 +56,9 @@ public: int repeat_count ( ) const; virtual Pitch to_relative_octave (Pitch); - Moment body_length_mom () const; - Moment alternatives_length_mom (bool fold) const; - Moment alternatives_volta_length_mom () const; + Moment body_get_length () const; + Moment alternatives_get_length (bool fold) const; + Moment alternatives_volta_get_length () const; DECLARE_SCHEME_CALLBACK (unfolded_music_length, (SCM)); DECLARE_SCHEME_CALLBACK (volta_music_length, (SCM)); diff --git a/lily/include/request.hh b/lily/include/request.hh index eb8f3f0467..292028e4c6 100644 --- a/lily/include/request.hh +++ b/lily/include/request.hh @@ -29,7 +29,7 @@ public: VIRTUAL_COPY_CONS (Music); virtual void compress (Moment); virtual void transpose (Pitch); - virtual Moment length_mom () const; + virtual Moment get_length () const; virtual Pitch to_relative_octave (Pitch); }; diff --git a/lily/lyric-combine-music.cc b/lily/lyric-combine-music.cc index 3dbc450707..8edc61903f 100644 --- a/lily/lyric-combine-music.cc +++ b/lily/lyric-combine-music.cc @@ -26,9 +26,9 @@ Lyric_combine_music::transpose (Pitch p) Moment -Lyric_combine_music::length_mom () const +Lyric_combine_music::get_length () const { - return get_music ()->length_mom (); + return get_music ()->get_length (); } Pitch diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 2a0b6a274f..49f02dad9d 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -228,7 +228,7 @@ Midi_note::Midi_note (Audio_note* a) } Moment -Midi_note::length_mom () const +Midi_note::get_length () const { Moment m = audio_->length_mom_; #if 0 diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 40aa3af5e7..66031d73cb 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -55,7 +55,7 @@ void Midi_walker::do_start_note (Midi_note* note) { Audio_item* ptr = (*items_)[index_]; - Moment stop_mom = note->length_mom () + ptr->audio_column_->at_mom (); + Moment stop_mom = note->get_length () + ptr->audio_column_->at_mom (); bool play_start = true; for (int i=0; i < stop_note_queue.size (); i++) @@ -151,7 +151,7 @@ Midi_walker::process () //midi->channel_ = track_->number_; if (Midi_note* note = dynamic_cast (midi)) { - if (note->length_mom ().to_bool ()) + if (note->get_length ().to_bool ()) do_start_note (note); } else diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 7d632c7f13..7524190cd0 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -106,14 +106,14 @@ Music_iterator::get_static_get_iterator (Music *m) p->music_ = m; assert (m); - p->music_length_ = m->length_mom (); + p->music_length_ = m->get_length (); p->start_mom_ = m->start_mom (); return iter; } Moment -Music_iterator::music_length_mom () const +Music_iterator::music_get_length () const { return music_length_; } diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index 1dc61a3866..0b38de2006 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -54,7 +54,7 @@ Music_sequence::cumulative_length (SCM l) for (SCM s = l; gh_pair_p (s); s = ly_cdr (s)) { - Moment l = unsmob_music (ly_car (s))->length_mom (); + Moment l = unsmob_music (ly_car (s))->get_length (); if (last_len.grace_part_ && l.main_part_) { last_len.grace_part_ = Rational (0); @@ -83,7 +83,7 @@ Music_sequence::maximum_length (SCM l) for (SCM s = l; gh_pair_p (s); s = ly_cdr (s)) { Music * m = unsmob_music (ly_car (s)); - Moment l = m->length_mom (); + Moment l = m->get_length (); dur = dur >? l; } @@ -154,7 +154,7 @@ Music_sequence::first_start (SCM l) for (SCM s = l; gh_pair_p (s); s = ly_cdr (s)) { Music * mus = unsmob_music (ly_car (s)); - Moment l = mus->length_mom (); + Moment l = mus->get_length (); Moment s = mus->start_mom (); if (l.to_bool () || s.to_bool ()) return s; diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index 222bda0fcd..a30b03958d 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -27,9 +27,9 @@ Music_wrapper::Music_wrapper () } Moment -Music_wrapper::length_mom () const +Music_wrapper::get_length () const { - return element ()->length_mom (); + return element ()->get_length (); } Pitch diff --git a/lily/music.cc b/lily/music.cc index f72290d546..2b85a4f423 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -90,7 +90,7 @@ Music::mark_smob (SCM m) } Moment -Music::length_mom () const +Music::get_length () const { SCM l = get_mus_property ("length"); if (unsmob_moment (l)) diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 35b93e58bd..5390447402 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -48,7 +48,7 @@ Note_performer::create_audio_elements () { Music* n = note_reqs_.pop (); Pitch pit = * unsmob_pitch (n->get_mus_property ("pitch")); - Audio_note* p = new Audio_note (pit, n->length_mom (), transposing_i); + Audio_note* p = new Audio_note (pit, n->get_length (), transposing_i); Audio_element_info info (p, n); announce_element (info); notes_.push (p); diff --git a/lily/parser.yy b/lily/parser.yy index fcb719e317..72bc32d8ef 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -661,7 +661,7 @@ music_output_def_body: Duration *d = unsmob_duration ($2->get_mus_property ("duration")); Midi_def * md = dynamic_cast ($$); if (md) - md->set_tempo (d->length_mom (), m); + md->set_tempo (d->get_length (), m); } | music_output_def_body error { @@ -1223,7 +1223,7 @@ command_element: csm->set_mus_property ("context-type", scm_makfrom0str ("Timing")); } | PARTIAL duration_length { - Moment m = - unsmob_duration ($2)->length_mom (); + Moment m = - unsmob_duration ($2)->get_length (); Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ()); Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic"); @@ -1234,25 +1234,13 @@ command_element: sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing")); } | CLEF STRING { - SCM func = scm_primitive_eval (ly_symbol2scm ("clef-name-to-properties")); - SCM result = gh_call1 (func, $2); - - SCM l = SCM_EOL; - for (SCM s = result ; gh_pair_p (s); s = ly_cdr (s)) { - Music * p = MY_MAKE_MUSIC("Music"); - set_music_properties (p, ly_car (s)); - l = scm_cons (p->self_scm (), l); - scm_gc_unprotect_object (p->self_scm ()); - } - Music * seq = MY_MAKE_MUSIC("SequentialMusic"); - seq->set_mus_property ("elements", l); - - Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic"); - sp->set_mus_property ("element", seq->self_scm ()); - scm_gc_unprotect_object (seq->self_scm ()); + static SCM proc ; + if (!proc) + proc = scm_c_eval_string ("make-clef-set"); - $$ =sp ; - sp-> set_mus_property ("context-type", scm_makfrom0str ("Staff")); + SCM result = scm_call_1 (proc, $2); + scm_gc_protect_object (result); + $$ = unsmob_music (result); } | TIME_T fraction { Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2); diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index 4a997c0968..9a4c25b529 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -247,14 +247,14 @@ Part_combine_music_iterator::get_state (Moment) { scm_sort_list_x (first_durations, scm_primitive_eval (ly_symbol2scm ("Duration::less_p"))); - first_mom += unsmob_duration (ly_car (first_durations))->length_mom (); + first_mom += unsmob_duration (ly_car (first_durations))->get_length (); } if (second_durations != SCM_EOL) { scm_sort_list_x (second_durations, scm_primitive_eval (ly_symbol2scm ("Duration::less_p"))); - second_mom += unsmob_duration (ly_car (second_durations))->length_mom (); + second_mom += unsmob_duration (ly_car (second_durations))->get_length (); } if (first_pitches != SCM_EOL && second_pitches == SCM_EOL diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index 2a589e8cd5..4a16ae5992 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -88,7 +88,7 @@ Percent_repeat_engraver::try_music (Music * m) == Percent_repeat_iterator::constructor_proc && !repeat_) { - body_length_ = rp->body_length_mom (); + body_length_ = rp->body_get_length (); int count = rp->repeat_count (); Moment now = now_mom (); diff --git a/lily/percent-repeat-iterator.cc b/lily/percent-repeat-iterator.cc index d09e6c8f3b..ba2c5b89e4 100644 --- a/lily/percent-repeat-iterator.cc +++ b/lily/percent-repeat-iterator.cc @@ -48,7 +48,7 @@ void Percent_repeat_iterator::construct_children () { Repeated_music * mus =dynamic_cast (get_music ()); - finish_mom_ = mus->length_mom (); + finish_mom_ = mus->get_length (); child_iter_ = unsmob_iterator (get_iterator (mus->body ())); } diff --git a/lily/porrectus-engraver.cc b/lily/porrectus-engraver.cc index b06806eeb5..2d9f6eef13 100644 --- a/lily/porrectus-engraver.cc +++ b/lily/porrectus-engraver.cc @@ -96,7 +96,7 @@ Porrectus_engraver::acknowledge_grob (Grob_info info_) if (m->is_mus_type ("note-event")) right_heads_.push (Grob_pitch_tuple (info_.grob_, m, now_mom () + - m->length_mom ())); + m->get_length ())); } } diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index 3a2ed5eb6c..28b2c0aca6 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -62,7 +62,7 @@ Repeated_music::compress (Moment p) } Moment -Repeated_music::alternatives_length_mom (bool fold) const +Repeated_music::alternatives_get_length (bool fold) const { if (!alternatives ()) return 0; @@ -76,7 +76,7 @@ Repeated_music::alternatives_length_mom (bool fold) const SCM p = alternatives (); while (gh_pair_p (p) && done < repeat_count ()) { - m = m + unsmob_music (ly_car (p))->length_mom (); + m = m + unsmob_music (ly_car (p))->get_length (); done ++; if (repeat_count () - done < scm_ilength (alternatives ())) p = ly_cdr (p); @@ -89,7 +89,7 @@ Repeated_music::alternatives_length_mom (bool fold) const of volta repeats, where the alternatives are iterated just as they were entered. */ Moment -Repeated_music::alternatives_volta_length_mom () const +Repeated_music::alternatives_volta_get_length () const { if (!alternatives ()) return 0; @@ -98,7 +98,7 @@ Repeated_music::alternatives_volta_length_mom () const SCM p = alternatives (); while (gh_pair_p (p)) { - m = m + unsmob_music (ly_car (p))->length_mom (); + m = m + unsmob_music (ly_car (p))->get_length (); p = ly_cdr (p); } return m; @@ -109,12 +109,12 @@ Repeated_music::alternatives_volta_length_mom () const Length of the body in THIS. Disregards REPEAT-COUNT. */ Moment -Repeated_music::body_length_mom () const +Repeated_music::body_get_length () const { Moment m = 0; if (body ()) { - m = body ()->length_mom (); + m = body ()->get_length (); } return m; } @@ -135,7 +135,7 @@ Repeated_music::unfolded_music_length (SCM m) { Repeated_music* r = dynamic_cast (unsmob_music (m)); - Moment l = Moment (r->repeat_count ()) * r->body_length_mom () + r->alternatives_length_mom (false); + Moment l = Moment (r->repeat_count ()) * r->body_get_length () + r->alternatives_get_length (false); return l.smobbed_copy (); } @@ -144,7 +144,7 @@ Repeated_music::folded_music_length (SCM m) { Repeated_music* r = dynamic_cast (unsmob_music (m)); - Moment l = r->body_length_mom () + r->alternatives_length_mom (true); + Moment l = r->body_get_length () + r->alternatives_get_length (true); return l.smobbed_copy (); } @@ -152,7 +152,7 @@ SCM Repeated_music::volta_music_length (SCM m) { Repeated_music* r = dynamic_cast (unsmob_music (m)); - Moment l = r->body_length_mom () + r->alternatives_volta_length_mom (); + Moment l = r->body_get_length () + r->alternatives_volta_get_length (); return l.smobbed_copy (); } diff --git a/lily/request.cc b/lily/request.cc index 840f891c4f..0c569f93cb 100644 --- a/lily/request.cc +++ b/lily/request.cc @@ -13,7 +13,7 @@ Moment -Request::length_mom () const +Request::get_length () const { Duration *d = unsmob_duration (get_mus_property ("duration")); if (!d) @@ -21,7 +21,7 @@ Request::length_mom () const Moment m ; return m; } - return d->length_mom (); + return d->get_length (); } void @@ -85,7 +85,7 @@ LY_DEFINE(music_duration_length, "music-duration-length", 1, 0,0, if (d) { - l = d->length_mom (); + l = d->get_length (); } else programming_error("Music has no duration"); diff --git a/lily/score.cc b/lily/score.cc index 83ef6ed05a..ccb5b2b95d 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -91,7 +91,7 @@ Score::run_translator (Music_output_def *odef) progress_indication (_ ("Interpreting music...")); Music * music = unsmob_music (music_); - trans->final_mom_ = music->length_mom (); + trans->final_mom_ = music->get_length (); SCM protected_iter = Music_iterator::get_static_get_iterator (music); Music_iterator * iter = unsmob_iterator (protected_iter); iter->init_translator (music, trans); diff --git a/lily/sequential-iterator.cc b/lily/sequential-iterator.cc index 798283abaa..e23b136784 100644 --- a/lily/sequential-iterator.cc +++ b/lily/sequential-iterator.cc @@ -97,7 +97,7 @@ get_grace_fixups (SCM cursor) { Music * mus = unsmob_music (ly_car (cursor)); Moment s = mus->start_mom (); - Moment l =mus->length_mom () - s; + Moment l =mus->get_length () - s; if (s.grace_part_) { @@ -176,7 +176,7 @@ Sequential_iterator::construct_children () void Sequential_iterator::next_element (bool side_effect) { - Moment len =iter_->music_length_mom () - iter_->music_start_mom (); + Moment len =iter_->music_get_length () - iter_->music_start_mom (); assert (!grace_fixups_ || grace_fixups_->start_ >= here_mom_); if (len.main_part_ && grace_fixups_ && @@ -258,7 +258,7 @@ Sequential_iterator::get_pending_events (Moment until)const for (SCM i = nm; gh_pair_p (i); i = ly_cdr (i)) { Music *mus=unsmob_music (ly_car (i)); - m = m >? (mus->length_mom () - mus->start_mom ()); + m = m >? (mus->get_length () - mus->start_mom ()); } if (m > Moment (0)) break ; @@ -289,9 +289,9 @@ Sequential_iterator::skip (Moment until) /* do the stuff/note/rest preceding a grace. */ - iter_->skip (iter_->music_length_mom ()); + iter_->skip (iter_->music_get_length ()); } - else if (iter_->music_length_mom () >= until - here_mom_) + else if (iter_->music_get_length () >= until - here_mom_) iter_->skip (until - here_mom_ + iter_->music_start_mom ()); if (iter_->ok ()) @@ -314,7 +314,7 @@ Sequential_iterator::process (Moment until) /* do the stuff/note/rest preceding a grace. */ - iter_->process (iter_->music_length_mom ()); + iter_->process (iter_->music_get_length ()); } else iter_->process (until - here_mom_ + iter_->music_start_mom ()); diff --git a/lily/sequential-music.cc b/lily/sequential-music.cc index 10acadf4cc..7100dd3a76 100644 --- a/lily/sequential-music.cc +++ b/lily/sequential-music.cc @@ -9,7 +9,7 @@ Sequential_music::Sequential_music () Moment -Sequential_music::length_mom () const +Sequential_music::get_length () const { return Music_sequence::cumulative_length (get_mus_property ("elements")); } diff --git a/lily/simple-music-iterator.cc b/lily/simple-music-iterator.cc index 5c7ebc6271..55fd9540c5 100644 --- a/lily/simple-music-iterator.cc +++ b/lily/simple-music-iterator.cc @@ -26,7 +26,7 @@ Simple_music_iterator::Simple_music_iterator (Simple_music_iterator const &src) bool Simple_music_iterator::ok ()const { - return last_processed_mom_ < music_length_mom (); + return last_processed_mom_ < music_get_length (); } /* @@ -43,7 +43,7 @@ Simple_music_iterator::pending_moment ()const if (last_processed_mom_ < Moment (0)) return Moment (0); else - return music_length_mom (); + return music_get_length (); } void diff --git a/lily/simultaneous-music.cc b/lily/simultaneous-music.cc index dcfa4c561b..f5930cdaab 100644 --- a/lily/simultaneous-music.cc +++ b/lily/simultaneous-music.cc @@ -5,7 +5,7 @@ #include "music-list.hh" Moment -Simultaneous_music::length_mom () const +Simultaneous_music::get_length () const { return Music_sequence::maximum_length (get_mus_property ("elements")); } diff --git a/lily/spacing-engraver.cc b/lily/spacing-engraver.cc index 9fc77d7239..0e4a4fe717 100644 --- a/lily/spacing-engraver.cc +++ b/lily/spacing-engraver.cc @@ -109,7 +109,7 @@ Spacing_engraver::acknowledge_grob (Grob_info i) Music *r = i.music_cause (); if (r && r->is_mus_type ("rhythmic-event")) { - Moment len = r->length_mom (); + Moment len = r->get_length (); Rhythmic_tuple t (i, now_mom () + len); now_durations_.push (t); } @@ -123,7 +123,7 @@ Spacing_engraver::stop_translation_timestep () shortest_playing.set_infinite (1); for (int i=0; i < playing_durations_.size (); i++) { - Moment m = (playing_durations_[i].info_.music_cause ())->length_mom (); + Moment m = (playing_durations_[i].info_.music_cause ())->get_length (); shortest_playing = shortest_playing length_mom (); + Moment m = now_durations_[i].info_.music_cause ()->get_length (); if (m.to_bool ()) { starter = starter get_mus_property ("metronome-count"); Duration *d = unsmob_duration (tempo_req_->get_mus_property ("duration")); - Rational r = (d->length_mom () / Moment (Rational (1, 4)) * Moment (gh_scm2int (met))).main_part_; + Rational r = (d->get_length () / Moment (Rational (1, 4)) * Moment (gh_scm2int (met))).main_part_; audio_ = new Audio_tempo (int (r)); diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index f1531ea677..7e0c41114b 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -94,7 +94,7 @@ Tie_performer::acknowledge_audio_element (Audio_element_info i) { Music *m = i.req_; if (m->is_mus_type ("note-event")) - now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->length_mom ())); + now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->get_length ())); } } diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 891d809f61..3488b06fa0 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -48,7 +48,7 @@ Tuplet_engraver::try_music (Music *c) if (el && !el->is_mus_type ("request-chord")) { time_scaled_musics_.push (c); - Rational m = now_mom ().main_part_ + c->length_mom ().main_part_; + Rational m = now_mom ().main_part_ + c->get_length ().main_part_; stop_moments_.push (m); SCM s = get_property ("tupletSpannerDuration"); diff --git a/lily/untransposable-music.cc b/lily/untransposable-music.cc index 4f1ea7f016..2dd1e6d4de 100644 --- a/lily/untransposable-music.cc +++ b/lily/untransposable-music.cc @@ -9,6 +9,13 @@ source file of the GNU LilyPond music typesetter #include "untransposable-music.hh" +/* + todo: This one, together with Un_relativable_music is ugh. + + fixthis. +*/ + + void Untransposable_music::transpose (Pitch ) { diff --git a/scm/clef.scm b/scm/clef.scm index 45e6edcd50..ba2d3bc54c 100644 --- a/scm/clef.scm +++ b/scm/clef.scm @@ -88,7 +88,18 @@ ) ) -(define-public (clef-name-to-properties cl) +(define-public (make-clef-set cl) + "Generate the clef setting commands for a clef with name CL." + (define (make-prop-set props) + (let* + ( + (m (make-music-by-name 'PropertySet)) + ) + + (map (lambda (x) (ly-set-mus-property! m (car x) (cdr x))) props) + m + )) + (let ((e '()) (c0 0) (oct 0) @@ -106,29 +117,39 @@ (set! e (assoc cl supported-clefs)) - + (if (pair? e) - `(((symbol . clefGlyph) - (iterator-ctor . ,Property_iterator::constructor) - (value . ,(cadr e)) - ) + (let* + ( + (musics (map make-prop-set - ((symbol . centralCPosition) - (iterator-ctor . ,Property_iterator::constructor) - (value . ,(+ oct (caddr e) (cdr (assoc (cadr e) c0-pitch-alist)))) - ) - ((symbol . clefPosition) - (iterator-ctor . ,Property_iterator::constructor) - (value . ,(caddr e)) - ) - ((symbol . clefOctavation) - (iterator-ctor . ,Property_iterator::constructor) - (value . ,(- oct)) - ) + `(((symbol . clefGlyph) + (value . ,(cadr e)) + ) + ((symbol . centralCPosition) + (value . ,(+ oct (caddr e) (cdr (assoc (cadr e) c0-pitch-alist)))) + ) + ((symbol . clefPosition) + (value . ,(caddr e)) + ) + ((symbol . clefOctavation) + (value . ,(- oct)) + ) + ))) + (seq (make-music-by-name 'SequentialMusic)) + (csp (make-music-by-name 'ContextSpeccedMusic)) + ) + + (ly-set-mus-property! seq 'elements musics) + (ly-set-mus-property! csp 'element seq) + (ly-set-mus-property! csp 'context-type "Staff") + + csp ) (begin - (ly-warn (string-append "Unknown clef type `" cl "'\nSee scm/lily.scm for supported clefs")) - '()) + (ly-warn (format "Unknown clef type `~a' +See scm/lily.scm for supported clefs")) + (make-music-by-name 'Music) + + ) ))) - - diff --git a/scm/music-types.scm b/scm/music-types.scm index 0c1d5fe578..55117bf81f 100644 --- a/scm/music-types.scm +++ b/scm/music-types.scm @@ -25,7 +25,7 @@ (internal-class-name . "Request") (types . (general-music event articulation-event script-event)) )) - (AutoChangeMusic + (AutoChangeMusic . ( (description . "") @@ -33,13 +33,13 @@ (iterator-ctor . ,Auto_change_iterator::constructor) (types . (general-music music-wrapper-music auto-change-instruction)) )) - (BarCheck - . ( - (description . "") - (internal-class-name . "Music") - (types . (general-music bar-check)) - (iterator-ctor . ,Bar_check_iterator::constructor) - )) + (BarCheck + . ( + (description . "") + (internal-class-name . "Music") + (types . (general-music bar-check)) + (iterator-ctor . ,Bar_check_iterator::constructor) + )) (BassFigureEvent . ( (description . "") @@ -82,7 +82,7 @@ (internal-class-name . "Music_wrapper") (types . (context-specification general-music music-wrapper-music)) )) - (CrescendoEvent + (CrescendoEvent . ( (description . "") @@ -96,7 +96,7 @@ (internal-class-name . "Request") (types . (general-music dynamic-event decrescendo-event event)) )) - (ExtenderEvent + (ExtenderEvent . ( (description . "") @@ -118,7 +118,7 @@ (iterator-ctor . ,Grace_iterator::constructor) (types . (grace-music music-wrapper-music general-music)) )) - (HyphenEvent + (HyphenEvent . ( (description . "") @@ -132,7 +132,7 @@ (internal-class-name . "Key_change_req") (types . (general-music key-change-event event)) )) - (LyricCombineMusic + (LyricCombineMusic . ( (description . "") @@ -141,7 +141,7 @@ (iterator-ctor . ,Lyric_combine_music_iterator::constructor) )) - (LyricEvent + (LyricEvent . ( (description . "A lyric syllable. Must be entered in lyrics mode, i.e. @code{\\lyrics @{ twinkle4 twinkle4 @} } .") @@ -199,24 +199,24 @@ (internal-class-name . "Request") (types . (general-music event note-event rhythmic-event melodic-event)) )) - (OverrideProperty - . ( + (OverrideProperty + . ( (description . "") - (internal-class-name . "Music") - (types . (general-music layout-instruction)) - (iterator-ctor . , Push_property_iterator::constructor) - )) + (internal-class-name . "Music") + (types . (general-music layout-instruction)) + (iterator-ctor . , Push_property_iterator::constructor) + )) - (PartCombineMusic + (PartCombineMusic . ( (description . "") (internal-class-name . "Simultaneous_music") (types . (general-music part-combine-music)) (iterator-ctor . ,Part_combine_music_iterator::constructor) - )) - (PhrasingSlurEvent + )) + (PhrasingSlurEvent . ( (description . "Start or end phrasing slur. Syntax NOTE \\( and \\) NOTE") (internal-class-name . "Request") @@ -230,7 +230,7 @@ (iterator-ctor . ,Property_iterator::constructor) ) ) - (PropertyUnset + (PropertyUnset . ( (description . "") @@ -239,7 +239,7 @@ (iterator-ctor . ,Property_unset_iterator::constructor) ) ) - (PorrectusEvent + (PorrectusEvent . ( (description . "") @@ -292,14 +292,14 @@ )) (RevertProperty - . ( + . ( (description . "") - (internal-class-name . "Music") - (types . (general-music layout-instruction)) - (iterator-ctor . , Pop_property_iterator::constructor) - )) - + (internal-class-name . "Music") + (types . (general-music layout-instruction)) + (iterator-ctor . , Pop_property_iterator::constructor) + )) + (OutputPropertySetMusic . ( (description . "") @@ -308,7 +308,7 @@ (iterator-ctor . ,Output_property_music_iterator::constructor) (types . (general-music layout-instruction)) )) - + (TextSpanEvent . ( (description . "Start a text spanner like 8va.....|") @@ -318,11 +318,11 @@ (TranslatorChange . ( (description . "") - (internal-class-name . "Music") (iterator-ctor . , Change_iterator::constructor) (types . (general-music translator-change-instruction)) )) + (TimeScaledMusic . ( (description . "") @@ -330,10 +330,10 @@ (iterator-ctor . ,Time_scaled_music_iterator::constructor) (types . (time-scaled-music music-wrapper-music general-music)) )) + (TransposedMusic . ( (description . "") - (internal-class-name . "Transposed_music") (types . (music-wrapper-music general-music transposed-music)) )) @@ -349,7 +349,6 @@ (UnrelativableMusic . ( (description . "") - (internal-class-name . "Un_relativable_music") (types . (music-wrapper-music general-music unrelativable-music)) )) @@ -362,7 +361,7 @@ (types . (music-wrapper-music general-music relative-octave-music)) )) - + (RequestChord . ( (description . "") @@ -372,7 +371,7 @@ (types . (general-music request-chord simultaneous-music)) ) ) - + (ScriptEvent . ( (description . "") @@ -395,23 +394,23 @@ (types . (general-music event)) )) (SustainPedalEvent - . ( - (description . "") - (internal-class-name . "Request") - (types . (general-music pedal-event sustain-pedal-event)) - )) + . ( + (description . "") + (internal-class-name . "Request") + (types . (general-music pedal-event sustain-pedal-event)) + )) (SostenutoEvent - . ( - (description . "") - (internal-class-name . "Request") - (types . (general-music pedal-event sostenuto-pedal-event)) - )) + . ( + (description . "") + (internal-class-name . "Request") + (types . (general-music pedal-event sostenuto-pedal-event)) + )) (UnaCordaEvent - . ( - (description . "") - (internal-class-name . "Request") - (types . (general-music pedal-event una-corda-pedal-event)) - )) + . ( + (description . "") + (internal-class-name . "Request") + (types . (general-music pedal-event una-corda-pedal-event)) + )) (StringNumberEvent . ( (description . "") @@ -444,65 +443,65 @@ (internal-class-name . "Request") (types . (general-music event tremolo-event)) )) - (VoiceSeparator - . ( - (description . "") - - (internal-class-name . "Music") - (types . (separator general-music)) - )) - - (VoltaRepeatedMusic - . ( - (iterator-ctor . ,Volta_repeat_iterator::constructor) - (internal-class-name . "Repeated_music") - (description . "") - (start-moment-function . ,Repeated_music::first_start) - (length . ,Repeated_music::volta_music_length) - (types . (general-music repeated-music volta-repeated-music)) - )) - - (UnfoldedRepeatedMusic - . ( - (iterator-ctor . ,Unfolded_repeat_iterator::constructor) - (description . "") - (start-moment-function . ,Repeated_music::first_start) - (internal-class-name . "Repeated_music") - (types . (general-music repeated-music unfolded-repeated-music)) - (length . ,Repeated_music::unfolded_music_length) - )) - (PercentRepeatedMusic - . ( - (internal-class-name . "Repeated_music") - (description . "") - (iterator-ctor . ,Percent_repeat_iterator::constructor) - (start-moment-function . ,Repeated_music::first_start) - (length . ,Repeated_music::unfolded_music_length) - (types . (general-music repeated-music percent-repeated-music)) - )) - - (TremoloRepeteadMusic - . ( - (iterator-ctor . ,Chord_tremolo_iterator::constructor) - (description . "") - (internal-class-name . "Repeated_music") - (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) - (types . (general-music repeated-music tremolo-repeated-music)) - - )) - (FoldedRepeatedMusic - . ( - (internal-class-name . "Repeated_music") - (description . "") - (iterator-ctor . ,Folded_repeat_iterator::constructor) - (start-moment-function . ,Repeated_music::minimum_start) - (length . ,Repeated_music::folded_music_length) - (types . (general-music repeated-music folded-repeated-music)) - )) - )) + (VoiceSeparator + . ( + (description . "") + + (internal-class-name . "Music") + (types . (separator general-music)) + )) + + (VoltaRepeatedMusic + . ( + (iterator-ctor . ,Volta_repeat_iterator::constructor) + (internal-class-name . "Repeated_music") + (description . "") + (start-moment-function . ,Repeated_music::first_start) + (length . ,Repeated_music::volta_music_length) + (types . (general-music repeated-music volta-repeated-music)) + )) + + (UnfoldedRepeatedMusic + . ( + (iterator-ctor . ,Unfolded_repeat_iterator::constructor) + (description . "") + (start-moment-function . ,Repeated_music::first_start) + (internal-class-name . "Repeated_music") + (types . (general-music repeated-music unfolded-repeated-music)) + (length . ,Repeated_music::unfolded_music_length) + )) + (PercentRepeatedMusic + . ( + (internal-class-name . "Repeated_music") + (description . "") + (iterator-ctor . ,Percent_repeat_iterator::constructor) + (start-moment-function . ,Repeated_music::first_start) + (length . ,Repeated_music::unfolded_music_length) + (types . (general-music repeated-music percent-repeated-music)) + )) + + (TremoloRepeteadMusic + . ( + (iterator-ctor . ,Chord_tremolo_iterator::constructor) + (description . "") + (internal-class-name . "Repeated_music") + (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) + (types . (general-music repeated-music tremolo-repeated-music)) + + )) + (FoldedRepeatedMusic + . ( + (internal-class-name . "Repeated_music") + (description . "") + (iterator-ctor . ,Folded_repeat_iterator::constructor) + (start-moment-function . ,Repeated_music::minimum_start) + (length . ,Repeated_music::folded_music_length) + (types . (general-music repeated-music folded-repeated-music)) + )) + )) (set! music-descriptions (sort music-descriptions alistevent name) (let ( (entry (assoc - name - '( - ("text" . TextSpanEvent) - ("decrescendo" . DecrescendoEvent) - ("crescendo" . CrescendoEvent) - ("Sustain" . SustainPedalEvent) - ("slur" . SlurEvent) - ("UnaCorda" . UnaCordaEvent) - ("Sostenuto" . SostenutoEvent) - ))) + name + '( + ("text" . TextSpanEvent) + ("decrescendo" . DecrescendoEvent) + ("crescendo" . CrescendoEvent) + ("Sustain" . SustainPedalEvent) + ("slur" . SlurEvent) + ("UnaCorda" . UnaCordaEvent) + ("Sostenuto" . SostenutoEvent) + ))) ) (if (eq? entry #f) (error (format "Could not find span type ~a" name)) (make-music-by-name (cdr entry)) ) - )) + )) (define-public (make-repeated-music name) (let* @@ -588,9 +587,9 @@ "'\nSee music-types.scm for supported repeats")) 'VoltaRepeatedMusic) ) - ) + ) ) - (make-music-by-name music-name) + (make-music-by-name music-name) )) -- 2.39.5