From: fred Date: Tue, 26 Mar 2002 23:23:05 +0000 (+0000) Subject: lilypond-1.3.60 X-Git-Tag: release/1.5.59~1574 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=dcce80b840cc2945e1cf5fe321821d4e2ee59fae;p=lilypond.git lilypond-1.3.60 --- diff --git a/lily/command-request.cc b/lily/command-request.cc index fea2de22a4..92143f8a55 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -98,25 +98,50 @@ Tempo_req::do_equal_b (Request const *r) const return t&& t->dur_.length_mom ()== dur_.length_mom () && metronome_i_ == t->metronome_i_; } -void -Key_change_req::do_print () const -{ -} -Key_change_req::Key_change_req () -{ - key_ = 0; -} -Key_change_req::Key_change_req (Key_change_req const&s) - : Request (s) + +bool +Key_change_req::do_equal_b (Request const * req) const { - key_ = s.key_ ? new Newkey_def (*s.key_) : 0; + Key_change_req const * k = dynamic_cast (req); + return k && scm_equal_p (pitch_alist_, k->pitch_alist_); } -Key_change_req::~Key_change_req () + + +void +Key_change_req::transpose (Musical_pitch p) { - delete key_; + SCM newlist = SCM_EOL; + for (SCM s = pitch_alist_; gh_pair_p (s); s = gh_cdr (s)) + { + SCM k = gh_caar (s); + + if (gh_pair_p (k)) + { + Musical_pitch orig (gh_list (gh_car (k), gh_cdr (k), gh_cdr (s), SCM_UNDEFINED)); + + orig.transpose (p); + + SCM key = gh_cons (gh_int2scm (orig.octave_i_), + gh_int2scm (orig.notename_i_)); + + newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)), + newlist); + } + else if (gh_number_p (k)) + { + Musical_pitch orig (gh_list (gh_int2scm (0), k, gh_cdar (s), SCM_UNDEFINED)); + orig.transpose (p); + + SCM key =gh_int2scm (orig.notename_i_); + newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)), + newlist); + } + } + + pitch_alist_ = newlist; } Break_req::Break_req () @@ -131,10 +156,3 @@ Mark_req::do_equal_b (Request const * r) const Mark_req const * other = dynamic_cast (r); return other && scm_equal_p (other->mark_label_, mark_label_); } - -void -Key_change_req::transpose (Musical_pitch p) -{ - key_->transpose (p); -} - diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index a79e711325..845598a3ad 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -14,7 +14,6 @@ #include "array.hh" #include "duration.hh" #include "musical-pitch.hh" -#include "newkey-def.hh" #include "protected-scm.hh" class Break_req : public Request { @@ -99,24 +98,16 @@ class Breathing_sign_req : public Request { /** Handle key changes. - Routines for sharps and flats are separated, - so that caller may identify non-conventional keys. */ -/* - UGH! - */ class Key_change_req : public Request { public: - Key_change_req (); - ~Key_change_req(); - Key_change_req(Key_change_req const &); - Newkey_def *key_; + Protected_scm pitch_alist_; protected: VIRTUAL_COPY_CONS(Music); void transpose (Musical_pitch d); - virtual void do_print () const; + bool do_equal_b (Request const * )const; }; class Clef_change_req : public Request { diff --git a/lily/include/key-def.hh b/lily/include/key-def.hh index 65296f8106..e69de29bb2 100644 --- a/lily/include/key-def.hh +++ b/lily/include/key-def.hh @@ -1,2 +0,0 @@ - -#error diff --git a/lily/include/newkey-def.hh b/lily/include/newkey-def.hh index dfa20c6c6b..e69de29bb2 100644 --- a/lily/include/newkey-def.hh +++ b/lily/include/newkey-def.hh @@ -1,36 +0,0 @@ -/* - newkey-def.hh -- declare Newkey_def - - source file of the GNU LilyPond music typesetter - - (c) 2000 Han-Wen Nienhuys - - */ - -#ifndef NEWKEY_DEF_HH -#define NEWKEY_DEF_HH - -#include "protected-scm.hh" -#include "musical-pitch.hh" - -class Newkey_def -{ - -public: - Protected_scm pitch_alist_; - - Newkey_def(); - - /// return number of flats in key - int flats_i () const; - - /// return number of sharps in key - int sharps_i () const; - int accs_i (int) const; - - void transpose (Musical_pitch d); -}; - -#endif /* NEWKEY_DEF_HH */ - - diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index d5091eb70f..64f4e4f0a5 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -6,7 +6,6 @@ (c) 1997--2000 Han-Wen Nienhuys */ - #include "key-item.hh" #include "command-request.hh" #include "musical-request.hh" @@ -139,10 +138,10 @@ Key_engraver::do_pre_move_processing () void Key_engraver::read_req (Key_change_req const * r) { - if (!r->key_) + if (r->pitch_alist_ == SCM_UNDEFINED) return; - SCM n = scm_list_copy (r->key_->pitch_alist_); + SCM n = scm_list_copy (r->pitch_alist_); SCM accs = SCM_EOL; for (SCM s = get_property ("keyAccidentalOrder"); gh_pair_p (s); s = gh_cdr (s)) diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 81fa1c5296..b55210a448 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -26,7 +26,7 @@ Key_performer::~Key_performer () void Key_performer::do_process_music () { - if (key_req_l_ && key_req_l_->key_) + if (key_req_l_ && key_req_l_->pitch_alist_ != SCM_UNDEFINED) { audio_p_ = new Audio_key (); // *key_req_l_->key_); Audio_element_info info (audio_p_, key_req_l_); diff --git a/lily/newkey-def.cc b/lily/newkey-def.cc index 6d8e5836f8..e69de29bb2 100644 --- a/lily/newkey-def.cc +++ b/lily/newkey-def.cc @@ -1,51 +0,0 @@ -/* - newkey-def.cc -- implement Newkey_def - - source file of the GNU LilyPond music typesetter - - (c) 2000 Han-Wen Nienhuys - - */ - -#include "newkey-def.hh" -#include "misc.hh" - - -Newkey_def::Newkey_def() -{ - pitch_alist_ = SCM_EOL; -} - -void -Newkey_def::transpose (Musical_pitch p) -{ - SCM newlist = SCM_EOL; - for (SCM s = pitch_alist_; gh_pair_p (s); s = gh_cdr (s)) - { - SCM k = gh_caar (s); - - if (gh_pair_p (k)) - { - Musical_pitch orig (gh_list (gh_car (k), gh_cdr (k), gh_cdr (s), SCM_UNDEFINED)); - - orig.transpose (p); - - SCM key = gh_cons (gh_int2scm (orig.octave_i_), - gh_int2scm (orig.notename_i_)); - - newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)), - newlist); - } - else if (gh_number_p (k)) - { - Musical_pitch orig (gh_list (gh_int2scm (0), k, gh_cdar (s), SCM_UNDEFINED)); - orig.transpose (p); - - SCM key =gh_int2scm (orig.notename_i_); - newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)), - newlist); - } - } - - pitch_alist_ = newlist; -}