* 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-19 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * 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 <hjunes@cc.hut.fi>
* Documentation/user/refman.itely: fix typo.
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
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
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.
@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
--- /dev/null
+\header {
+ texidoc = "Ambituses indicate pitch ranges for voices."
+}
+
+\version "1.7.6"
+
+upper = \notes \relative c {
+ \clef "treble"
+ \key c \minor
+ as'' c e bes f cis d e f g f e d f d e
+ f d e e d f d e e d f d e e d f d e
+ f d e e d f d e e d f d e e d f d e
+}
+
+lower = \notes \relative c {
+ \clef "treble"
+ \key e \major
+ e'2 b4 g a c es fis a cis b a g f e d
+ f e d e f g f e d e f g f e d e f g
+ f e d e f g f e d e f g f e d e f g
+}
+
+\score { \context ChoirStaff {
+ <
+ \context Staff = one { \upper }
+ \context Staff = three { \lower }
+ > }
+ \paper {
+ \translator {
+ \ScoreContext
+ breakAlignOrder = #'(
+ instrument-name
+ left-edge
+ ambitus
+ span-bar
+ breathing-sign
+ clef
+ key-signature
+ staff-bar
+ time-signature
+ custos
+ )
+ }
+ \translator {
+ \VoiceContext
+ \consists Ambitus_engraver
+ }
+ }
+}
+%% new-chords-done %%
<< 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
}
\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."
}
+++ /dev/null
-\header {
- texidoc = "Ambituses indicate pitch ranges for voices."
-}
-
-\version "1.7.6"
-
-upper = \notes \relative c {
- \clef "treble"
- \key c \minor
- as'' c e bes f cis d e f g f e d f d e
- f d e e d f d e e d f d e e d f d e
- f d e e d f d e e d f d e e d f d e
-}
-
-lower = \notes \relative c {
- \clef "treble"
- \key e \major
- e'2 b4 g a c es fis a cis b a g f e d
- f e d e f g f e d e f g f e d e f g
- f e d e f g f e d e f g f e d e f g
-}
-
-\score { \context ChoirStaff {
- <
- \context Staff = one { \upper }
- \context Staff = three { \lower }
- > }
- \paper {
- \translator {
- \ScoreContext
- breakAlignOrder = #'(
- instrument-name
- left-edge
- ambitus
- span-bar
- breathing-sign
- clef
- key-signature
- staff-bar
- time-signature
- custos
- )
- }
- \translator {
- \VoiceContext
- \consists Ambitus_engraver
- }
- }
-}
-%% new-chords-done %%
-\version "1.7.6"
-
-
-
-\score {
-\notes \context Voice = VA \relative c'' {
- \grace {[b8^1 c^2]} d4^3
-}
-\paper {linewidth = -1. }}
-%% new-chords-done %%
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;
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);
*/
- 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));
/*
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);
*/
/**
- * 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
{
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);
}
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;
{
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;
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++;
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)));
}
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)));
}
*/
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);
}
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 */ "",
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 ()));
}
}
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;
/*
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),
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);
}
}
}
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)
{
}
return true;
}
-
-bool
-Key_change_req::do_equal_b (Event const * m )const
-{
- Key_change_req const * kc =dynamic_cast<Key_change_req const*> (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);
/**
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);
};
#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
/// 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
#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:
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 ();
Key_engraver::Key_engraver ()
{
- keyreq_ = 0;
+ key_ev_ = 0;
item_ = 0;
}
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)
bool
-Key_engraver::try_music (Music * req)
+Key_engraver::try_music (Music * ev)
{
- // if (Key_change_req *kc = dynamic_cast <Key_change_req *> (req))
- if (req->is_mus_type ("key-change-event"))
+ // if (Key_change_ev *kc = dynamic_cast <Key_change_ev *> (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<Key_change_req*> (req); // UGH.
- read_req (keyreq_);
+ key_ev_ = dynamic_cast<Key_change_ev*> (ev); // UGH.
+ read_ev (key_ev_);
}
return true;
void
Key_engraver::process_music ()
{
- if (keyreq_ ||
+ if (key_ev_ ||
get_property ("lastKeySignature") != get_property ("keySignature"))
create_key (false);
}
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))
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"));
}
{
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 ());
+
}
/* accepts */ "key-change-event",
/* acks */ "bar-line-interface clef-interface",
/* reads */ "keySignature lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature",
-/* write */ "lastKeySignature");
+/* write */ "lastKeySignature tonic keySignature");
virtual void stop_translation_timestep ();
private:
- Key_change_req* key_req_;
+ Key_change_ev* key_req_;
Audio_key* audio_;
};
(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);
bool
Key_performer::try_music (Music* req)
{
- if (Key_change_req *kc = dynamic_cast <Key_change_req *> (req))
+ if (Key_change_ev *kc = dynamic_cast <Key_change_ev *> (req))
{
if (key_req_)
warning (_ ("FIXME: key change merge"));
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;
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);
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);
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);
{
fingerings_[i].position_ = gh_scm2int (fingerings_[i].head_ -> get_grob_property( "staff-position"));
}
+
+ SCM fhd = get_property ("fingerHorizontalDirection");
Array<Finger_tuple> up, down, horiz;
for (int i = fingerings_.size(); i--;)
}
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
{
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);
* 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 <ctype.h>
+#include <stdlib.h>
#include "translator-def.hh"
#include "lily-guile.hh"
#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)
{
-#define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
-
Music*
set_property_music (SCM sym, SCM value)
{
return p;
}
-
-// needed for bison.simple's malloc () and free ()
-
-// #include <malloc.h>
-#include <stdlib.h>
-
-
-
-#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
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;
}
;
}
| 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 ();
-
}
;
}
| 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 ();
-
}
;
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 ();
}
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()));
}
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);
n = down_pitch;
n.octave_ += oct_mod;
-
- *this = n;
- return *this;
+ return n;
}
void
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 ();
}
/****************************************************************/
return alteration_;
}
+Pitch
+Pitch::transposed (Pitch d) const
+{
+ Pitch p =*this;
+ p.transpose (d);
+ return p;
+}
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)
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",
}
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",
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",
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 */ "",
;; 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)))))
;; 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
(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
(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)
(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
(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
((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
(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
(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.")
(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")
. (
(description . "")
- (internal-class-name . "Key_change_req")
+ (internal-class-name . "Key_change_ev")
(types . (general-music key-change-event event))
))
(LigatureEvent
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?