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<Key_change_req const*> (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 ()
Mark_req const * other = dynamic_cast<Mark_req const*> (r);
return other && scm_equal_p (other->mark_label_, mark_label_);
}
-
-void
-Key_change_req::transpose (Musical_pitch p)
-{
- key_->transpose (p);
-}
-
#include "array.hh"
#include "duration.hh"
#include "musical-pitch.hh"
-#include "newkey-def.hh"
#include "protected-scm.hh"
class Break_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 {
-/*
- newkey-def.hh -- declare Newkey_def
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#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 */
-
-
(c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#include "key-item.hh"
#include "command-request.hh"
#include "musical-request.hh"
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))
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_);
-/*
- newkey-def.cc -- implement Newkey_def
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#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;
-}