From 7ea5c74058200ace4b405de82e1088560aeaacb2 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 19 Jan 2003 12:58:18 +0000 Subject: [PATCH] * input/regression/ambitus.ly: move file. * lily/include/pitch.hh (class Pitch): make Pitch objects immutable. * lily/event.cc (transpose): add tonic property to Key_change_req and to Key_engraver. --- ChangeLog | 9 +++ Documentation/user/tutorial.itely | 19 ++----- input/{test => regression}/ambitus.ly | 0 input/regression/finger-chords.ly | 2 + input/template/piano-melody-lyrics.ly | 3 +- input/test/fingering.ly | 10 ---- lily/accidental-engraver.cc | 14 ++--- lily/accidental-placement.cc | 2 +- lily/ambitus.cc | 28 ++++++---- lily/chord.cc | 35 ++++++------ lily/completion-note-heads-engraver.cc | 6 +- lily/event.cc | 50 +++++++---------- lily/include/event.hh | 3 +- lily/include/pitch.hh | 35 +++++++----- lily/key-engraver.cc | 45 ++++++++------- lily/key-performer.cc | 8 +-- lily/new-accidental-engraver.cc | 14 ++--- lily/new-chord-name-engraver.cc | 1 + lily/new-fingering-engraver.cc | 15 +++-- lily/note-head.cc | 2 +- lily/parser.yy | 74 +++++++++++-------------- lily/pitch.cc | 27 ++++----- lily/rest-collision.cc | 3 + lily/staff-symbol-engraver.cc | 4 +- lily/stem-engraver.cc | 4 +- lily/thread-devnull-engraver.cc | 16 +++--- lily/timing-engraver.cc | 8 +-- scm/double-plus-new-chord-name.scm | 42 +++++++------- scm/grob-property-description.scm | 7 ++- scm/music-property-description.scm | 1 + scm/music-types.scm | 2 +- scm/translator-property-description.scm | 2 + 32 files changed, 249 insertions(+), 242 deletions(-) rename input/{test => regression}/ambitus.ly (100%) diff --git a/ChangeLog b/ChangeLog index fdc6a70021..8ebd6e2521 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-01-19 Han-Wen Nienhuys + + * input/regression/ambitus.ly: move file. + + * lily/include/pitch.hh (class Pitch): make Pitch objects immutable. + + * lily/event.cc (transpose): add tonic property to Key_change_req + and to Key_engraver. + 2003-01-17 Heikki Junes * Documentation/user/refman.itely: fix typo. diff --git a/Documentation/user/tutorial.itely b/Documentation/user/tutorial.itely index a90fada776..b7d81bee19 100644 --- a/Documentation/user/tutorial.itely +++ b/Documentation/user/tutorial.itely @@ -752,7 +752,10 @@ demonstrated here: In this example, @code{staffA} and @code{staffB} are names that are given to the staves. It doesn't matter what names you give, as long -as each staff has a different name. +as each staff has a different name. If you give them the same name, +LilyPond will assume that you only want one staff, and will but both +pieces of music on the same staff. + @separate @@ -1457,8 +1460,6 @@ The convention for naming @code{LyricsVoice} and @code{Voice} must also be used to get melismata on rests correct. -@c I think we need to change the name of this section, but that -@c would probably involve a lot of changes in other places too. @node More movements @section More movements @@ -1468,16 +1469,6 @@ you need to use @code{ly2dvi}, which comes with LilyPond. @code{ly2dvi} creates the title, then calls @code{lilypond} to format the sheet music. In this section, we show you how to create titles like this: -@c Old version of the above paragraph. -@c LilyPond only produces sheet music; it doesn't concern itself with -@c producing titles. Titles are produced using a simply wrapper program -@c This is the jobs of a simple wrapper -@c program called ly2dvi. @code{ly2dvi} calls LilyPond to do the -@c sheet music formatting. Then it produces titles, and ties together all -@c inputs into a single @file{dvi} file. In this section, we show some of -@c the options for titling. We will show how you can produce a file -@c that looks like this: - @center @strong{Two miniatures} @flushright Opus 1. @@ -1566,7 +1557,7 @@ versions using old print-outs. @cindex tag line Many people find the default tagline (``Lily was here'') too droll. -If that is the case, you can change @code{tagline} to somethign else, +If that is the case, you can change @code{tagline} to something else, as shown above. @separate diff --git a/input/test/ambitus.ly b/input/regression/ambitus.ly similarity index 100% rename from input/test/ambitus.ly rename to input/regression/ambitus.ly diff --git a/input/regression/finger-chords.ly b/input/regression/finger-chords.ly index c09c095782..4df28235fa 100644 --- a/input/regression/finger-chords.ly +++ b/input/regression/finger-chords.ly @@ -21,6 +21,8 @@ easier to process." << c-1 es-3 g-5 >> 4 \property Voice.fingerHorizontalDirection = #RIGHT << c-1 e-2 g-3 b-5 >> 4-\arpeggio + \property Voice.fingerHorizontalDirection = #LEFT + << c_1 e-2 g-3 b^5 >> 4 } diff --git a/input/template/piano-melody-lyrics.ly b/input/template/piano-melody-lyrics.ly index 8c48c08a08..31d1348c7d 100644 --- a/input/template/piano-melody-lyrics.ly +++ b/input/template/piano-melody-lyrics.ly @@ -1,7 +1,8 @@ \version "1.7.6" \header { - texidoc ="Classical song format: one staff with melody and lyrics, and piano accompaniment." + texidoc ="Classical song format: one staff with melody and lyrics, +and piano accompaniment." } diff --git a/input/test/fingering.ly b/input/test/fingering.ly index 82bcebc90b..e69de29bb2 100644 --- a/input/test/fingering.ly +++ b/input/test/fingering.ly @@ -1,10 +0,0 @@ -\version "1.7.6" - - - -\score { -\notes \context Voice = VA \relative c'' { - \grace {[b8^1 c^2]} d4^3 -} -\paper {linewidth = -1. }} -%% new-chords-done %% diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index a50b5cf404..fd26acd16c 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -124,9 +124,9 @@ static int number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, bool ignore_octave_b) { - int n = pitch->notename_; - int o = pitch->octave_; - int a = pitch->alteration_; + int n = pitch->get_notename (); + int o = pitch->get_octave(); + int a = pitch->get_alteration (); int curbarnum_i = gh_scm2int (curbarnum); int accbarnum_i = 0; @@ -300,7 +300,7 @@ Accidental_engraver::process_acknowledged_grobs () announce_grob (a, SCM_EOL); - SCM accs = gh_cons (scm_int2num (pitch->alteration_), SCM_EOL); + SCM accs = gh_cons (scm_int2num (pitch->get_alteration ()), SCM_EOL); if (num == 2 && extra_natural_b) accs = gh_cons (scm_int2num (0), accs); @@ -346,9 +346,9 @@ Accidental_engraver::process_acknowledged_grobs () */ - int n = pitch->notename_; - int o = pitch->octave_; - int a = pitch->alteration_; + int n = pitch->get_notename (); + int o = pitch->get_octave (); + int a = pitch->get_alteration (); SCM on_s = gh_cons (scm_int2num (o), scm_int2num (n)); /* diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index a184776174..20cff55c0e 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -54,7 +54,7 @@ Accidental_placement::add_accidental (Grob* me, Grob* a) Pitch *p= unsmob_pitch (mcause->get_mus_property ("pitch")); - int n = p->notename_; + int n = p->get_notename (); SCM accs = me->get_grob_property ("accidental-grobs"); SCM key = scm_int2num (n); diff --git a/lily/ambitus.cc b/lily/ambitus.cc index b71a2620fd..2a3a29f23b 100644 --- a/lily/ambitus.cc +++ b/lily/ambitus.cc @@ -40,25 +40,29 @@ */ /** - * Given a pitch and a key_signature, decide what accidentals to show. - * - * Possible return values: - * - * 0: do not show any accidental - * 1: show pitch->alteration_ only - * 2: show pitch->alteration_, preceded by a natural sign + Given a pitch and a key_signature, decide what accidentals to show. + + Possible return values: + + 0: do not show any accidental + 1: show pitch->alteration_ only + 2: show pitch->get_alteration, preceded by a natural sign + + UGH: code duplication! See accidental-engraver. + */ static int number_accidentals (SCM key_signature, Pitch *pitch, bool ignore_octave_b, bool force_accidental) { - int notename = pitch->notename_; - int octave = pitch->octave_; - int alteration = pitch->alteration_; + int notename = pitch->get_notename (); + int octave = pitch->get_octave(); + int alteration = pitch->get_alteration(); if (force_accidental) // ignore key signature return 1; + #if DEBUG_AMBITUS scm_display (key_signature, scm_current_output_port ()); #endif @@ -101,12 +105,12 @@ add_accidentals (Item *me, Molecule *head, int num_acc, { if (!num_acc) return; - if (pitch->alteration_) + if (pitch->get_alteration()) { Molecule accidental (Font_interface::get_default_font (me)-> find_by_name (String ("accidentals-") + accidentals_style + - to_string (pitch->alteration_))); + to_string (pitch->get_alteration()))); accidental.translate_axis (yoffs, Y_AXIS); head->add_at_edge (X_AXIS, LEFT, accidental, 0.1, 0); } diff --git a/lily/chord.cc b/lily/chord.cc index 024c54833a..9248bad895 100644 --- a/lily/chord.cc +++ b/lily/chord.cc @@ -81,8 +81,8 @@ Chord::member_notename (SCM p, SCM pitches) Urg, eindelijk gevonden: () != #f, kan maar niet aan wennen. Anders kon iets korter... */ - if (unsmob_pitch (p)->notename_ - == unsmob_pitch (ly_car (i))->notename_) + if (unsmob_pitch (p)->get_notename () + == unsmob_pitch (ly_car (i))->get_notename ()) { member = ly_car (i); break; @@ -104,10 +104,10 @@ Chord::member_pitch (SCM p, SCM pitches) { for (SCM i = pitches; gh_pair_p (i); i = ly_cdr (i)) { - if (unsmob_pitch (p)->notename_ - == unsmob_pitch (ly_car (i))->notename_ - && unsmob_pitch (p)->alteration_ - == unsmob_pitch (ly_car (i))->alteration_) + if (unsmob_pitch (p)->get_notename () + == unsmob_pitch (ly_car (i))->get_notename () + && unsmob_pitch (p)->get_alteration() + == unsmob_pitch (ly_car (i))->get_alteration()) { member = ly_car (i); break; @@ -123,10 +123,10 @@ SCM Chord::step_scm (SCM tonic, SCM p) { /* De Pitch intervaas is nog beetje sleutelgat? */ - int i = unsmob_pitch (p)->notename_ - - unsmob_pitch (tonic)->notename_ - + (unsmob_pitch (p)->octave_ - - unsmob_pitch (tonic)->octave_) * 7; + int i = unsmob_pitch (p)->get_notename () + - unsmob_pitch (tonic)->get_notename () + + (unsmob_pitch (p)->get_octave () + - unsmob_pitch (tonic)->get_octave ()) * 7; while (i < 0) i += 7; i++; @@ -165,10 +165,10 @@ Chord::missing_thirds (SCM pitches) SCM p = ly_car (i); int step = gh_scm2int (step_scm (tonic, p)); - if (unsmob_pitch (last)->notename_ == unsmob_pitch (p)->notename_) + if (unsmob_pitch (last)->get_notename () == unsmob_pitch (p)->get_notename ()) { - int third = (unsmob_pitch (last)->notename_ - - unsmob_pitch (tonic)-> notename_ + 7) % 7; + int third = (unsmob_pitch (last)->get_notename () + - unsmob_pitch (tonic)-> get_notename () + 7) % 7; last = ly_pitch_transpose (last, scm_vector_ref (thirds, scm_int2num (third))); } @@ -177,8 +177,8 @@ Chord::missing_thirds (SCM pitches) while (step > gh_scm2int (step_scm (tonic, last))) { missing = gh_cons (last, missing); - int third = (unsmob_pitch (last)->notename_ - - unsmob_pitch (tonic)->notename_ + 7) % 7; + int third = (unsmob_pitch (last)->get_notename () + - unsmob_pitch (tonic)->get_notename () + 7) % 7; last = ly_pitch_transpose (last, scm_vector_ref (thirds, scm_int2num (third))); } @@ -241,10 +241,13 @@ Chord::tonic_add_sub_to_pitches (SCM tonic, SCM add, SCM sub) */ if (p->get_octave () == -100) { - p->octave_ = 0; + dim_b = true; + Pitch t (0, p->get_notename(), p->get_alteration()); + gh_set_car_x (i, t.smobbed_copy()); dim_b = true; } } + add = transpose_pitches (tonic, add); add = lower_step (tonic, add, scm_int2num (7)); add = scm_sort_list (add, Pitch::less_p_proc); diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 676c39a6ef..62cc6fec34 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -309,9 +309,9 @@ Completion_heads_engraver::Completion_heads_engraver() } ENTER_DESCRIPTION(Completion_heads_engraver, -/* descr */ "This engraver replaces -@code{Note_heads_engraver}. It plays some trickery to -break long notes and automatically tie them into the next measure.", +/* descr */ "This engraver replaces " +"@code{Note_heads_engraver}. It plays some trickery to " +"break long notes and automatically tie them into the next measure.", /* creats*/ "NoteHead Dots", /* accepts */ "busy-playing-event note-event", /* acks */ "", diff --git a/lily/event.cc b/lily/event.cc index ad736eb794..199c85eb45 100644 --- a/lily/event.cc +++ b/lily/event.cc @@ -37,12 +37,11 @@ Event::transpose (Pitch delta) if (!p) return ; - Pitch np = *p; - np.transpose (delta); + Pitch np = p->transposed (delta); - if (abs (np.alteration_) > 2) + if (abs (np.get_alteration ()) > 2) { - warning (_f ("Transposition by %s makes accidental larger than two", + warning (_f ("Transposition by %s makes alteration larger than two", delta.string ())); } @@ -50,13 +49,13 @@ Event::transpose (Pitch delta) } Pitch - Event::to_relative_octave (Pitch last) +Event::to_relative_octave (Pitch last) { Pitch *old_pit = unsmob_pitch (get_mus_property ("pitch")); if (old_pit) { Pitch new_pit = *old_pit; - new_pit.to_relative_octave (last); + new_pit = new_pit.to_relative_octave (last); set_mus_property ("pitch", new_pit.smobbed_copy ()); return new_pit; @@ -112,6 +111,9 @@ LY_DEFINE(music_duration_compress, "ly:music-duration-compress", 2, 0,0, /* This is hairy, since the scale in a key-change event may contain octaveless notes. + + + TODO: this should use ly:pitch. */ LY_DEFINE(transpose_key_alist, "ly:transpose-key-alist", 2, 0,0, (SCM l, SCM pitch), @@ -127,24 +129,24 @@ LY_DEFINE(transpose_key_alist, "ly:transpose-key-alist", if (gh_pair_p (key)) { Pitch orig (gh_scm2int (ly_car (key)), - gh_scm2int (ly_cdr (key)), - gh_scm2int (alter)); + gh_scm2int (ly_cdr (key)), + gh_scm2int (alter)); - orig.transpose (*p); + orig =orig.transposed (*p); SCM key = gh_cons (scm_int2num (orig.get_octave ()), - scm_int2num (orig.notename_)); + scm_int2num (orig.get_notename ())); - newlist = gh_cons (gh_cons (key, scm_int2num (orig.alteration_)), + newlist = gh_cons (gh_cons (key, scm_int2num (orig.get_alteration ())), newlist); } else if (gh_number_p (key)) { Pitch orig (0, gh_scm2int (key), gh_scm2int (alter)); - orig.transpose (*p); + orig = orig.transposed (*p); - key =scm_int2num (orig.notename_); - alter = scm_int2num (orig.alteration_); + key =scm_int2num (orig.get_notename ()); + alter = scm_int2num (orig.get_alteration()); newlist = gh_cons (gh_cons (key, alter), newlist); } } @@ -152,14 +154,16 @@ LY_DEFINE(transpose_key_alist, "ly:transpose-key-alist", } void -Key_change_req::transpose (Pitch p) +Key_change_ev::transpose (Pitch p) { SCM pa = get_mus_property ("pitch-alist"); set_mus_property ("pitch-alist", transpose_key_alist (pa, p.smobbed_copy())); + Pitch tonic = *unsmob_pitch (get_mus_property ("tonic")); + set_mus_property ("tonic", + tonic.smobbed_copy ()); } - bool alist_equal_p (SCM a, SCM b) { @@ -177,16 +181,4 @@ alist_equal_p (SCM a, SCM b) } return true; } - -bool -Key_change_req::do_equal_b (Event const * m )const -{ - Key_change_req const * kc =dynamic_cast (m); - - if(!kc) - return false; - return alist_equal_p (get_mus_property ("pitch-alist"), - kc->get_mus_property ("pitch-alist")); -} - -ADD_MUSIC (Key_change_req); +ADD_MUSIC (Key_change_ev); diff --git a/lily/include/event.hh b/lily/include/event.hh index 0d1823c8a5..ee60c1e9e3 100644 --- a/lily/include/event.hh +++ b/lily/include/event.hh @@ -37,14 +37,13 @@ public: /** Handle key changes. */ -class Key_change_req : public Event +class Key_change_ev : public Event { public: SCM pitch_alist (); protected: VIRTUAL_COPY_CONS (Music); - bool do_equal_b (Event const * ) const; void transpose (Pitch d); }; diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh index 613d45cf05..a3c63fb25b 100644 --- a/lily/include/pitch.hh +++ b/lily/include/pitch.hh @@ -13,16 +13,26 @@ #include "lily-proto.hh" #include "smobs.hh" -/** A "tonal" pitch. This is a pitch as it figures in diatonal western - music (12 semitones in an octave), as opposed to a frequence in Hz +/** A "tonal" pitch. This is a pitch used in diatonal western + music (12 semitones in an octave), as opposed to a frequency in Hz or a integer number of semitones. - + + Pitch is lexicographically ordered by (octave, notename, + alteration). + + + TODO: + + - add indeterminate octaves, so it can be used as a key in keySigature + + - abstract out the representation of alteration_, so we can + put micropitches (quartertones, etc.) in the Pitch object */ class Pitch { -public: // fixme +private: // fixme /* - TODO: use SCM -- (make private?) + TODO: use SCM */ /// 0 is c, 6 is b @@ -33,28 +43,23 @@ public: // fixme /// 0 is central c int octave_; - /* - mutators, so JUNKME. - */ + void transpose (Pitch); void up_to (int); void down_to (int); + void normalise (); public: - + int get_octave () const; int get_notename () const; int get_alteration () const; - void normalise (); - /* - Pitch is lexicographically ordered by (octave, notename, - alteration). - */ Pitch (int octave, int notename,int accidental); Pitch (); - Pitch to_relative_octave (Pitch); + Pitch transposed (Pitch) const; + Pitch to_relative_octave (Pitch) const; static int compare (Pitch const&,Pitch const&); /// return large part of interval from central c diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index cb28955a16..ec5b4054b2 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -18,14 +18,18 @@ #include "protected-scm.hh" #include "clef.hh" +/* + TODO: The representation of key sigs is all fucked. + */ + /** Make the key signature. */ class Key_engraver : public Engraver { void create_key (bool); - void read_req (Key_change_req const * r); - Key_change_req * keyreq_; + void read_ev (Key_change_ev const * r); + Key_change_ev * key_ev_; Item * item_; public: @@ -34,7 +38,7 @@ public: protected: virtual void initialize (); virtual void finalize (); - virtual bool try_music (Music *req); + virtual bool try_music (Music *ev); virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void process_music (); @@ -50,7 +54,7 @@ Key_engraver::finalize () Key_engraver::Key_engraver () { - keyreq_ = 0; + key_ev_ = 0; item_ = 0; } @@ -69,7 +73,7 @@ Key_engraver::create_key (bool def) item_->set_grob_property ("old-accidentals", get_property ("lastKeySignature")); item_->set_grob_property ("new-accidentals", get_property ("keySignature")); - announce_grob(item_, keyreq_ ? keyreq_->self_scm() : SCM_EOL); + announce_grob(item_, key_ev_ ? key_ev_->self_scm() : SCM_EOL); } if (!def) @@ -82,18 +86,18 @@ Key_engraver::create_key (bool def) bool -Key_engraver::try_music (Music * req) +Key_engraver::try_music (Music * ev) { - // if (Key_change_req *kc = dynamic_cast (req)) - if (req->is_mus_type ("key-change-event")) + // if (Key_change_ev *kc = dynamic_cast (ev)) + if (ev->is_mus_type ("key-change-event")) { - if (!keyreq_) + if (!key_ev_) { /* do this only once, just to be on the safe side. */ - keyreq_ = dynamic_cast (req); // UGH. - read_req (keyreq_); + key_ev_ = dynamic_cast (ev); // UGH. + read_ev (key_ev_); } return true; @@ -124,7 +128,7 @@ Key_engraver::acknowledge_grob (Grob_info info) void Key_engraver::process_music () { - if (keyreq_ || + if (key_ev_ || get_property ("lastKeySignature") != get_property ("keySignature")) create_key (false); } @@ -142,7 +146,7 @@ Key_engraver::stop_translation_timestep () void -Key_engraver::read_req (Key_change_req const * r) +Key_engraver::read_ev (Key_change_ev const * r) { SCM p = r->get_mus_property ("pitch-alist"); if (!gh_pair_p (p)) @@ -164,19 +168,16 @@ Key_engraver::read_req (Key_change_req const * r) if (gh_scm2int (ly_cdar (s))) accs = gh_cons (ly_car (s), accs); -#if 0 - daddy_trans_->set_property ("lastKeySignature", - get_property ("keySignature")); -#endif - daddy_trans_->set_property ("keySignature", accs); + daddy_trans_->set_property ("tonic" , + r->get_mus_property ("tonic")); } void Key_engraver::start_translation_timestep () { - keyreq_ = 0; + key_ev_ = 0; daddy_trans_->set_property ("lastKeySignature", get_property ("keySignature")); } @@ -186,6 +187,10 @@ Key_engraver::initialize () { daddy_trans_->set_property ("keySignature", SCM_EOL); daddy_trans_->set_property ("lastKeySignature", SCM_EOL); + + Pitch p(0,0,0); + daddy_trans_->set_property ("tonic", p.smobbed_copy ()); + } @@ -195,4 +200,4 @@ ENTER_DESCRIPTION(Key_engraver, /* accepts */ "key-change-event", /* acks */ "bar-line-interface clef-interface", /* reads */ "keySignature lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature", -/* write */ "lastKeySignature"); +/* write */ "lastKeySignature tonic keySignature"); diff --git a/lily/key-performer.cc b/lily/key-performer.cc index e67c68f27d..8836930bb4 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -25,7 +25,7 @@ protected: virtual void stop_translation_timestep (); private: - Key_change_req* key_req_; + Key_change_ev* key_req_; Audio_key* audio_; }; @@ -61,8 +61,8 @@ Key_performer::create_audio_elements () (7 - gh_scm2int (ly_caar (pitchlist))) % 7, -gh_scm2int (ly_cdar (pitchlist))); - my_do.transpose (to_c); - to_c.alteration_ -= my_do.alteration_; + my_do = my_do.transposed (to_c); + to_c = my_do.transposed (Pitch(0,0,- my_do.get_alteration ())); SCM c_pitchlist = transpose_key_alist (pitchlist, to_c.smobbed_copy()); SCM major = gh_call1 (proc, c_pitchlist); @@ -87,7 +87,7 @@ Key_performer::stop_translation_timestep () bool Key_performer::try_music (Music* req) { - if (Key_change_req *kc = dynamic_cast (req)) + if (Key_change_ev *kc = dynamic_cast (req)) { if (key_req_) warning (_ ("FIXME: key change merge")); diff --git a/lily/new-accidental-engraver.cc b/lily/new-accidental-engraver.cc index b9452f77cd..aa03965df4 100644 --- a/lily/new-accidental-engraver.cc +++ b/lily/new-accidental-engraver.cc @@ -185,9 +185,9 @@ static int number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, bool ignore_octave_b) { - int n = pitch->notename_; - int o = pitch->octave_; - int a = pitch->alteration_; + int n = pitch->get_notename (); + int o = pitch->get_octave (); + int a = pitch->get_alteration (); int curbarnum_i = gh_scm2int (curbarnum); int accbarnum_i = 0; @@ -324,9 +324,9 @@ New_accidental_engraver::process_grobs_first_pass () for (int j = 0; j < ties_.size (); j++) if (support == Tie::head (ties_[j], RIGHT)) tie_changes = accidentals_[i].different_; - int n = pitch->notename_; - int o = pitch->octave_; - int a = pitch->alteration_; + int n = pitch->get_notename (); + int o = pitch->get_octave (); + int a = pitch->get_alteration (); SCM o_s = gh_int2scm (o); SCM n_s = gh_int2scm (n); SCM on_s = gh_cons (o_s,n_s); @@ -434,7 +434,7 @@ New_accidental_engraver::process_grobs_second_pass () announce_grob (a, SCM_EOL); - SCM accs = gh_cons (gh_int2scm (pitch->alteration_), SCM_EOL); + SCM accs = gh_cons (gh_int2scm (pitch->get_alteration ()), SCM_EOL); if (num == 2 && extra_natural_b) accs = gh_cons (gh_int2scm (0), accs); diff --git a/lily/new-chord-name-engraver.cc b/lily/new-chord-name-engraver.cc index 49e728306f..d76e288fc4 100644 --- a/lily/new-chord-name-engraver.cc +++ b/lily/new-chord-name-engraver.cc @@ -74,6 +74,7 @@ New_chord_name_engraver::process_music () pitches = scm_sort_list (pitches, Pitch::less_p_proc); + SCM name_proc = get_property ("chordNameFunction"); SCM exceptions = get_property ("chordNameExceptions"); SCM markup = scm_call_4 (name_proc, pitches, bass, inversion, exceptions); diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 8228083585..1018d465a8 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -169,6 +169,8 @@ New_fingering_engraver::position_scripts () { fingerings_[i].position_ = gh_scm2int (fingerings_[i].head_ -> get_grob_property( "staff-position")); } + + SCM fhd = get_property ("fingerHorizontalDirection"); Array up, down, horiz; for (int i = fingerings_.size(); i--;) @@ -187,15 +189,18 @@ New_fingering_engraver::position_scripts () } fingerings_.sort (&Finger_tuple::compare); - SCM fhd = get_property ("fingerHorizontalDirection"); if (ly_dir_p (fhd)) { - up.push (fingerings_.pop()); - down.push (fingerings_[0]); - fingerings_.del(0); + if (!up.size()) + up.push (fingerings_.pop()); + if (!down.size()) + { + down.push (fingerings_[0]); + fingerings_.del(0); + } - horiz = fingerings_; + horiz.concat (fingerings_); } else { diff --git a/lily/note-head.cc b/lily/note-head.cc index bbce833353..a703d13db5 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -196,7 +196,7 @@ Note_head::brew_ez_molecule (SCM smob) Pitch* pit = unsmob_pitch (spitch); char s[2] = "a"; - s[0] = (pit->notename_ + 2)%7 + 'a'; + s[0] = (pit->get_notename () + 2)%7 + 'a'; s[0] = toupper (s[0]); SCM charstr = scm_makfrom0str (s); diff --git a/lily/parser.yy b/lily/parser.yy index d6a3f997d0..1c7fb5b0d1 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -42,12 +42,13 @@ TODO: * The rules for who is protecting what are very shady. Uniformise this. -* There are too many lexical modes. +* There are too many lexical modes? */ #include +#include #include "translator-def.hh" #include "lily-guile.hh" @@ -73,6 +74,26 @@ TODO: #include "event.hh" #include "text-item.hh" + + +#define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x)) + + + +#define YYERROR_VERBOSE 1 + +My_lily_parser* my_lily_parser; +#define YYPARSE_PARAM my_lily_parser +#define YYLEX_PARAM my_lily_parser +#define THIS\ + ((My_lily_parser *) my_lily_parser) + +#define yyerror THIS->parser_error + + + + + bool regular_identifier_b (SCM id) { @@ -116,8 +137,6 @@ set_music_properties (Music *p, SCM a) -#define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x)) - Music* set_property_music (SCM sym, SCM value) { @@ -127,24 +146,6 @@ set_property_music (SCM sym, SCM value) return p; } - -// needed for bison.simple's malloc () and free () - -// #include -#include - - - -#define YYERROR_VERBOSE 1 - -My_lily_parser* my_lily_parser; -#define YYPARSE_PARAM my_lily_parser -#define YYLEX_PARAM my_lily_parser -#define THIS\ - ((My_lily_parser *) my_lily_parser) - -#define yyerror THIS->parser_error - %} /* We use SCMs to do strings, because it saves us the trouble of @@ -1405,8 +1406,10 @@ verbose_command_req: Music *key= MY_MAKE_MUSIC("KeyChangeEvent"); key->set_mus_property ("pitch-alist", $3); + key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy()); ((Music*)key)->transpose (* unsmob_pitch ($2)); - $$ = key; + + $$ = key; } ; @@ -1513,15 +1516,13 @@ steno_pitch: } | NOTENAME_PITCH sup_quotes { Pitch p = *unsmob_pitch ($1); - p.octave_ += $2; + p = p.transposed (Pitch ($2,0,0)); $$ = p.smobbed_copy (); } | NOTENAME_PITCH sub_quotes { Pitch p =* unsmob_pitch ($1); - - p.octave_ += -$2; + p = p.transposed (Pitch (-$2,0,0)); $$ = p.smobbed_copy (); - } ; @@ -1535,15 +1536,14 @@ steno_tonic_pitch: } | TONICNAME_PITCH sup_quotes { Pitch p = *unsmob_pitch ($1); - p.octave_ += $2; + p = p.transposed (Pitch ($2,0,0)); $$ = p.smobbed_copy (); } | TONICNAME_PITCH sub_quotes { Pitch p =* unsmob_pitch ($1); - p.octave_ += -$2; + p = p.transposed (Pitch (-$2,0,0)); $$ = p.smobbed_copy (); - } ; @@ -2067,27 +2067,17 @@ chord_step: chord_note: bare_unsigned { - Pitch m; - m.notename_ = ($1 - 1) % 7; - m.octave_ = $1 > 7 ? 1 : 0; - m.alteration_ = 0; + Pitch m($1 > 7 ? 1 : 0, ($1 - 1) % 7, 0); $$ = m.smobbed_copy (); } | bare_unsigned '+' { - Pitch m; - m.notename_ = ($1 - 1) % 7; - m.octave_ = $1 > 7 ? 1 : 0; - m.alteration_ = 1; - + Pitch m( $1 > 7 ? 1 : 0,($1 - 1) % 7, 1); $$ = m.smobbed_copy (); } | bare_unsigned CHORD_MINUS { - Pitch m; - m.notename_ = ($1 - 1) % 7; - m.octave_ = $1 > 7 ? 1 : 0; - m.alteration_ = -1; + Pitch m( $1 > 7 ? 1 : 0,($1 - 1) % 7, -1); $$ = m.smobbed_copy (); } diff --git a/lily/pitch.cc b/lily/pitch.cc index f49b2bd8fb..b4250900dc 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -140,13 +140,11 @@ Pitch interval (Pitch const & from , Pitch const & to ) { int sound = to.semitone_pitch() - from.semitone_pitch (); - Pitch pt ; - pt.octave_ = to.octave_ - from.octave_; - pt.notename_ = to.notename_ - from.notename_; - pt.alteration_ = to.alteration_ - from.alteration_; - pt.alteration_ += sound - pt.semitone_pitch(); + Pitch pt (to.get_octave () - from.get_octave (), + to.get_notename() - from.get_notename(), + to.get_alteration() - from.get_alteration()); - return pt; + return pt.transposed (Pitch(0,0,sound - pt.semitone_pitch())); } @@ -184,7 +182,7 @@ Pitch::string () const return copy of resulting pitch */ Pitch -Pitch::to_relative_octave (Pitch p) +Pitch::to_relative_octave (Pitch p) const { int oct_mod = octave_ + 1; // account for c' = octave 1 iso. 0 4 Pitch up_pitch (p); @@ -204,9 +202,7 @@ Pitch::to_relative_octave (Pitch p) n = down_pitch; n.octave_ += oct_mod; - - *this = n; - return *this; + return n; } void @@ -240,9 +236,7 @@ LY_DEFINE(ly_pitch_transpose, SCM_ASSERT_TYPE(t, p, SCM_ARG1, __FUNCTION__, "pitch") ; SCM_ASSERT_TYPE(d, delta, SCM_ARG1, __FUNCTION__, "pitch") ; - Pitch tp =*t; - tp.transpose (*d); - return tp.smobbed_copy (); + return t->transposed (*d).smobbed_copy (); } /****************************************************************/ @@ -398,3 +392,10 @@ Pitch::get_alteration () const return alteration_; } +Pitch +Pitch::transposed (Pitch d) const +{ + Pitch p =*this; + p.transpose (d); + return p; +} diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index c50cff5b19..57e6f9310a 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -76,6 +76,9 @@ head_characteristic (Grob * col) 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 Rest_collision::do_shift (Grob *me) diff --git a/lily/staff-symbol-engraver.cc b/lily/staff-symbol-engraver.cc index e666f3b87f..ea7300749a 100644 --- a/lily/staff-symbol-engraver.cc +++ b/lily/staff-symbol-engraver.cc @@ -71,8 +71,8 @@ Staff_symbol_engraver::acknowledge_grob (Grob_info s) ENTER_DESCRIPTION(Staff_symbol_engraver, -/* descr */ "create the constellation of five (default) -staff lines.", +/* descr */ "create the constellation of five (default) " +"staff lines.", /* creats*/ "StaffSymbol", /* accepts */ "", /* acks */ "grob-interface", diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index 2e8aafd481..c2e2db386e 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -173,8 +173,8 @@ Stem_engraver::try_music (Music* r) } ENTER_DESCRIPTION(Stem_engraver, -/* descr */ "Create stems and single-stem tremolos. It also works together with -the beam engraver for overriding beaming.", +/* descr */ "Create stems and single-stem tremolos. It also works together with " +"the beam engraver for overriding beaming.", /* creats*/ "Stem StemTremolo", /* accepts */ "tremolo-event", /* acks */ "rhythmic-head-interface", diff --git a/lily/thread-devnull-engraver.cc b/lily/thread-devnull-engraver.cc index 9822ad63ef..8480139e6a 100644 --- a/lily/thread-devnull-engraver.cc +++ b/lily/thread-devnull-engraver.cc @@ -49,14 +49,14 @@ Thread_devnull_engraver::acknowledge_grob (Grob_info i) Thread_devnull_engraver::Thread_devnull_engraver(){} ENTER_DESCRIPTION(Thread_devnull_engraver, -/* descr */ "Kill elements whenever we are Voice called `two' and either -unison, unisilence or soloADue is set.@footnote{On unix systems, the -file @file{/dev/null} is special device: anything written to it is -discarded.}. This engraver works closely together with the part -combiner. When the part combiner notices that two threads are -identical, it tells the @code{Thread_devnull_engraver} to discard -everything in the second thread. -", +/* descr */ "Kill elements whenever we are Voice called `two' and either " +"unison, unisilence or soloADue is set.@footnote{On unix systems, the " +"file @file{/dev/null} is special device: anything written to it is " +"discarded.}. This engraver works closely together with the part " +"combiner. When the part combiner notices that two threads are " +"identical, it tells the @code{Thread_devnull_engraver} to discard " +"everything in the second thread. " +, /* creats*/ "", /* accepts */ "", /* acks */ "grob-interface", diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc index 269c2d60d0..5456a6820a 100644 --- a/lily/timing-engraver.cc +++ b/lily/timing-engraver.cc @@ -88,10 +88,10 @@ Timing_engraver::stop_translation_timestep () ENTER_DESCRIPTION (Timing_engraver, -/* descr */ " Responsible for synchronizing timing information from staves. -Normally in @code{Score}. In order to create polyrhythmic music, -this engraver should be removed from @code{Score} and placed in -@code{Staff}.", +/* descr */ " Responsible for synchronizing timing information from staves. " +"Normally in @code{Score}. In order to create polyrhythmic music, " +"this engraver should be removed from @code{Score} and placed in " +"@code{Staff}.", /* creats*/ "", /* accepts */ "", /* acks */ "", diff --git a/scm/double-plus-new-chord-name.scm b/scm/double-plus-new-chord-name.scm index a5c9836a8e..0ef705a072 100644 --- a/scm/double-plus-new-chord-name.scm +++ b/scm/double-plus-new-chord-name.scm @@ -81,18 +81,18 @@ ;; Generic PITCH/MARKUP functions -(define (ly:pitch-diff pitch tonic) - "Return pitch with value PITCH - TONIC, ie, -TONIC == (ly:pitch-transpose tonic delta)." - (let ((simple-octave (- (ly:pitch-octave pitch) (ly:pitch-octave tonic))) +(define (ly:pitch-diff pitch root) + "Return pitch with value PITCH - ROOT, ie, +ROOT == (ly:pitch-transpose root delta)." + (let ((simple-octave (- (ly:pitch-octave pitch) (ly:pitch-octave root))) (simple-notename - (- (ly:pitch-notename pitch) (ly:pitch-notename tonic)))) + (- (ly:pitch-notename pitch) (ly:pitch-notename root)))) (let ((octave (+ simple-octave (quotient simple-notename 7) (if (< simple-notename 0) -1 0))) (notename (modulo simple-notename 7))) (let ((alteration (- (ly:pitch-semitones pitch) - (ly:pitch-semitones tonic) + (ly:pitch-semitones root) (ly:pitch-semitones (ly:make-pitch octave notename 0))))) (ly:make-pitch octave notename alteration))))) @@ -122,7 +122,7 @@ TONIC == (ly:pitch-transpose tonic delta)." ;; FIXME: if/when double-plus-new-chord->markup get installed ;; setting and calling can be done a bit handier. (define-public (double-plus-new-chord->markup - func pitches bass inversion options) + func root-markup pitches bass inversion options) "Entry point for New_chord_name_engraver. See double-plus-new-chord-name.scm for the signature of FUNC. PITCHES, BASS and INVERSION are lily pitches. OPTIONS is an alist-alist (see @@ -133,9 +133,9 @@ input/test/dpncnt.ly). (define (step-nr pitch) (let* ((pitch-nr (+ (* 7 (ly:pitch-octave pitch)) (ly:pitch-notename pitch))) - (tonic-nr (+ (* 7 (ly:pitch-octave (car pitches))) + (root-nr (+ (* 7 (ly:pitch-octave (car pitches))) (ly:pitch-notename (car pitches))))) - (+ 1 (- pitch-nr tonic-nr)))) + (+ 1 (- pitch-nr root-nr)))) (define (next-third pitch) (ly:pitch-transpose pitch @@ -232,8 +232,8 @@ input/test/dpncnt.ly). (partial-pitches (car partial-exception)) (partial-markup (markup-or-empty-markup (cdr partial-exception))) - (tonic (car pitches)) - (full (get-full-list tonic)) + (root (car pitches)) + (full (get-full-list root)) ;; kludge alert: replace partial matched lower part of all with ;; 'normal' pitches from full ;; (all pitches) @@ -262,12 +262,12 @@ input/test/dpncnt.ly). (case func ((banter) - ;; tonic + ;; root ;; + steps:altered + (highest all -- if not altered) ;; + subs:missing - (let* ((tonic->markup (assoc-get-default - 'tonic->markup options pitch->markup)) + (let* ((root->markup (assoc-get-default + 'root->markup options pitch->markup)) (step->markup (assoc-get-default 'step->markup options step->markup-plusminus)) (sub->markup (assoc-get-default @@ -279,11 +279,11 @@ input/test/dpncnt.ly). (if (pair? full-markup) - (make-line-markup (list (tonic->markup tonic) full-markup)) + (make-line-markup (list (root->markup root) full-markup)) (make-line-markup (list - (tonic->markup tonic) + (root->markup root) partial-markup (make-normal-size-super-markup (markup-join @@ -300,12 +300,12 @@ input/test/dpncnt.ly). ((jazz) - ;; tonic + ;; root ;; + steps:(highest base) + cons-alt ;; + 'add' ;; + steps:rest - (let* ((tonic->markup (assoc-get-default - 'tonic->markup options pitch->markup)) + (let* ((root->markup (assoc-get-default + 'root->markup options pitch->markup)) (step->markup (assoc-get-default 'step->markup options step->markup-accidental)) (sep (assoc-get-default @@ -315,11 +315,11 @@ input/test/dpncnt.ly). (if (pair? full-markup) - (make-line-markup (list (tonic->markup tonic) full-markup)) + (make-line-markup (list (root->markup root) full-markup)) (make-line-markup (list - (tonic->markup tonic) + (root->markup root) partial-markup (make-normal-size-super-markup (make-line-markup diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index 3064e154cf..fb9ee1253e 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -212,8 +212,11 @@ Overrides all other font-X qualifiers.") (grob-property-description 'font-design-size number? "partial font definition: exact font size in points FIXME: should override font-relative-size.") (grob-property-description 'font-magnification number? "Magnification of the font. If undefined, the default is @code{1.0}.") -(grob-property-description 'font-relative-size number? "partial font definition: the relative size compared the `normal' size. - 0 is style-sheet's normal size, -1 is smaller, +1 is bigger, -1 is smaller.") + +(grob-property-description 'font-relative-size number? "partial font +definition: the relative size compared the `normal' size. 0 is +style-sheet's normal size, -1 is smaller, +1 is bigger.") + (grob-property-description 'font-series symbol? "partial font definition: medium, bold.") (grob-property-description 'font-shape symbol? "partial font definition: upright or italic.") diff --git a/scm/music-property-description.scm b/scm/music-property-description.scm index af871aa0d9..a20edaced9 100644 --- a/scm/music-property-description.scm +++ b/scm/music-property-description.scm @@ -44,6 +44,7 @@ TODO: consider making type into symbol ") (music-property-description 'direction ly:dir? "Print this up or down?") (music-property-description 'text-type symbol? "Particular type of text script (eg. finger, dynamic).") (music-property-description 'tempo-unit ly:duration? "The unit for the metronome count.") +(music-property-description 'tonic ly:pitch? "Base of the scale") (music-property-description 'element ly:music? "The single child of a Music_wrapper music object, or the body of a repeat.") (music-property-description 'elements music-list? "A list of elements for sequential of simultaneous music, or the alternatives of repeated music. ") (music-property-description 'force-accidental boolean? "If set, a cautionary accidental should always be printed on this note") diff --git a/scm/music-types.scm b/scm/music-types.scm index 4db44dd7c7..2b27cd4091 100644 --- a/scm/music-types.scm +++ b/scm/music-types.scm @@ -177,7 +177,7 @@ c8-[ c c-] c8") . ( (description . "") - (internal-class-name . "Key_change_req") + (internal-class-name . "Key_change_ev") (types . (general-music key-change-event event)) )) (LigatureEvent diff --git a/scm/translator-property-description.scm b/scm/translator-property-description.scm index c3196ed68c..364d58841b 100644 --- a/scm/translator-property-description.scm +++ b/scm/translator-property-description.scm @@ -391,6 +391,8 @@ settings. pair of numbers, signifying the time signature. For example #'(4 . 4) is a 4/4time signature.") (translator-property-description 'timing boolean? " Keep administration of measure length, position, bar number, etc? Switch off for cadenzas.") +(translator-property-description 'tonic ly:pitch? + "The tonic of the current scale") (translator-property-description 'transposing integer? "Transpose the MIDI output. Set this property to the number of half-steps to transpose by.") (translator-property-description 'tremoloFlags integer? "Number of tremolo flags to add if none is specified.") (translator-property-description 'tupletNumberFormatFunction procedure? -- 2.39.2