+2005-01-16 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/include/transposed-music.hh (class Transposed_music): remove.
+
+ * lily/transposed-music.cc: remove
+
+ * lily/include/relative-music.hh: remove.
+
+ * lily/include/music-sequence.hh (struct Music_sequence): change
+ into "namespace" class.
+
+ * lily/untransposable-music.cc (Module): remove
+
+ * lily/include/un-relativable-music.hh (Module): remove
+
+ * lily/include/untransposable-music.hh (Module): remove
+
+ * lily/include/music-list.hh (Module): remove file
+
+ * lily/un-relativable-music.cc: remove file.
+
2005-01-14 Jan Nieuwenhuizen <janneke@gnu.org>
* lily/parser.yy: Compile fix.
#include "item.hh"
#include "chord-tremolo-iterator.hh"
#include "stem-tremolo.hh"
-#include "music-list.hh"
#include "math.h" // ceil
/**
#include "context.hh"
#include "warn.hh"
-#include "music-list.hh"
#include "event.hh"
Event_chord_iterator::Event_chord_iterator ()
{
if (last_processed_mom_ < Moment (0))
{
- for (SCM s = dynamic_cast<Music_sequence *> (get_music ())->music_list ();
+ for (SCM s = get_music ()->get_property ("elements");
scm_is_pair (s); s = scm_cdr (s))
{
Music *mus = unsmob_music (scm_car (s));
}
return mom.smobbed_copy();
}
-
-
-Pitch
-Event::to_relative_octave (Pitch last)
-{
- Pitch *old_pit = unsmob_pitch (get_property ("pitch"));
- if (old_pit)
- {
- Pitch new_pit = *old_pit;
- new_pit = new_pit.to_relative_octave (last);
-
- SCM check = get_property ("absolute-octave");
- if (scm_is_number (check) &&
- new_pit.get_octave () != scm_to_int (check))
- {
- Pitch expected_pit (scm_to_int (check),
- new_pit.get_notename (),
- new_pit.get_alteration ());
- origin ()->warning (_f ("octave check failed; expected %s, found: %s",
- expected_pit.to_string (),
- new_pit.to_string ()));
- new_pit = expected_pit;
- }
-
- set_property ("pitch", new_pit.smobbed_copy ());
-
- return new_pit;
- }
- return last;
-}
Event::Event (SCM i)
: Music (i)
#include "input.hh"
#include "repeated-music.hh"
-#include "music-list.hh"
#include "simultaneous-music-iterator.hh"
#include "context.hh"
#include "warn.hh"
#include "event.hh"
-#include "music-list.hh"
#include "music-iterator.hh"
#include "score-context.hh"
#include "context-def.hh"
Event (SCM);
VIRTUAL_COPY_CONSTRUCTOR (Music, Event);
DECLARE_SCHEME_CALLBACK(length_callback,(SCM));
- virtual Pitch to_relative_octave (Pitch);
};
+++ /dev/null
-/*
- music-list.hh -- declare Simultaneous_music, Sequential_music, Event_chord
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef MUSIC_LIST_HH
-#define MUSIC_LIST_HH
-
-#include "music-sequence.hh"
-
-/**
- Simultaneous_music is a list of music-elements which happen simultaneously
- */
-class Simultaneous_music : public Music_sequence
-{
-public:
- Simultaneous_music (SCM);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Simultaneous_music);
- virtual Pitch to_relative_octave (Pitch);
-};
-
-/*
- A chord.
- */
-class Event_chord : public Simultaneous_music
-{
-public:
- VIRTUAL_COPY_CONSTRUCTOR (Music, Event_chord);
- virtual Pitch to_relative_octave (Pitch);
- Event_chord (SCM);
-};
-
-#endif /* MUSIC_LIST_HH */
#include "music.hh"
-class Music_sequence : public Music
+struct Music_sequence
{
public:
- Music_sequence (SCM h);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Music_sequence);
DECLARE_SCHEME_CALLBACK(cumulative_length_callback, (SCM));
DECLARE_SCHEME_CALLBACK(maximum_length_callback, (SCM));
DECLARE_SCHEME_CALLBACK(minimum_start_callback, (SCM));
DECLARE_SCHEME_CALLBACK(first_start_callback, (SCM));
- SCM music_list () const;
+ DECLARE_SCHEME_CALLBACK(simultaneous_relative_callback, (SCM, SCM));
+ DECLARE_SCHEME_CALLBACK(event_chord_relative_callback, (SCM, SCM));
Pitch do_relative_octave (Pitch p, bool b);
bool internal_is_music_type (SCM) const;
int duration_log () const;
+ DECLARE_SCHEME_CALLBACK(relative_callback,(SCM,SCM));
virtual Pitch to_relative_octave (Pitch);
String name () const;
Moment get_length () const;
+++ /dev/null
-/*
- relative-music.hh -- declare Relative_octave_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef RELATIVE_MUSIC_HH
-#define RELATIVE_MUSIC_HH
-
-#include "music-wrapper.hh"
-
-class Relative_octave_music : public Music_wrapper
-{
-public:
- Relative_octave_music (SCM);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Relative_octave_music);
-
- virtual Pitch to_relative_octave (Pitch);
-};
-
-#endif /* RELATIVE_MUSIC_HH */
-
-
+++ /dev/null
-/*
- relative-octave-check.hh -- declare Relative_octave_octave-check
-
- source file of GNU LilyPond
-
- (c) 2003--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef RELATIVE_OCTAVE_CHECK_HH
-#define RELATIVE_OCTAVE_CHECK_HH
-
-#include "music.hh"
-
-class Relative_octave_check : public Music
-{
-public:
- Relative_octave_check (SCM);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Relative_octave_check);
-
- virtual Pitch to_relative_octave (Pitch);
-};
-
-#endif /* RELATIVE_OCTAVE_CHECK_HH */
-
-
/* How often do we repeat? */
int repeat_count () const;
+ DECLARE_SCHEME_CALLBACK(relative_callback,(SCM,SCM));
+
virtual Pitch to_relative_octave (Pitch);
Moment body_get_length () const;
+++ /dev/null
-/*
- transposed-music.hh -- declare Transposed_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef TRANSPOSED_MUSIC_HH
-#define TRANSPOSED_MUSIC_HH
-
-#include "music-wrapper.hh"
-
-class Transposed_music : public Music_wrapper
-{
-public:
- Transposed_music (SCM);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Transposed_music);
-
- virtual Pitch to_relative_octave (Pitch);
-};
-
-#endif /* TRANSPOSED_MUSIC_HH */
-
+++ /dev/null
-/*
- un-relativable-music.hh -- declare Un_relativable_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2001--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef UN_RELATIVABLE_MUSIC_HH
-#define UN_RELATIVABLE_MUSIC_HH
-
-#include "music-wrapper.hh"
-
-class Un_relativable_music: public Music_wrapper
-{
-public:
- Un_relativable_music (SCM);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Un_relativable_music);
-
- Pitch to_relative_octave (Pitch);
-};
-
-#endif /* UN_RELATIVABLE_MUSIC_HH */
-
+++ /dev/null
-/*
- untransposable-music.hh -- declare Untransposable_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2001--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef UNTRANSPOSABLE_MUSIC_HH
-#define UNTRANSPOSABLE_MUSIC_HH
-
-#include "music-wrapper.hh"
-
-class Untransposable_music : public Music_wrapper
-{
-public:
- Untransposable_music (SCM);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Untransposable_music);
-
- virtual Pitch to_relative_octave (Pitch);
-};
-
-
-#endif /* UNTRANSPOSABLE_MUSIC_HH */
-
(c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "music-list.hh"
#include "warn.hh"
+#include "scm-option.hh"
#include "pitch.hh"
#include "input.hh"
-
-Music_sequence::Music_sequence (SCM x)
- : Music (x)
-{
-}
-
-SCM
-Music_sequence::music_list () const
-{
- return get_property ("elements");
-}
+#include "music-sequence.hh"
void
transpose_music_list (SCM lst, Pitch rq)
}
}
- return (ret_first)? first : last;
+ return (ret_first) ? first : last;
}
unsmob_music (scm_car (s))->compress (m);
}
-ADD_MUSIC (Music_sequence);
-
Moment
Music_sequence::minimum_start (SCM l)
{
return m;
}
+MAKE_SCHEME_CALLBACK(Music_sequence, simultaneous_relative_callback, 2);
+SCM
+Music_sequence::simultaneous_relative_callback (SCM music, SCM pitch)
+{
+ Music *me = unsmob_music (music);
+ Pitch p = *unsmob_pitch (pitch);
+
+ SCM elts = me->get_property ("elements");
+
+ Pitch retval = music_list_to_relative (elts, p, false);
+ if (lily_1_8_relative)
+ {
+ Pitch retval_1_8 = music_list_to_relative (elts, p, true);
+ if (retval_1_8 != retval)
+ lily_1_8_compatibility_used = true;
+
+ retval = retval_1_8;
+ }
+
+ return retval.smobbed_copy ();
+}
+
+MAKE_SCHEME_CALLBACK(Music_sequence,event_chord_relative_callback,2);
+SCM
+Music_sequence::event_chord_relative_callback (SCM music, SCM pitch)
+{
+ Music *me = unsmob_music (music);
+ Pitch p = *unsmob_pitch (pitch);
+ return music_list_to_relative (me->get_property ("elements"),
+ p, true).smobbed_copy ();
+}
+
*/
#include "music.hh"
-
+#include "music-sequence.hh"
#include "duration.hh"
#include "input-smob.hh"
#include "ly-smobs.icc"
#include "main.hh"
-#include "music-list.hh"
#include "pitch.hh"
#include "score.hh"
#include "warn.hh"
}
Pitch
-Music::to_relative_octave (Pitch p)
+Music::to_relative_octave (Pitch last)
{
+ SCM callback = get_property ("to-relative-callback");
+ if (ly_c_procedure_p (callback))
+ {
+ Pitch * p = unsmob_pitch (scm_call_2 (callback, self_scm(), last.smobbed_copy ()));
+ return *p;
+ }
+
SCM elt = get_property ("element");
+ Pitch *old_pit = unsmob_pitch (get_property ("pitch"));
+ if (old_pit)
+ {
+ Pitch new_pit = *old_pit;
+ new_pit = new_pit.to_relative_octave (last);
+ SCM check = get_property ("absolute-octave");
+ if (scm_is_number (check) &&
+ new_pit.get_octave () != scm_to_int (check))
+ {
+ Pitch expected_pit (scm_to_int (check),
+ new_pit.get_notename (),
+ new_pit.get_alteration ());
+ origin ()->warning (_f ("octave check failed; expected %s, found: %s",
+ expected_pit.to_string (),
+ new_pit.to_string ()));
+ new_pit = expected_pit;
+ }
+
+ set_property ("pitch", new_pit.smobbed_copy ());
+
+ last = new_pit;
+ }
+
+
if (Music *m = unsmob_music (elt))
- p = m->to_relative_octave (p);
+ last = m->to_relative_octave (last);
- p = music_list_to_relative (get_property ("elements"), p, false);
- return p;
+ last = music_list_to_relative (get_property ("elements"), last, false);
+ return last;
}
void
*/
#include "input.hh"
-#include "music-list.hh"
#include "simple-music-iterator.hh"
+#include "music.hh"
class Output_property_music_iterator : public Simple_music_iterator
{
#include "lilypond-input-version.hh"
#include "main.hh"
#include "misc.hh"
-#include "music-list.hh"
-#include "music-sequence.hh"
#include "lily-lexer.hh"
#include "lily-parser.hh"
#include "paper-book.hh"
*/
-#include "relative-octave-check.hh"
-
+#include "music.hh"
#include "input.hh"
#include "pitch.hh"
-Pitch
-Relative_octave_check::to_relative_octave (Pitch p)
+class Relative_octave_check
{
- Pitch * check_p = unsmob_pitch (get_property ("pitch"));
+public:
+ DECLARE_SCHEME_CALLBACK(relative_callback,(SCM,SCM));
+};
+
+MAKE_SCHEME_CALLBACK(Relative_octave_check, relative_callback, 2)
+SCM
+Relative_octave_check::relative_callback (SCM music, SCM last_pitch)
+{
+ Pitch p = *unsmob_pitch (last_pitch);
+ Music *m = unsmob_music (music);
+ Pitch *check_p = unsmob_pitch (m->get_property ("pitch"));
+
int delta_oct = 0;
if (check_p)
{
String s = _("Failed octave check, got: ");
s += result.to_string ();
- origin ()->warning (s);
+ m->origin ()->warning (s);
delta_oct = check_p->get_octave () - result.get_octave ();
}
}
- return Pitch (p.get_octave () + delta_oct,
- p.get_notename (), p.get_alteration ());
+ return Pitch (p.get_octave () + delta_oct,
+ p.get_notename (), p.get_alteration ()).smobbed_copy ();
}
-
-
-Relative_octave_check::Relative_octave_check (SCM x)
- : Music (x)
-{
-}
-
-ADD_MUSIC (Relative_octave_check);
*/
-#include "relative-music.hh"
+#include "music.hh"
+#include "pitch.hh"
#include "warn.hh"
#include "scm-option.hh"
-Pitch
-Relative_octave_music::to_relative_octave (Pitch p)
+
+class Relative_octave_music
+{
+public:
+ DECLARE_SCHEME_CALLBACK(relative_callback,(SCM,SCM));
+ DECLARE_SCHEME_CALLBACK(no_relative_callback,(SCM,SCM));
+};
+
+MAKE_SCHEME_CALLBACK(Relative_octave_music,no_relative_callback,2)
+SCM
+Relative_octave_music::no_relative_callback (SCM music, SCM pitch)
+{
+ (void)music;
+ return pitch;
+}
+
+MAKE_SCHEME_CALLBACK(Relative_octave_music,relative_callback,2)
+SCM
+Relative_octave_music::relative_callback (SCM music, SCM pitch)
{
+ Music *me = unsmob_music (music);
if (lily_1_8_relative)
{
lily_1_8_compatibility_used = true;
/* last-pitch should be junked some time, when
we ditch 1.8 compat too.
-
+cvs-
When you do, B should start where A left off.
\relative { A \relative { ...} B } */
- Pitch *ptr = unsmob_pitch (get_property ("last-pitch"));
- return (ptr) ? *ptr : p;
+ SCM last_pitch = me->get_property ("last-pitch");
+ Pitch *ptr = unsmob_pitch (last_pitch);
+ return (ptr) ? last_pitch : pitch;
}
else
- return p;
+ return pitch;
}
-Relative_octave_music::Relative_octave_music (SCM x)
- : Music_wrapper (x)
-{
-
-}
-
-ADD_MUSIC (Relative_octave_music);
-
-
*/
#include "repeated-music.hh"
-
-#include "music-list.hh"
+#include "music-sequence.hh"
#include "pitch.hh"
#include "warn.hh"
#include "scm-option.hh"
*/
#include "sequential-iterator.hh"
-
+#include "music.hh"
#include "translator-group.hh"
#include "context.hh"
-#include "music-list.hh"
#include "grace-fixup.hh"
/*
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "sequential-music-iterator.hh"
-
#include "context.hh"
+#include "sequential-music-iterator.hh"
+#include "music.hh"
#include "warn.hh"
-#include "music-list.hh"
IMPLEMENT_CTOR_CALLBACK (Sequential_music_iterator);
*/
#include "simultaneous-music-iterator.hh"
-
+#include "music.hh"
#include "context.hh"
#include "warn.hh"
-#include "music-list.hh"
#include "context-def.hh"
Simultaneous_music_iterator::Simultaneous_music_iterator ()
-/*
- simultaneous-music.cc -- implement Simultaneous_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
-*/
-
-#include "input.hh"
-#include "pitch.hh"
-#include "music-list.hh"
-#include "scm-option.hh"
-
-Simultaneous_music::Simultaneous_music (SCM x)
- : Music_sequence (x)
-{
-
-}
-
-Pitch
-Simultaneous_music::to_relative_octave (Pitch p)
-{
- Pitch retval = music_list_to_relative (music_list (), p, false);
- if (lily_1_8_relative)
- {
- Pitch retval_1_8 = music_list_to_relative (music_list (), p, true);
- if (retval_1_8 != retval)
- lily_1_8_compatibility_used = true;
-
- retval = retval_1_8;
- }
-
- return retval;
-}
-ADD_MUSIC (Simultaneous_music);
-
-Pitch
-Event_chord::to_relative_octave (Pitch p)
-{
- return music_list_to_relative (music_list (), p, true);
-}
-
-Event_chord::Event_chord (SCM x)
- : Simultaneous_music (x)
-{
-}
-
-ADD_MUSIC (Event_chord);
+++ /dev/null
-/*
- transposed-music.cc -- implement Transposed_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "transposed-music.hh"
-
-#include "warn.hh"
-
-Pitch
-Transposed_music::to_relative_octave (Pitch p)
-{
- return p;
-}
-
-ADD_MUSIC (Transposed_music);
-
-Transposed_music::Transposed_music (SCM x)
- : Music_wrapper (x)
-{
-
-}
#include "tuplet-bracket.hh"
#include "note-column.hh"
#include "beam.hh"
-#include "music-list.hh"
#include "engraver.hh"
#include "spanner.hh"
+++ /dev/null
-/*
- un-relativable-music.cc -- implement Un_relativable_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2001--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "un-relativable-music.hh"
-
-Un_relativable_music::Un_relativable_music (SCM x)
- : Music_wrapper (x)
-{
-}
-
-Pitch
-Un_relativable_music::to_relative_octave (Pitch p)
-{
- return p;
-}
-
-ADD_MUSIC (Un_relativable_music);
-
+++ /dev/null
-/*
-untransposable-music.cc -- implement Untransposable_music
-
-source file of the GNU LilyPond music typesetter
-
-(c) 2001--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "untransposable-music.hh"
-
-Pitch
-Untransposable_music::to_relative_octave (Pitch p)
-{
- return p;
-}
-
-ADD_MUSIC (Untransposable_music);
-
-Untransposable_music::Untransposable_music (SCM init)
- : Music_wrapper (init)
-{
-
-}
(quoted-voice-direction ,ly:dir? "Should the quoted voice be up-stem or down-stem?")
(quoted-context-type ,symbol? "The name of the context to direct quotes to, eg., @code{Voice}.")
(quoted-context-id ,string? "The id of the context to direct quotes to, eg., @code{cue}.")
-
(to-relative-callback ,procedure? "How to transform a piece of music to relative pitches")
(repeat-count ,integer? "do a @code{\repeat} how ofen?")
(span-direction ,ly:dir? "Does this start or stop a spanner?")
. (
(description . "Combine two parts on a staff, either merged or
as separate voices.")
- (internal-class-name . "Simultaneous_music")
+ (internal-class-name . "Music")
(length-callback . ,Music_sequence::maximum_length_callback)
(start-callback . ,Music_sequence::minimum_start_callback)
(types . (general-music part-combine-music))
(RelativeOctaveCheck
. ((description . "Check if a pitch is in the correct octave.")
- (internal-class-name . "Relative_octave_check")
+ (internal-class-name . "Music")
+ (to-relative-callback . ,Relative_octave_check::relative_callback)
(types . (general-music relative-octave-check))
))
@code{ \\simultaneous @{ .. @}} or < .. >.")
- (internal-class-name . "Simultaneous_music")
+ (internal-class-name . "Music")
(iterator-ctor . ,Simultaneous_music_iterator::constructor)
(start-callback . ,Music_sequence::minimum_start_callback)
(length-callback . ,Music_sequence::maximum_length_callback)
+ (to-relative-callback . ,Music_sequence::simultaneous_relative_callback)
(types . (general-music simultaneous-music))
))
. (
(description . "Music that has been transposed.")
(internal-class-name . "Transposed_music")
+ (to-relative-callback . ,Relative_octave_music::no_relative_callback)
(types . (music-wrapper-music general-music transposed-music))
))
(UntransposableMusic
. (
(description . "Music that can not be transposed.")
+ (to-relative-callback . ,Relative_octave_music::no_relative_callback)
(untransposable . #t)
- (internal-class-name . "Untransposable_music")
+ (internal-class-name . "Music_wrapper")
(types . (music-wrapper-music general-music untransposable-music))
))
. (
(description . "Music that can not be converted from relative to absolute notation.
For example, transposed music.")
+ (to-relative-callback . ,Relative_octave_music::no_relative_callback)
(internal-class-name . "Un_relativable_music")
(types . (music-wrapper-music general-music unrelativable-music))
))
(RelativeOctaveMusic
. (
(description . "Music that was entered in relative octave notation.")
-
- (internal-class-name . "Relative_octave_music")
+ (to-relative-callback . ,Relative_octave_music::relative_callback)
+ (internal-class-name . "Music_wrapper")
(types . (music-wrapper-music general-music relative-octave-music))
))
(EventChord
. (
(description . "Internally used to group a set of events.")
- (internal-class-name . "Event_chord")
+ (internal-class-name . "Music")
(iterator-ctor . ,Event_chord_iterator::constructor)
(length-callback . ,Music_sequence::maximum_length_callback)
+ (to-relative-callback . ,Music_sequence::event_chord_relative_callback)
(types . (general-music event-chord simultaneous-music))
- )
- )
+ ))
(ScriptEvent
. (